3
0
mirror of https://github.com/triqs/dft_tools synced 2024-08-06 20:40:00 +02:00

[cmake] Do not enable compiler warnings globally but instead through an interface target

This commit is contained in:
Nils Wentzell 2019-06-26 11:06:04 -04:00
parent 162bf1a482
commit 24f49da39c
3 changed files with 18 additions and 8 deletions

View File

@ -17,13 +17,23 @@ 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>
)
$<$<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)

View File

@ -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)

View File

@ -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)