3
0
mirror of https://github.com/triqs/dft_tools synced 2024-06-25 06:32:22 +02:00

Further cleanining, switching to static library

-Disable LINTing in test macros with comment // NOLINT
-Enable static analyzers for c++ tests
-Switch app4triqs_c to static library
 Dynamic was pickung up previously installed libapp4triqs_c.so in tests
 Also there is no need to be dynamic for applications
-Fix previous change in HeaderFilterRegex:
 'app4triqs/c++' was blocking all headers for clang-tidy checks.
 'app4triqs' works well, but we cannot install any other headers into
 app4triqs folder structure.
 We thus had to create INSTALL_DIR in travis.yml
This commit is contained in:
Nils Wentzell 2018-03-26 00:31:39 +02:00
parent e3c4366d54
commit f65e5bfbad
7 changed files with 40 additions and 44 deletions

View File

@ -1,2 +1,2 @@
Checks: '-*,modernize-*,cppcoreguidelines-*'
HeaderFilterRegex: 'c++/app4triqs'
HeaderFilterRegex: 'app4triqs'

View File

@ -21,25 +21,24 @@ before_install:
install: true
script:
- export INSTALL_DIR=$HOME/root_install # We should install outside the repository
# ===== Set up Cpp2Py
- git clone https://github.com/triqs/cpp2py
- mkdir cpp2py/build && cd cpp2py/build
- git checkout master
- cmake .. -DCMAKE_CXX_COMPILER=/usr/bin/${CXX} -DPYTHON_INTERPRETER=/usr/bin/python -DCMAKE_INSTALL_PREFIX=$TRAVIS_BUILD_DIR/root_install
- cmake .. -DCMAKE_CXX_COMPILER=/usr/bin/${CXX} -DPYTHON_INTERPRETER=/usr/bin/python -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR
- make -j8 install
- cd $TRAVIS_BUILD_DIR
- source root_install/share/cpp2pyvars.sh
- source $INSTALL_DIR/share/cpp2pyvars.sh
# ===== Set up TRIQS
- cd $TRAVIS_BUILD_DIR
- git clone https://github.com/TRIQS/triqs --branch unstable
- mkdir triqs/build && cd triqs/build
- git checkout unstable
- cmake .. -DCMAKE_CXX_COMPILER=/usr/bin/${CXX} -DBuild_Tests=OFF -DCMAKE_INSTALL_PREFIX=$TRAVIS_BUILD_DIR/root_install -DCMAKE_BUILD_TYPE=Debug
- cmake .. -DCMAKE_CXX_COMPILER=/usr/bin/${CXX} -DBuild_Tests=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR
- make -j8 install
- cd $TRAVIS_BUILD_DIR
- source root_install/share/triqsvars.sh
- source $INSTALL_DIR/share/triqsvars.sh
# ===== Set up CTINT and Test with Sanitizer Checks
- cd $TRAVIS_BUILD_DIR
- mkdir build && cd build
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=/usr/bin/${CXX} -DASAN=ON -DUBSAN=ON
- cmake .. -DCMAKE_CXX_COMPILER=/usr/bin/${CXX} -DASAN=ON -DUBSAN=ON
- 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_OPTIONS=symbolize=1:detect_leaks=0

View File

@ -11,11 +11,11 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
message( STATUS "-------- BUILD-TYPE: ${CMAKE_BUILD_TYPE} --------")
# Use shared libraries
set(BUILD_SHARED_LIBS ON)
# Build static libraries
set(BUILD_SHARED_LIBS OFF)
# Enable compiler warnings for the whole project
add_definitions(-Wall)
add_definitions(-Wall -fPIC)
# Load Dependencies
find_package(TRIQS ${APP4TRIQS_VERSION} EXACT REQUIRED)
@ -32,9 +32,6 @@ 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 all compiled executables
triqs_set_rpath_for_all_targets()
# Build and install the app4triqs library
add_subdirectory(c++/app4triqs)

View File

@ -1,10 +1,12 @@
file(GLOB_RECURSE sources *.cpp *.hpp)
file(GLOB_RECURSE sources *.cpp)
add_library(app4triqs_c ${sources})
# Link against triqs and use headers with SYSTEM flag for better warning messages
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_options(app4triqs_c PUBLIC -std=c++17 -fPIC)
target_include_directories(app4triqs_c PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/c++>)
target_compile_definitions(app4triqs_c PRIVATE
APP4TRIQS_GIT_HASH=${APP4TRIQS_GIT_HASH}
TRIQS_GIT_HASH=${TRIQS_GIT_HASH}
@ -36,7 +38,6 @@ 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
@ -44,8 +45,7 @@ if(CPPCHECK_EXECUTABLE)
--verbose
--quiet
${sources}
COMMAND echo "------------------------\n"
)
)
else()
message(STATUS "cppcheck not found in $PATH. Please consider installing cppcheck for additional checks!")
endif()

View File

@ -9,20 +9,20 @@ foreach(t ${all_tests})
target_link_libraries(${t} app4triqs_c gtest)
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()
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()

View File

@ -3,16 +3,16 @@
using namespace app4triqs;
TEST(Toto, Add) {
TEST(Toto, Add) { // NOLINT
toto a(0);
toto b(2);
auto c = a + b;
EXPECT_EQ(c, b);
EXPECT_EQ(c, b); // NOLINT
}
TEST(Toto, H5) {
TEST(Toto, H5) { // NOLINT
toto a(0);
{ // Local scope for file
@ -26,7 +26,7 @@ TEST(Toto, H5) {
h5_read(f, "a", a2);
}
EXPECT_EQ(a, a2);
EXPECT_EQ(a, a2); // NOLINT
}
MAKE_MAIN;
MAKE_MAIN; // NOLINT

View File

@ -20,7 +20,7 @@ class test_toto(unittest.TestCase):
def test_h5(self):
a=Toto(0)
with HDFArchive("f.h5",'a') as A:
with HDFArchive("f.h5",'w') as A:
A["a"] = a
with HDFArchive("f.h5",'r') as A:
a_read = A["a"]