mirror of
https://github.com/triqs/dft_tools
synced 2024-12-23 04:43:42 +01:00
Major update and Cleaning
-consistent indends in all cmake files -add static analyzer checks with both cppcheck and clang-tidy -add dynamic analyzer checks with Address Sanitizer and option ASAN -add dynamic analyzer checks with Undefined Behavior Sanitizer and option UBSAN -Further Cleaning and Comments
This commit is contained in:
parent
616479d883
commit
f2d7e84bdd
@ -1 +1,2 @@
|
|||||||
Checks: '-*,modernize-*,cppcoreguidelines-*'
|
Checks: '-*,modernize-*,cppcoreguidelines-*'
|
||||||
|
HeaderFilterRegex: 'app4triqs'
|
||||||
|
12
.travis.yml
12
.travis.yml
@ -37,15 +37,11 @@ script:
|
|||||||
- make -j8 install
|
- make -j8 install
|
||||||
- cd $TRAVIS_BUILD_DIR
|
- cd $TRAVIS_BUILD_DIR
|
||||||
- source root_install/share/triqsvars.sh
|
- source root_install/share/triqsvars.sh
|
||||||
# ===== Set up CTINT and Test using fsanitize=address
|
# ===== Set up CTINT and Test with Sanitizer Checks
|
||||||
- mkdir build && cd build
|
- mkdir build && cd build
|
||||||
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=/usr/bin/${CXX} -DGTAU_IS_COMPLEX=ON -DINTERACTION_IS_COMPLEX=ON -DCMAKE_CXX_FLAGS='-fsanitize=address -fno-omit-frame-pointer -fuse-ld=gold -Wno-register -Wno-macro-redefined'
|
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=/usr/bin/${CXX} -DASAN=ON -DUBSAN=ON
|
||||||
- make -j8
|
- export UBSAN_SYMBOLIZER_PATH=/usr/lib/llvm-5.0/bin/llvm-symbolizer
|
||||||
- export ASAN_SYMBOLIZER_PATH=/usr/lib/llvm-5.0/bin/llvm-symbolizer
|
- export ASAN_SYMBOLIZER_PATH=/usr/lib/llvm-5.0/bin/llvm-symbolizer
|
||||||
- export ASAN_OPTIONS=symbolize=1:detect_leaks=0
|
- export ASAN_OPTIONS=symbolize=1:detect_leaks=0
|
||||||
- export CTEST_OUTPUT_ON_FAILURE=1
|
- export CTEST_OUTPUT_ON_FAILURE=1
|
||||||
- cd test/c++ && ctest
|
- make -j8 && make test
|
||||||
- if [ "$CXX" = g++ ]; then export LD_PRELOAD=/usr/lib/gcc/x86_64-linux-gnu/7/libasan.so; elif [ "$CXX" = clang++ ]; then export LD_PRELOAD=/usr/lib/llvm-5.0/lib/clang/5.0.1/lib/linux/libclang_rt.asan-x86_64.so; fi
|
|
||||||
- cd ../python && ctest
|
|
||||||
- cd ../../
|
|
||||||
- unset LD_PRELOAD
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
set(APP4TRIQS_VERSION "1.5")
|
set(APP4TRIQS_VERSION "1.5")
|
||||||
|
|
||||||
# Start configuration
|
# Start configuration
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 3.6)
|
||||||
project(app4triqs CXX)
|
project(app4triqs CXX)
|
||||||
|
|
||||||
# Default to Release build type
|
# Default to Release build type
|
||||||
@ -14,13 +14,10 @@ message( STATUS "-------- BUILD-TYPE: ${CMAKE_BUILD_TYPE} --------")
|
|||||||
# Use shared libraries
|
# Use shared libraries
|
||||||
set(BUILD_SHARED_LIBS ON)
|
set(BUILD_SHARED_LIBS ON)
|
||||||
|
|
||||||
# Load TRIQS and Cpp2Py
|
# 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)
|
||||||
|
|
||||||
# We will need the FindNNFT of triqs, so we adjust CMake Module Path to find it
|
|
||||||
list(APPEND CMAKE_MODULE_PATH ${TRIQS_ROOT}/share/cmake)
|
|
||||||
|
|
||||||
# Default Install directory to TRIQS_ROOT if not given. Checks an absolute name is given.
|
# Default Install directory to TRIQS_ROOT if not given. Checks an absolute name is given.
|
||||||
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")
|
||||||
@ -35,9 +32,12 @@ message(STATUS "app4triqs git hash: ${APP4TRIQS_GIT_HASH}")
|
|||||||
# Set up the rpath for compiled executable
|
# Set up the rpath for compiled executable
|
||||||
triqs_set_rpath_for_all_targets()
|
triqs_set_rpath_for_all_targets()
|
||||||
|
|
||||||
|
# Build and install the app4triqs library
|
||||||
add_subdirectory(c++/app4triqs)
|
add_subdirectory(c++/app4triqs)
|
||||||
|
|
||||||
|
# Build and install the app4triqs python module
|
||||||
if(${TRIQS_WITH_PYTHON_SUPPORT})
|
if(${TRIQS_WITH_PYTHON_SUPPORT})
|
||||||
add_subdirectory(python/app4triqs)
|
add_subdirectory(python/app4triqs)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
|
@ -1,20 +1,77 @@
|
|||||||
file(GLOB_RECURSE sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
file(GLOB_RECURSE sources *.cpp *.hpp)
|
||||||
add_library(app4triqs_c ${sources})
|
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_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}
|
||||||
$<$<CONFIG:Debug>:DEBUG_APP4TRIQS>
|
$<$<CONFIG:Debug>:APP4TRIQS_DEBUG>
|
||||||
$<$<CONFIG:Debug>:TRIQS_ARRAYS_ENFORCE_BOUNDCHECK>
|
$<$<CONFIG:Debug>:TRIQS_ARRAYS_ENFORCE_BOUNDCHECK>
|
||||||
#$<$<BOOL:${MyOption}>:MYOPTION> # Add compile definintions for option
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install
|
# Install library and headers
|
||||||
install(TARGETS app4triqs_c EXPORT app4triqs-targets DESTINATION lib)
|
install(TARGETS app4triqs_c EXPORT app4triqs-targets DESTINATION lib)
|
||||||
|
|
||||||
# If other applications need our headers, we can install them as well
|
|
||||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION include FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h")
|
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION include FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h")
|
||||||
|
|
||||||
|
|
||||||
|
# ========= Static Analyzer Checks ==========
|
||||||
|
|
||||||
|
# Locate static analyzer tools
|
||||||
|
find_program(CPPCHECK_EXECUTABLE NAMES "cppcheck" PATHS ENV PATH)
|
||||||
|
find_program(CLANG_TIDY_EXECUTABLE NAMES "clang-tidy" PATHS ENV PATH)
|
||||||
|
|
||||||
|
# Run clang-tidy if found
|
||||||
|
if(CLANG_TIDY_EXECUTABLE)
|
||||||
|
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXECUTABLE}")
|
||||||
|
set_target_properties(app4triqs_c PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}")
|
||||||
|
else()
|
||||||
|
message(STATUS "clang-tidy not found in $PATH. Please consider installing clang-tidy for additional checks!")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Run cppcheck if found
|
||||||
|
if(CPPCHECK_EXECUTABLE)
|
||||||
|
message(STATUS "cppcheck found: ${CPPCHECK_EXECUTABLE}")
|
||||||
|
add_custom_command(
|
||||||
|
TARGET app4triqs_c
|
||||||
|
COMMAND echo "--- Running cppcheck ---\n"
|
||||||
|
COMMAND ${CPPCHECK_EXECUTABLE}
|
||||||
|
--enable=warning,style,performance,portability
|
||||||
|
--std=c++14
|
||||||
|
--template=gcc
|
||||||
|
--verbose
|
||||||
|
--quiet
|
||||||
|
${sources}
|
||||||
|
COMMAND echo "------------------------\n"
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(STATUS "cppcheck not found in $PATH. Please consider installing cppcheck for additional checks!")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
# ========= Dynamic Analyzer Checks ==========
|
||||||
|
|
||||||
|
# Address Sanitizer
|
||||||
|
option(ASAN OFF "Compile library and executables with LLVM Address Sanitizer")
|
||||||
|
if(ASAN)
|
||||||
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
|
message(FATAL_ERROR "Address Sanitizer Checks currently not compatible with OSX.")
|
||||||
|
endif()
|
||||||
|
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")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Undefined Behavior Sanitizer
|
||||||
|
option(UBSAN OFF "Compile library and executables with LLVM Undefined Behavior Sanitizer")
|
||||||
|
if(UBSAN)
|
||||||
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
|
message(FATAL_ERROR "Undefined Behavior Sanitizer Checks currently not compatible with OSX.")
|
||||||
|
endif()
|
||||||
|
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")
|
||||||
|
endif()
|
||||||
|
@ -14,20 +14,22 @@ namespace app4triqs {
|
|||||||
int i = 0.0;
|
int i = 0.0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
toto() = default;
|
toto() = default;
|
||||||
|
|
||||||
// Copy construction
|
|
||||||
toto(toto const &) = default;
|
|
||||||
toto(toto &&) = default;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct from integer
|
* Construct from integer
|
||||||
*
|
*
|
||||||
* @param i_ a scalar
|
* @param i_ a scalar
|
||||||
*/
|
*/
|
||||||
toto(int i_) : i(i_) {}
|
explicit toto(int i_) : i(i_) {}
|
||||||
|
|
||||||
/// Copy assignment
|
~toto() = default;
|
||||||
|
|
||||||
|
// Copy/Move construction
|
||||||
|
toto(toto const &) = default;
|
||||||
|
toto(toto &&) = default;
|
||||||
|
|
||||||
|
/// Copy/Move assignment
|
||||||
toto &operator=(toto const &) = default;
|
toto &operator=(toto const &) = default;
|
||||||
toto &operator=(toto &&) = default;
|
toto &operator=(toto &&) = default;
|
||||||
|
|
||||||
@ -45,7 +47,6 @@ namespace app4triqs {
|
|||||||
static std::string hdf5_scheme() { return "Toto"; }
|
static std::string hdf5_scheme() { return "Toto"; }
|
||||||
|
|
||||||
friend void h5_write(triqs::h5::group grp, std::string subgroup_name, toto const &m);
|
friend void h5_write(triqs::h5::group grp, std::string subgroup_name, toto const &m);
|
||||||
|
|
||||||
friend void h5_read(triqs::h5::group grp, std::string subgroup_name, toto &m);
|
friend void h5_read(triqs::h5::group grp, std::string subgroup_name, toto &m);
|
||||||
|
|
||||||
/// Serialization
|
/// Serialization
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
# Generate the conf.py
|
# Generate the sphinx config file
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/conf.py @ONLY)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/conf.py @ONLY)
|
||||||
|
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
# Top Sphinx target
|
# Top Sphinx target
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
# Sources
|
|
||||||
file(GLOB_RECURSE sources *.rst)
|
file(GLOB_RECURSE sources *.rst)
|
||||||
|
|
||||||
set(sphinx_top ${CMAKE_CURRENT_BINARY_DIR}/html/contents.html)
|
set(sphinx_top ${CMAKE_CURRENT_BINARY_DIR}/html/contents.html)
|
||||||
@ -20,48 +19,45 @@ add_dependencies(docs_sphinx app4triqs_c)
|
|||||||
# cp_rs is a script in cpp2py/bin, it mimics cp -rs on Linux
|
# cp_rs is a script in cpp2py/bin, it mimics cp -rs on Linux
|
||||||
# and filters the relevant extension
|
# and filters the relevant extension
|
||||||
# ------------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
set(EXT_FOR_DOC "rst png txt css_t conf css js gif jpg py html bib")
|
set(EXT_FOR_DOC "rst png txt css_t conf css js gif jpg py html bib")
|
||||||
execute_process(COMMAND cp_rs ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${EXT_FOR_DOC})
|
execute_process(COMMAND cp_rs ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${EXT_FOR_DOC})
|
||||||
|
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
# Generate C++ doc with c++2rst
|
# Generate C++ doc with c++2rst
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
|
|
||||||
add_custom_target(docs_cpp2rst)
|
add_custom_target(docs_cpp2rst)
|
||||||
|
|
||||||
get_property(TRIQS_INCLUDE_DIRS TARGET triqs PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
get_property(TRIQS_INCLUDE_DIRS TARGET triqs PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
get_property(APP4TRIQS_INCLUDE_DIRS TARGET app4triqs_c PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
get_property(APP4TRIQS_INCLUDE_DIRS TARGET app4triqs_c PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
|
|
||||||
set(CPP2RST_INCLUDE_DIRS ${TRIQS_INCLUDE_DIRS} ${APP4TRIQS_INCLUDE_DIRS})
|
set(CPP2RST_INCLUDE_DIRS ${TRIQS_INCLUDE_DIRS} ${APP4TRIQS_INCLUDE_DIRS})
|
||||||
|
|
||||||
foreach(I ${CPP2RST_INCLUDE_DIRS})
|
foreach(I ${CPP2RST_INCLUDE_DIRS})
|
||||||
set (CPP2RST_INCLUDE_COMMAND ${CPP2RST_INCLUDE_COMMAND} --includes ${I})
|
set (CPP2RST_INCLUDE_COMMAND ${CPP2RST_INCLUDE_COMMAND} --includes ${I})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
macro(generate_docs header_file)
|
macro(generate_docs header_file)
|
||||||
add_custom_command (TARGET docs_cpp2rst
|
add_custom_command(
|
||||||
COMMAND c++2rst
|
TARGET docs_cpp2rst
|
||||||
${header_file}
|
COMMAND c++2rst
|
||||||
-N app4triqs
|
${header_file}
|
||||||
--output_directory ${CMAKE_CURRENT_BINARY_DIR}/cpp2rst_generated
|
-N app4triqs
|
||||||
${CPP2RST_INCLUDE_COMMAND}
|
--output_directory ${CMAKE_CURRENT_BINARY_DIR}/cpp2rst_generated
|
||||||
--cxxflags="-std=c++17"
|
${CPP2RST_INCLUDE_COMMAND}
|
||||||
-I ${CMAKE_SOURCE_DIR}/c++
|
--cxxflags="-std=c++17"
|
||||||
-I ${TRIQS_ROOT}/include
|
-I ${CMAKE_SOURCE_DIR}/c++
|
||||||
2>&1 >> cpp2rst.log
|
-I ${TRIQS_ROOT}/include
|
||||||
)
|
2>&1 >> cpp2rst.log
|
||||||
|
)
|
||||||
endmacro(generate_docs)
|
endmacro(generate_docs)
|
||||||
|
|
||||||
generate_docs(${CMAKE_SOURCE_DIR}/c++/app4triqs/toto.hpp)
|
generate_docs(${CMAKE_SOURCE_DIR}/c++/app4triqs/toto.hpp)
|
||||||
|
|
||||||
add_dependencies(docs_sphinx docs_cpp2rst)
|
add_dependencies(docs_sphinx docs_cpp2rst)
|
||||||
|
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
# Install
|
# Install
|
||||||
# ---------------------------------
|
# ---------------------------------
|
||||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ COMPONENT documentation DESTINATION share/doc/app4triqs
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ COMPONENT documentation DESTINATION share/doc/app4triqs
|
||||||
FILES_MATCHING
|
FILES_MATCHING
|
||||||
REGEX "\\.(html|pdf|png|gif|jpg|js|xsl|css|py|txt|inv|bib)$"
|
REGEX "\\.(html|pdf|png|gif|jpg|js|xsl|css|py|txt|inv|bib)$"
|
||||||
PATTERN "_*"
|
PATTERN "_*"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ configure_file(version.py.in version.py)
|
|||||||
# All Python files. Copy them in the build dir to have a complete package for the tests.
|
# All Python files. Copy them in the build dir to have a complete package for the tests.
|
||||||
set(PYTHON_SOURCES __init__.py)
|
set(PYTHON_SOURCES __init__.py)
|
||||||
foreach(f ${PYTHON_SOURCES})
|
foreach(f ${PYTHON_SOURCES})
|
||||||
configure_file(${f} ${f} COPYONLY)
|
configure_file(${f} ${f} COPYONLY)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Install python module to proper location
|
# Install python module to proper location
|
||||||
|
@ -2,22 +2,22 @@ add_subdirectory(cmake)
|
|||||||
|
|
||||||
if(NOT CMAKE_INSTALL_PREFIX STREQUAL TRIQS_ROOT)
|
if(NOT CMAKE_INSTALL_PREFIX STREQUAL TRIQS_ROOT)
|
||||||
|
|
||||||
configure_file(app4triqs.modulefile.in app4triqs.modulefile @ONLY)
|
configure_file(app4triqs.modulefile.in app4triqs.modulefile @ONLY)
|
||||||
configure_file(app4triqsvars.sh.in app4triqsvars.sh @ONLY)
|
configure_file(app4triqsvars.sh.in app4triqsvars.sh @ONLY)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/app4triqs.modulefile
|
${CMAKE_CURRENT_BINARY_DIR}/app4triqs.modulefile
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/app4triqsvars.sh
|
${CMAKE_CURRENT_BINARY_DIR}/app4triqsvars.sh
|
||||||
DESTINATION share
|
DESTINATION share
|
||||||
)
|
)
|
||||||
|
|
||||||
message(STATUS "***************************************************************")
|
message(STATUS "***************************************************************")
|
||||||
message(STATUS "* Custom install Location. Use: ")
|
message(STATUS "* Custom install Location. Use: ")
|
||||||
message(STATUS "* ")
|
message(STATUS "* ")
|
||||||
message(STATUS "* source ${CMAKE_INSTALL_PREFIX}/share/app4triqsvars.sh ")
|
message(STATUS "* source ${CMAKE_INSTALL_PREFIX}/share/app4triqsvars.sh ")
|
||||||
message(STATUS "* ")
|
message(STATUS "* ")
|
||||||
message(STATUS "* to set up the environment variables ")
|
message(STATUS "* to set up the environment variables ")
|
||||||
message(STATUS "***************************************************************")
|
message(STATUS "***************************************************************")
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
configure_file(app4triqs-config.cmake.in app4triqs-config.cmake @ONLY)
|
configure_file(app4triqs-config.cmake.in app4triqs-config.cmake @ONLY)
|
||||||
configure_file(app4triqs-config-version.cmake.in app4triqs-config-version.cmake @ONLY)
|
configure_file(app4triqs-config-version.cmake.in app4triqs-config-version.cmake @ONLY)
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/app4triqs-config.cmake
|
${CMAKE_CURRENT_BINARY_DIR}/app4triqs-config.cmake
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/app4triqs-config-version.cmake
|
${CMAKE_CURRENT_BINARY_DIR}/app4triqs-config-version.cmake
|
||||||
DESTINATION share/cmake
|
DESTINATION share/cmake
|
||||||
)
|
)
|
||||||
|
|
||||||
install(EXPORT app4triqs-targets DESTINATION share/cmake)
|
install(EXPORT app4triqs-targets DESTINATION share/cmake)
|
||||||
|
50
share/cmake/Findlibasan_rt.cmake
Normal file
50
share/cmake/Findlibasan_rt.cmake
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# Copyright Nils Wentzell 2018
|
||||||
|
# Distributed under the GNU GENERAL PUBLIC LICENSE Version 3.0.
|
||||||
|
# See accompanying file LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
|
#
|
||||||
|
# This cmake find module looks for the LLVM Address Sanitizer Runtime Library
|
||||||
|
# It sets up : ASAN_RT_LIBRARY
|
||||||
|
|
||||||
|
# This module finds the LLVM Address Sanitizer Runtime Library
|
||||||
|
# latter case skip to the "Boost CMake" section below. For the former
|
||||||
|
#
|
||||||
|
# Use this module by invoking find_package with the form::
|
||||||
|
#
|
||||||
|
# find_package(libasan_rt [REQUIRED])
|
||||||
|
#
|
||||||
|
# Results are reported in::
|
||||||
|
#
|
||||||
|
# ASAN_RT_LIBRARY Address Sanitizer Runtime Library
|
||||||
|
|
||||||
|
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
||||||
|
set(name clang_rt.asan-x86_64)
|
||||||
|
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
|
||||||
|
set(name asan)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "LLVM Address Sanitizer is not available for your compiler")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_library(ASAN_RT_LIBRARY
|
||||||
|
NAMES ${name}
|
||||||
|
PATHS
|
||||||
|
ENV LIBRARY_PATH
|
||||||
|
ENV LD_INCLUDE_PATH
|
||||||
|
/usr/lib
|
||||||
|
/usr/local/lib
|
||||||
|
/usr/lib/gcc/*/*
|
||||||
|
/usr/lib/clang/*/lib/linux
|
||||||
|
/usr/lib/llvm-*/lib/clang/*/lib/linux
|
||||||
|
/usr/local/opt/llvm/lib/clang/*/lib/darwin
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(ASAN_RT_LIBRARY)
|
||||||
|
|
||||||
|
# Imported target
|
||||||
|
add_library(libasan_rt SHARED IMPORTED)
|
||||||
|
set_property(TARGET libasan_rt PROPERTY IMPORTED_LOCATION ${ASAN_RT_LIBRARY})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args("Address Sanitizer Runtime Library"
|
||||||
|
REQUIRED_VARS ASAN_RT_LIBRARY
|
||||||
|
FAIL_MESSAGE "Address Sanitizer Runtime Libraries not found! Consider installing for additional checks!"
|
||||||
|
)
|
50
share/cmake/Findlibubsan_rt.cmake
Normal file
50
share/cmake/Findlibubsan_rt.cmake
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# Copyright Nils Wentzell 2018
|
||||||
|
# Distributed under the GNU GENERAL PUBLIC LICENSE Version 3.0.
|
||||||
|
# See accompanying file LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
|
#
|
||||||
|
# This cmake find module looks for the LLVM Undefined Behavior Sanitizer Runtime Library
|
||||||
|
# It sets up : UBSAN_RT_LIBRARY
|
||||||
|
|
||||||
|
# This module finds the LLVM Undefined Behavior Sanitizer Runtime Library
|
||||||
|
# latter case skip to the "Boost CMake" section below. For the former
|
||||||
|
#
|
||||||
|
# Use this module by invoking find_package with the form::
|
||||||
|
#
|
||||||
|
# find_package(libubsan_rt [REQUIRED])
|
||||||
|
#
|
||||||
|
# Results are reported in::
|
||||||
|
#
|
||||||
|
# UBSAN_RT_LIBRARY Undefined Behavior Sanitizer Runtime Library
|
||||||
|
|
||||||
|
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
||||||
|
set(name clang_rt.ubsan_standalone-x86_64)
|
||||||
|
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
|
||||||
|
set(name ubsan)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Undefined Behavior Sanitizer is not available for your compiler")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_library(UBSAN_RT_LIBRARY
|
||||||
|
NAMES ${name}
|
||||||
|
PATHS
|
||||||
|
ENV LIBRARY_PATH
|
||||||
|
ENV LD_INCLUDE_PATH
|
||||||
|
/usr/lib
|
||||||
|
/usr/local/lib
|
||||||
|
/usr/lib/gcc/*/*
|
||||||
|
/usr/lib/clang/*/lib/linux
|
||||||
|
/usr/lib/llvm-*/lib/clang/*/lib/linux
|
||||||
|
/usr/local/opt/llvm/lib/clang/*/lib/darwin
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(UBSAN_RT_LIBRARY)
|
||||||
|
|
||||||
|
# Imported target
|
||||||
|
add_library(libubsan_rt SHARED IMPORTED)
|
||||||
|
set_property(TARGET libubsan_rt PROPERTY IMPORTED_LOCATION ${UBSAN_RT_LIBRARY})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args("Undefined Behavior Sanitizer Runtime Library"
|
||||||
|
REQUIRED_VARS UBSAN_RT_LIBRARY
|
||||||
|
FAIL_MESSAGE "Undefined Behavior Sanitizer Runtime Libraries not found! Consider installing for additional checks!"
|
||||||
|
)
|
@ -8,4 +8,21 @@ foreach(t ${all_tests})
|
|||||||
add_executable(${t} ${CMAKE_CURRENT_SOURCE_DIR}/${t}.cpp)
|
add_executable(${t} ${CMAKE_CURRENT_SOURCE_DIR}/${t}.cpp)
|
||||||
target_link_libraries(${t} app4triqs_c gtest)
|
target_link_libraries(${t} app4triqs_c gtest)
|
||||||
add_test(${t} ${CMAKE_CURRENT_BINARY_DIR}/${t})
|
add_test(${t} ${CMAKE_CURRENT_BINARY_DIR}/${t})
|
||||||
|
# Run clang-tidy if found
|
||||||
|
#if(CLANG_TIDY_EXECUTABLE)
|
||||||
|
#set_target_properties(${t} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}")
|
||||||
|
#endif()
|
||||||
|
## Run cppcheck if found
|
||||||
|
#if(CPPCHECK_EXECUTABLE)
|
||||||
|
#add_custom_command(
|
||||||
|
#TARGET ${t}
|
||||||
|
#COMMAND ${CPPCHECK_EXECUTABLE}
|
||||||
|
#--enable=warning,style,performance,portability
|
||||||
|
#--std=c++14
|
||||||
|
#--template=gcc
|
||||||
|
#--verbose
|
||||||
|
#--quiet
|
||||||
|
#${CMAKE_CURRENT_SOURCE_DIR}/${t}.cpp
|
||||||
|
#)
|
||||||
|
#endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -9,4 +9,8 @@ foreach(t ${all_tests})
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Set the PythonPath : put the build dir first (in case there is an installed version).
|
# Set the PythonPath : put the build dir first (in case there is an installed version).
|
||||||
set_property(TEST ${all_tests} PROPERTY ENVIRONMENT PYTHONPATH=${CMAKE_BINARY_DIR}/python:$ENV{PYTHONPATH} )
|
set_property(TEST ${all_tests} PROPERTY
|
||||||
|
ENVIRONMENT
|
||||||
|
PYTHONPATH=${CMAKE_BINARY_DIR}/python:$ENV{PYTHONPATH}
|
||||||
|
LD_PRELOAD=$<$<BOOL:${ASAN}>:${ASAN_RT_LIBRARY}>:$<$<BOOL:${UBSAN}>:${UBSAN_RT_LIBRARY}>
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user