mirror of
https://github.com/triqs/dft_tools
synced 2025-01-03 10:05:49 +01:00
[cmake] Do not enable compiler warnings globally but instead through an interface target
This commit is contained in:
parent
162bf1a482
commit
24f49da39c
@ -17,14 +17,24 @@ set(BUILD_SHARED_LIBS OFF)
|
||||
# Export the list of compile-commands into compile_commands.json
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# Enable compiler warnings for the whole project
|
||||
# Global compiler options
|
||||
add_compile_options(
|
||||
-Wall
|
||||
-Wextra
|
||||
$<$<CONFIG:Debug>:-Og>
|
||||
$<$<CONFIG:Debug>:-ggdb3>
|
||||
)
|
||||
|
||||
# Create an Interface target for compiler warnings
|
||||
add_library(project_warnings INTERFACE)
|
||||
install(TARGETS project_warnings EXPORT app4triqs-targets)
|
||||
target_compile_options(project_warnings
|
||||
INTERFACE
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wshadow
|
||||
-Wpedantic
|
||||
-Wno-sign-compare
|
||||
)
|
||||
|
||||
# Load Dependencies
|
||||
find_package(TRIQS 2.2 REQUIRED)
|
||||
find_package(Cpp2Py 1.6 REQUIRED)
|
||||
|
@ -2,7 +2,7 @@ file(GLOB_RECURSE sources *.cpp)
|
||||
add_library(app4triqs_c ${sources})
|
||||
|
||||
# Link against dependencies
|
||||
target_link_libraries(app4triqs_c PUBLIC triqs)
|
||||
target_link_libraries(app4triqs_c PUBLIC triqs PRIVATE project_warnings)
|
||||
|
||||
# Configure compilation
|
||||
target_compile_options(app4triqs_c PUBLIC -fPIC)
|
||||
|
@ -10,7 +10,7 @@ set(all_tests toto)
|
||||
foreach(test ${all_tests})
|
||||
get_filename_component(test_name ${test} NAME_WE)
|
||||
add_executable(${test_name} ${test})
|
||||
target_link_libraries(${test_name} app4triqs_c triqs::gtest)
|
||||
target_link_libraries(${test_name} app4triqs_c triqs::gtest project_warnings)
|
||||
add_test(${test_name} ${test_name})
|
||||
# Run clang-tidy if found
|
||||
if(CLANG_TIDY_EXECUTABLE)
|
||||
|
Loading…
Reference in New Issue
Block a user