3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-22 20:34:38 +01:00

Enable all compiler warnings, Include Triqs headers as SYSTEM, fix linker for sanitizers

This commit is contained in:
Nils Wentzell 2018-03-25 19:57:55 +02:00
parent f0b49145da
commit e3c4366d54
3 changed files with 9 additions and 5 deletions

View File

@ -14,11 +14,14 @@ message( STATUS "-------- BUILD-TYPE: ${CMAKE_BUILD_TYPE} --------")
# Use shared libraries
set(BUILD_SHARED_LIBS ON)
# Enable compiler warnings for the whole project
add_definitions(-Wall)
# Load Dependencies
find_package(TRIQS ${APP4TRIQS_VERSION} EXACT REQUIRED)
find_package(Cpp2Py ${APP4TRIQS_VERSION} EXACT REQUIRED)
# Default Install directory to TRIQS_ROOT if not given. Checks an absolute name is given.
# Default Install directory to TRIQS_ROOT if not given or invalid.
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR (NOT IS_ABSOLUTE ${CMAKE_INSTALL_PREFIX}))
message(STATUS "No install prefix given (or invalid). Defaulting to TRIQS_ROOT")
set(CMAKE_INSTALL_PREFIX ${TRIQS_ROOT} CACHE PATH "default install path" FORCE)
@ -29,7 +32,7 @@ message(STATUS "-------- INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX} --------")
triqs_get_git_hash_of_source_dir(APP4TRIQS_GIT_HASH)
message(STATUS "app4triqs git hash: ${APP4TRIQS_GIT_HASH}")
# Set up the rpath for compiled executable
# Set up the rpath for all compiled executables
triqs_set_rpath_for_all_targets()
# Build and install the app4triqs library

View File

@ -4,6 +4,7 @@ add_library(app4triqs_c ${sources})
target_link_libraries(app4triqs_c PUBLIC triqs)
target_compile_options(app4triqs_c PUBLIC -std=c++17)
target_include_directories(app4triqs_c PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/c++>)
target_include_directories(app4triqs_c SYSTEM PUBLIC ${TRIQS_ROOT}/include)
target_compile_definitions(app4triqs_c PRIVATE
APP4TRIQS_GIT_HASH=${APP4TRIQS_GIT_HASH}
TRIQS_GIT_HASH=${TRIQS_GIT_HASH}
@ -61,7 +62,7 @@ if(ASAN)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/share/cmake)
find_package(libasan_rt REQUIRED)
target_compile_options(app4triqs_c PUBLIC -fsanitize=address -fno-omit-frame-pointer)
target_link_libraries(app4triqs_c INTERFACE "-fsanitize=address -fno-omit-frame-pointer")
target_link_libraries(app4triqs_c INTERFACE "-fsanitize=address -fno-omit-frame-pointer -fuse-ld=gold")
endif()
# Undefined Behavior Sanitizer
@ -73,5 +74,5 @@ if(UBSAN)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/share/cmake)
find_package(libubsan_rt REQUIRED)
target_compile_options(app4triqs_c PUBLIC -fsanitize=undefined -fno-omit-frame-pointer -fno-sanitize=vptr)
target_link_libraries(app4triqs_c INTERFACE "-fsanitize=undefined -fno-omit-frame-pointer")
target_link_libraries(app4triqs_c INTERFACE "-fsanitize=undefined -fno-omit-frame-pointer -fuse-ld=gold")
endif()

View File

@ -8,7 +8,7 @@ foreach(t ${all_tests})
add_test(NAME ${t} COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/${t}.py)
endforeach()
# Set the PythonPath : put the build dir first (in case there is an installed version).
# Set the PythonPath and the Sanitizer Library Preloads
set_property(TEST ${all_tests} PROPERTY
ENVIRONMENT
PYTHONPATH=${CMAKE_BINARY_DIR}/python:$ENV{PYTHONPATH}