mirror of
https://github.com/triqs/dft_tools
synced 2025-01-09 12:44:03 +01:00
Enable all compiler warnings, Include Triqs headers as SYSTEM, fix linker for sanitizers
This commit is contained in:
parent
f0b49145da
commit
e3c4366d54
@ -14,11 +14,14 @@ message( STATUS "-------- BUILD-TYPE: ${CMAKE_BUILD_TYPE} --------")
|
|||||||
# Use shared libraries
|
# Use shared libraries
|
||||||
set(BUILD_SHARED_LIBS ON)
|
set(BUILD_SHARED_LIBS ON)
|
||||||
|
|
||||||
|
# Enable compiler warnings for the whole project
|
||||||
|
add_definitions(-Wall)
|
||||||
|
|
||||||
# Load Dependencies
|
# Load Dependencies
|
||||||
find_package(TRIQS ${APP4TRIQS_VERSION} EXACT REQUIRED)
|
find_package(TRIQS ${APP4TRIQS_VERSION} EXACT REQUIRED)
|
||||||
find_package(Cpp2Py ${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}))
|
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")
|
message(STATUS "No install prefix given (or invalid). Defaulting to TRIQS_ROOT")
|
||||||
set(CMAKE_INSTALL_PREFIX ${TRIQS_ROOT} CACHE PATH "default install path" FORCE)
|
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)
|
triqs_get_git_hash_of_source_dir(APP4TRIQS_GIT_HASH)
|
||||||
message(STATUS "app4triqs git hash: ${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()
|
triqs_set_rpath_for_all_targets()
|
||||||
|
|
||||||
# Build and install the app4triqs library
|
# Build and install the app4triqs library
|
||||||
|
@ -4,6 +4,7 @@ add_library(app4triqs_c ${sources})
|
|||||||
target_link_libraries(app4triqs_c PUBLIC triqs)
|
target_link_libraries(app4triqs_c PUBLIC triqs)
|
||||||
target_compile_options(app4triqs_c PUBLIC -std=c++17)
|
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 PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/c++>)
|
||||||
|
target_include_directories(app4triqs_c SYSTEM PUBLIC ${TRIQS_ROOT}/include)
|
||||||
target_compile_definitions(app4triqs_c PRIVATE
|
target_compile_definitions(app4triqs_c PRIVATE
|
||||||
APP4TRIQS_GIT_HASH=${APP4TRIQS_GIT_HASH}
|
APP4TRIQS_GIT_HASH=${APP4TRIQS_GIT_HASH}
|
||||||
TRIQS_GIT_HASH=${TRIQS_GIT_HASH}
|
TRIQS_GIT_HASH=${TRIQS_GIT_HASH}
|
||||||
@ -61,7 +62,7 @@ if(ASAN)
|
|||||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/share/cmake)
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/share/cmake)
|
||||||
find_package(libasan_rt REQUIRED)
|
find_package(libasan_rt REQUIRED)
|
||||||
target_compile_options(app4triqs_c PUBLIC -fsanitize=address -fno-omit-frame-pointer)
|
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()
|
endif()
|
||||||
|
|
||||||
# Undefined Behavior Sanitizer
|
# Undefined Behavior Sanitizer
|
||||||
@ -73,5 +74,5 @@ if(UBSAN)
|
|||||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/share/cmake)
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/share/cmake)
|
||||||
find_package(libubsan_rt REQUIRED)
|
find_package(libubsan_rt REQUIRED)
|
||||||
target_compile_options(app4triqs_c PUBLIC -fsanitize=undefined -fno-omit-frame-pointer -fno-sanitize=vptr)
|
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()
|
endif()
|
||||||
|
@ -8,7 +8,7 @@ foreach(t ${all_tests})
|
|||||||
add_test(NAME ${t} COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/${t}.py)
|
add_test(NAME ${t} COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/${t}.py)
|
||||||
endforeach()
|
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
|
set_property(TEST ${all_tests} PROPERTY
|
||||||
ENVIRONMENT
|
ENVIRONMENT
|
||||||
PYTHONPATH=${CMAKE_BINARY_DIR}/python:$ENV{PYTHONPATH}
|
PYTHONPATH=${CMAKE_BINARY_DIR}/python:$ENV{PYTHONPATH}
|
||||||
|
Loading…
Reference in New Issue
Block a user