3
0
mirror of https://github.com/triqs/dft_tools synced 2024-08-16 01:08:29 +02:00

Major cleaning, Synchronize project structure with qmc codes

This commit is contained in:
Nils Wentzell 2019-04-02 18:07:03 -04:00
parent 4d2ba07226
commit 095409d879
16 changed files with 149 additions and 233 deletions

View File

@ -29,10 +29,10 @@ find_package(Cpp2Py 1.5 REQUIRED)
# Default Install directory to TRIQS_ROOT if not given or invalid. # 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)
endif() endif()
message(STATUS "-------- INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX} --------") message(STATUS "-------- CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX} --------")
# Define the app4triqs version numbers and get the git hash # Define the app4triqs version numbers and get the git hash
set(APP4TRIQS_VERSION_MAJOR 0) set(APP4TRIQS_VERSION_MAJOR 0)
@ -46,11 +46,6 @@ message(STATUS "Git hash: ${APP4TRIQS_GIT_HASH}")
# Build and install the app4triqs library # 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})
add_subdirectory(python/app4triqs)
endif()
# Tests # Tests
option(Build_Tests "Build tests" ON) option(Build_Tests "Build tests" ON)
if(Build_Tests) if(Build_Tests)
@ -58,19 +53,28 @@ if(Build_Tests)
add_subdirectory(test) add_subdirectory(test)
endif() endif()
# Additional configuration files if(TRIQS_WITH_PYTHON_SUPPORT)
add_subdirectory(share) # Python interface
add_subdirectory(python/app4triqs)
option(Build_Documentation "Build documentation" OFF) # Build the documentation
if(Build_Documentation) option(Build_Documentation "Build documentation" OFF)
if(Build_Documentation)
if(NOT TRIQS_WITH_DOCUMENTATION) if(NOT TRIQS_WITH_DOCUMENTATION)
message(WARNING "TRIQS library has not been compiled with its documentation! Cannot build documentation.") message(WARNING "TRIQS library has not been compiled with its documentation! Cannot build documentation.")
else() else()
message(STATUS "Documentation Build enabled") message(STATUS "Documentation Build enabled")
add_subdirectory(doc) add_subdirectory(doc)
endif() endif()
endif()
else()
message(WARNING "TRIQS library has been installed without Python support. Cannot build the Python Interface and Documentation.")
endif() endif()
# Additional configuration files
add_subdirectory(share)
# Debian Package
option(BUILD_DEBIAN_PACKAGE "Build a deb package" OFF) option(BUILD_DEBIAN_PACKAGE "Build a deb package" OFF)
if(BUILD_DEBIAN_PACKAGE) if(BUILD_DEBIAN_PACKAGE)
if(NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr") if(NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr")

16
LICENSE.txt Normal file
View File

@ -0,0 +1,16 @@
TRIQS: a Toolbox for Research in Interacting Quantum Systems
Copyright (C) 2014 by P. Seth, I. Krivenko, M. Ferrero, O. Parcollet
TRIQS is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
TRIQS (in the file COPYING.txt in this directory). If not, see
<http://www.gnu.org/licenses/>.

View File

@ -1,22 +1,23 @@
file(GLOB_RECURSE sources *.cpp) file(GLOB_RECURSE sources *.cpp)
add_library(app4triqs_c ${sources}) add_library(app4triqs_c ${sources})
# Link against triqs and use headers with SYSTEM flag for better warning messages # Link against dependencies
target_link_libraries(app4triqs_c PUBLIC triqs) target_link_libraries(app4triqs_c PUBLIC triqs)
target_include_directories(app4triqs_c SYSTEM PUBLIC ${TRIQS_ROOT}/include)
# Configure compilation
target_compile_options(app4triqs_c PUBLIC -std=c++17 -fPIC) target_compile_options(app4triqs_c PUBLIC -std=c++17 -fPIC)
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 PUBLIC
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>:APP4TRIQS_DEBUG> $<$<CONFIG:Debug>:APP4TRIQS_DEBUG>
$<$<CONFIG:Debug>:TRIQS_DEBUG>
$<$<CONFIG:Debug>:TRIQS_ARRAYS_ENFORCE_BOUNDCHECK> $<$<CONFIG:Debug>:TRIQS_ARRAYS_ENFORCE_BOUNDCHECK>
) )
# Install library and headers # Install library and headers
install(TARGETS app4triqs_c EXPORT app4triqs-targets DESTINATION lib) install(TARGETS app4triqs_c EXPORT app4triqs-targets DESTINATION lib)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION include/app4triqs FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h") install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION include FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h")
# ========= Static Analyzer Checks ========== # ========= Static Analyzer Checks ==========
@ -58,25 +59,32 @@ endif()
# ========= Dynamic Analyzer Checks ========== # ========= Dynamic Analyzer Checks ==========
# Make additional cmake Modules available set(sanitizers "")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/share/cmake)
# Address Sanitizer # Address Sanitizer
option(ASAN OFF "Compile library and executables with LLVM Address Sanitizer") option(ASAN OFF "Compile library and executables with LLVM Address Sanitizer")
if(ASAN) if(ASAN)
find_package(libasan_rt REQUIRED) list(APPEND sanitizers asan)
target_compile_options(app4triqs_c PUBLIC -fsanitize=address -fno-omit-frame-pointer) target_compile_options(app4triqs_c PRIVATE -fsanitize=address -fno-omit-frame-pointer -ggdb3)
target_link_libraries(app4triqs_c INTERFACE "-fsanitize=address -fno-omit-frame-pointer") target_link_libraries(app4triqs_c INTERFACE "-fsanitize=address -fno-omit-frame-pointer")
if(NOT DEFINED ENV{ASAN_OPTIONS})
message(WARNING "ASAN_OPTIONS is not set. Consider setting ASAN_OPTIONS=symbolize=1:detect_leaks=0 when running tests")
endif()
endif() endif()
# Undefined Behavior Sanitizer # Undefined Behavior Sanitizer
option(UBSAN OFF "Compile library and executables with LLVM Undefined Behavior Sanitizer") option(UBSAN OFF "Compile library and executables with LLVM Undefined Behavior Sanitizer")
if(UBSAN) if(UBSAN)
find_package(libubsan_rt REQUIRED) list(APPEND sanitizers ubsan)
target_compile_options(app4triqs_c PUBLIC -fsanitize=undefined -fno-omit-frame-pointer -fno-sanitize=vptr) target_compile_options(app4triqs_c PUBLIC -fsanitize=undefined -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-omit-frame-pointer -ggdb3)
target_link_libraries(app4triqs_c INTERFACE "-fsanitize=undefined -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-omit-frame-pointer") target_link_libraries(app4triqs_c INTERFACE "-fsanitize=undefined -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-omit-frame-pointer")
if(NOT DEFINED ENV{UBSAN_OPTIONS})
message(WARNING "UBSAN_OPTIONS is not set. Consider setting UBSAN_OPTIONS=symbolize=1:print_stacktrace=1:halt_on_error=1 when running tests")
endif()
endif() endif()
if(ASAN OR UBSAN AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") if(sanitizers)
find_package(sanitizer REQUIRED ${sanitizers})
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
target_link_libraries(app4triqs_c INTERFACE "-fuse-ld=gold") target_link_libraries(app4triqs_c INTERFACE "-fuse-ld=gold")
endif()
endif() endif()

View File

@ -4,6 +4,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in ${CMAKE_CURRENT_BINARY_DIR
# --------------------------------- # ---------------------------------
# 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)
@ -19,7 +20,7 @@ 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 md") set(EXT_FOR_DOC "rst png txt css_t conf css js gif jpg py html bib h5 md")
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})
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------

View File

@ -10,5 +10,5 @@
</p> </p>
<hr> <hr>
<p> <p>
<a href="https://github.com/triqs/cthyb"> <img style="width: 50px; margin: 10px 0 0 5px" src='https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png' alt="Visit the project on GitHub"/> </a> <a href="https://github.com/triqs/app4triqs"> <img style="width: 50px; margin: 10px 0 0 5px" src='https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png' alt="Visit the project on GitHub"/> </a>
</p> </p>

View File

@ -3,6 +3,7 @@
# TRIQS documentation build configuration file # TRIQS documentation build configuration file
import sys import sys
sys.path.insert(0, "@TRIQS_SPHINXEXT_PATH@/autorun")
sys.path.insert(0, "@TRIQS_SPHINXEXT_PATH@/numpydoc") sys.path.insert(0, "@TRIQS_SPHINXEXT_PATH@/numpydoc")
extensions = ['sphinx.ext.autodoc', extensions = ['sphinx.ext.autodoc',
@ -13,7 +14,8 @@ extensions = ['sphinx.ext.autodoc',
'sphinx.ext.viewcode', 'sphinx.ext.viewcode',
'sphinx.ext.autosummary', 'sphinx.ext.autosummary',
'plot_directive', 'plot_directive',
'numpydoc'] 'numpydoc',
'autorun']
source_suffix = '.rst' source_suffix = '.rst'

View File

@ -6,7 +6,7 @@ app4triqs
.. sidebar:: app4triqs 0.1 .. sidebar:: app4triqs 0.1
This is the homepage app4triqs Version 0.1 This is the homepage app4triqs Version 0.1
For the changes in 0.1, Cf :ref:`changelog page <changelog>` For changes see, Cf :ref:`changelog page <changelog>`
An example application using cpp2py and triqs. An example application using cpp2py and triqs.

View File

@ -1,21 +1,18 @@
# Build the python module # Build the python module
add_cpp2py_module(toto_module) add_cpp2py_module(toto_module)
target_link_libraries(toto_module app4triqs_c) target_link_libraries(toto_module app4triqs_c)
# We need to include the convertes.hxx files
target_include_directories(toto_module PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
# Configure the version # Configure the version
configure_file(version.py.in version.py) 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) file(GLOB_RECURSE python_sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py)
foreach(f ${PYTHON_SOURCES}) list(FILTER python_sources EXCLUDE REGEX "_desc.py")
configure_file(${f} ${f} COPYONLY) foreach(file ${python_sources})
configure_file(${file} ${file} COPYONLY)
endforeach() endforeach()
# Install python module to proper location # Install python module to proper location
set(PYTHON_LIB_DEST ${CPP2PY_PYTHON_LIB_DEST_ROOT}/app4triqs) set(PYTHON_LIB_DEST ${TRIQS_PYTHON_LIB_DEST_ROOT}/app4triqs)
install(TARGETS toto_module DESTINATION ${PYTHON_LIB_DEST}) install(TARGETS toto_module DESTINATION ${PYTHON_LIB_DEST})
install(FILES ${PYTHON_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/version.py DESTINATION ${PYTHON_LIB_DEST}) install(FILES ${python_sources} ${CMAKE_CURRENT_BINARY_DIR}/version.py DESTINATION ${PYTHON_LIB_DEST})

View File

@ -1,3 +1,26 @@
################################################################################
#
# TRIQS: a Toolbox for Research in Interacting Quantum Systems
#
# Copyright (C) 2016-2018, N. Wentzell
# Copyright (C) 2018-2019, The Simons Foundation
# author: N. Wentzell
#
# TRIQS is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
r""" r"""
DOC DOC

View File

@ -1,9 +1,32 @@
################################################################################
#
# TRIQS: a Toolbox for Research in Interacting Quantum Systems
#
# Copyright (C) 2016-2018, N. Wentzell
# Copyright (C) 2018-2019, Simons Foundation
# author: N. Wentzell
#
# TRIQS is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# TRIQS is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# TRIQS. If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
version = "@APP4TRIQS_VERSION@" version = "@APP4TRIQS_VERSION@"
triqs_hash = "@TRIQS_GIT_HASH@" triqs_hash = "@TRIQS_GIT_HASH@"
app4triqs_hash = "@APP4TRIQS_GIT_HASH@" app4triqs_hash = "@APP4TRIQS_GIT_HASH@"
def show_version(): def show_version():
print "\nYou are using app4triqs version %s, release %s\n"%(version, release) print "\nYou are using app4triqs version %s\n"%version
def show_git_hash(): def show_git_hash():
print "\nYou are using app4triqs git hash %s based on triqs git hash %s\n"%(app4triqs_hash, triqs_hash) print "\nYou are using app4triqs git hash %s based on triqs git hash %s\n"%(app4triqs_hash, triqs_hash)

View File

@ -1,55 +0,0 @@
# 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")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(name clang_rt.asan_osx_dynamic)
else()
set(name clang_rt.asan-x86_64)
endif()
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_LIBRARY_PATH
/usr/lib
/usr/local/lib
/usr/lib/gcc/*/7
/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!"
)

View File

@ -1,74 +0,0 @@
# 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
# [UBSAN_MINIMAL_RT_LIBRARY] Minimal version of UBSan Runtime, To be used in combination with Asan
set(TRIAL_PATHS
ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH
/usr/lib
/usr/local/lib
/usr/lib/gcc/7/*
/usr/lib/gcc/*/*
/usr/lib/clang/*/lib/linux
/usr/lib/llvm-*/lib/clang/*/lib/linux
/usr/local/opt/llvm/lib/clang/*/lib/darwin
)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(name clang_rt.ubsan_osx_dynamic)
else()
set(name clang_rt.ubsan_standalone-x86_64)
endif()
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 ${TRIAL_PATHS}
)
mark_as_advanced(UBSAN_RT_LIBRARY)
# Try to find UBSan Minimal Runtime for Clang
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(name libclang_rt.ubsan_minimal_osx_dynamic)
else()
set(name clang_rt.ubsan_minimal-x86_64)
endif()
find_library(UBSAN_MINIMAL_RT_LIBRARY
NAMES ${name}
PATHS ${TRIAL_PATHS}
)
mark_as_advanced(UBSAN_MINIMAL_RT_LIBRARY)
endif()
# 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!"
)

View File

@ -1,4 +1,5 @@
add_subdirectory(c++) add_subdirectory(c++)
if (${TRIQS_WITH_PYTHON_SUPPORT})
if(${TRIQS_WITH_PYTHON_SUPPORT})
add_subdirectory(python) add_subdirectory(python)
endif() endif()

View File

@ -1,34 +1,32 @@
# Copy reference h5 files to binary dir # Copy h5 files to binary dir
file(GLOB all_h5_files *.h5) file(GLOB_RECURSE all_h5_ref_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.ref.h5)
file(COPY ${all_h5_files} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) foreach(file ${all_h5_ref_files})
configure_file(${file} ${file} COPYONLY)
endforeach()
# List of all tests
set(all_tests toto) set(all_tests toto)
foreach(t ${all_tests}) foreach(test ${all_tests})
add_executable(${t} ${CMAKE_CURRENT_SOURCE_DIR}/${t}.cpp) get_filename_component(test_name ${test} NAME_WE)
target_link_libraries(${t} app4triqs_c gtest) add_executable(${test_name} ${test})
add_test(${t} ${CMAKE_CURRENT_BINARY_DIR}/${t}) target_link_libraries(${test_name} app4triqs_c gtest)
add_test(${test_name} ${test_name})
# Run clang-tidy if found # Run clang-tidy if found
if(CLANG_TIDY_EXECUTABLE) if(CLANG_TIDY_EXECUTABLE)
set_target_properties(${t} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}") set_target_properties(${test_name} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}")
endif() endif()
# Run cppcheck if found # Run cppcheck if found
if(CPPCHECK_EXECUTABLE) if(CPPCHECK_EXECUTABLE)
add_custom_command( add_custom_command(
TARGET ${t} TARGET ${test_name}
COMMAND ${CPPCHECK_EXECUTABLE} COMMAND ${CPPCHECK_EXECUTABLE}
--enable=warning,style,performance,portability --enable=warning,style,performance,portability
--std=c++14 --std=c++14
--template=gcc --template=gcc
--verbose --verbose
--quiet --quiet
${CMAKE_CURRENT_SOURCE_DIR}/${t}.cpp ${CMAKE_CURRENT_SOURCE_DIR}/${test}.cpp
) )
endif() endif()
endforeach() endforeach()
# Set UBSan Options for all tests
set_property(TEST ${all_tests} PROPERTY
ENVIRONMENT
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1:$ENV{UBSAN_OPTIONS}
)

View File

@ -1,43 +1,15 @@
# Copy h5 files to binary dir # Copy h5 files to binary dir
file(GLOB all_h5_files *.h5) file(GLOB_RECURSE all_h5_ref_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.ref.h5)
file(COPY ${all_h5_files} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) foreach(file ${all_h5_ref_files})
configure_file(${file} ${file} COPYONLY)
set(all_tests Toto chain)
# Nasty Workaround for Mac Os Homebrew Python to find the proper Sanitizer Compatible Python Executable
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND (ASAN OR UBSAN))
execute_process(COMMAND bash "-c" "readlink -f $(which python) | xargs dirname" OUTPUT_VARIABLE PYTHON_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE)
set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}/../Resources/Python.app/Contents/MacOS/Python")
if(NOT EXISTS ${PYTHON_EXECUTABLE})
message(FATAL_ERROR "Could not find the proper Python executable for MacOs")
endif()
else()
set(PYTHON_EXECUTABLE python)
endif()
message(STATUS "Python Executable: ${PYTHON_EXECUTABLE}")
foreach(t ${all_tests})
add_test(NAME ${t} COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${t}.py)
endforeach() endforeach()
# Set the PythonPath # List of all tests
set_property(TEST ${all_tests} PROPERTY ENVIRONMENT PYTHONPATH=${CMAKE_BINARY_DIR}/python:$ENV{PYTHONPATH}) set(all_tests Toto chain)
# === Preload Sanitizer Libraries === foreach(test ${all_tests})
get_filename_component(test_name ${test} NAME_WE)
# If ASAN=ON use minimal runtime of UBSAN if it exists get_filename_component(test_dir ${test} DIRECTORY)
if(ASAN AND UBSAN_MINIMAL_RT_LIBRARY) add_test(NAME ${test_name} COMMAND ${TRIQS_PYTHON_INTERPRETER} ${CMAKE_CURRENT_SOURCE_DIR}/${test_dir}/${test_name}.py WORKING_DIRECTORY test/python/${test_dir})
set(UBSAN_RT_LIBRARY ${UBSAN_MINIMAL_RT_LIBRARY}) set_property(TEST ${test_name} APPEND PROPERTY ENVIRONMENT PYTHONPATH=${CMAKE_BINARY_DIR}/python:$ENV{PYTHONPATH} ${SANITIZER_RT_PRELOAD})
endif() endforeach()
# Set the Sanitizer Library Preloads and UBSan Options for all tests
if(ASAN OR UBSAN)
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}>
DYLD_INSERT_LIBRARIES=$<$<BOOL:${ASAN}>:${ASAN_RT_LIBRARY}>:$<$<BOOL:${UBSAN}>:${UBSAN_RT_LIBRARY}>
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1:$ENV{UBSAN_OPTIONS}
)
endif()