Commit 24c01100 authored by David Frank's avatar David Frank
Browse files

#16 added new Cmake-Option to configure JUnit Reporter, added JUnit reporter...

#16 added new Cmake-Option to configure JUnit Reporter, added JUnit reporter to tests, moved Test macro to one place (DRY)
parent 7c8a9b5a
cmake_minimum_required(VERSION 3.9)
project(elsa VERSION 0.5
DESCRIPTION "elsa recon toolbox"
LANGUAGES CXX)
......@@ -6,12 +7,25 @@ project(elsa VERSION 0.5
# ------------ elsa options ------------
# ------------
option(ELSA_TESTING "Enable the unit tests of elsa" ON)
option(GIT_SUBMODULE "Check submodules during build" ON)
option(BUILD_ELSA_PROJECTORS_CUDA "Attempts to build CUDA projectors if set" ON)
# detect if elsa is being bundled, disable some options based on this
if (NOT DEFINED ELSA_MASTER_PROJECT)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(ELSA_MASTER_PROJECT ON)
else()
set(ELSA_MASTER_PROJECT OFF)
endif()
endif ()
option(ELSA_TESTING "Enable the unit tests of elsa" ${ELSA_MASTER_PROJECT})
option(ELSA_INSTALL "Generate the install target" ${ELSA_MASTER_PROJECT})
option(GIT_SUBMODULE "Check submodules during build" ${ELSA_MASTER_PROJECT})
option(ELSA_BUILD_EXAMPLES "Build examples" ${ELSA_MASTER_PROJECT})
option(ELSA_COVERAGE "Enables test coverage reporting" OFF)
option(ELSA_BUILD_CUDA_PROJECTORS "Attempts to build CUDA projectors if set" ON)
option(ELSA_BUILD_WITH_MORE_WARNINGS "Reduce noise of warnings, but make chaning fast and easy" OFF)
option(ELSA_BUILD_WITH_SANITIZERS "Build with Sanitizers. Pass ELSA_SANITIZE_THREAD or ELSA_SANITIZE_ADDRESS" ON)
option(ELSA_CREATE_JUNIT_REPORTS "Create JUnit style reports while running tests" OFF)
# ------------ general setup -----------
# ------------
......@@ -26,37 +40,48 @@ include(SetDefaultBuildType)
# set where to install the exports/targets
set(INSTALL_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/cmake)
# ------------ dependencies ------------
# ------------
# include the git submodule update
include(UpdateGitSubmodules)
# include the InstallElsaModule function
include(InstallElsaModule)
# only populate the dependencies, iff it's a standalone project!
if(ELSA_MASTER_PROJECT)
# include the git submodule update
include(UpdateGitSubmodules)
# setup the Eigen3 library
find_package(Eigen3 3.3 NO_MODULE QUIET) # first try if there is an installed version
if(NOT EIGEN3_INCLUDE_DIR) # if not found, try our submodule
set(EIGEN3_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/thirdparty/eigen3")
message(STATUS "Using eigen3 submodule at ${EIGEN3_INCLUDE_DIR}")
# find Eigen Library
# if you're not using the submodules use set(EIGEN3_INCLUDE_DIR path/to/Eigen3) to point to the Eigen3 directory
find_package(Eigen3 3.3 REQUIRED)
message(STATUS "Using eigen3 submodule at ${EIGEN3_INCLUDE_DIR}")
# find spdlog Library
# if you're not using the submodules use set(Spdlog_INCLUDE_DIR path/to/spdlog) to point to the spdlog directory
find_package(Spdlog REQUIRED)
message(STATUS "Using spdlog submodule at ${Spdlog_INCLUDE_DIR}")
else()
message(STATUS " No dependencies added for elsa, as it's a subproject")
endif()
# include the In stallElsaModule function
include(InstallElsaModule)
# ------------ setup testing -----------
# ------------
# reset ELSA_TESTING to only be active, if it's a standlone project
if(NOT ELSA_MASTER_PROJECT)
set(ELSA_TESTING OFF)
endif(NOT ELSA_MASTER_PROJECT)
if(ELSA_TESTING)
message(STATUS "elsa testing is enabled")
enable_testing()
add_subdirectory(thirdparty/Catch2)
# add the CMake modules for automatic test discovery
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/thirdparty/Catch2/contrib" ${CMAKE_MODULE_PATH})
else(ELSA_TESTING)
message(STATUS "elsa testing is disabled")
message(STATUS " elsa testing is disabled")
endif(ELSA_TESTING)
......@@ -83,38 +108,41 @@ add_subdirectory(elsa)
# the documentation
add_subdirectory(docs EXCLUDE_FROM_ALL)
# the examples
add_subdirectory(examples EXCLUDE_FROM_ALL)
if(ELSA_BUILD_EXAMPLES)
# the examples
add_subdirectory(examples EXCLUDE_FROM_ALL)
endif(ELSA_BUILD_EXAMPLES)
# ------------ setup installation ------
# ------------
# set up the target/library for make install
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
if(ELSA_INSTALL)
# set up the target/library for make install
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# setup the ElsaConfig*.cmake files
write_basic_package_version_file(
# setup the ElsaConfig*.cmake files
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/elsa/elsaConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(
)
configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/elsaConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/elsa/elsaConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIG_DIR}
)
)
# install the config files
install(
# install the config files
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/elsa/elsaConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/elsa/elsaConfigVersion.cmake
DESTINATION ${INSTALL_CONFIG_DIR}
)
)
# this puts the local build tree into the user package repository, but not the installed version...
# ...but we rely on the paths in the installed version. sigh. commented out for now.
#export(PACKAGE elsa)
# this puts the local build tree into the user package repository, but not the installed version...
# ...but we rely on the paths in the installed version. sigh. commented out for now.
#export(PACKAGE elsa)
endif(ELSA_INSTALL)
......@@ -6,6 +6,23 @@ macro(registerComponent name)
set(ELSA_REGISTERED_COMPONENTS "${ELSA_REGISTERED_COMPONENTS};${name}" PARENT_SCOPE)
endmacro()
# macro for the unit tests
MACRO (ELSA_TEST NAME)
# create the test executable
add_executable(test_${NAME} test_${NAME}.cpp test_main.cpp)
# add catch and the corresponding elsa library
target_link_libraries(test_${NAME} PRIVATE Catch2::Catch2 ${ELSA_MODULE_TARGET_NAME})
# enable C++17
target_compile_features(test_${NAME} PUBLIC cxx_std_17)
# if we use JUnit reporter handle arguments
if(${ELSA_CREATE_JUNIT_REPORTS})
set(ELSA_JUNIT_ARGUMENTS "-r junit" "-o test_${NAME}.xml")
endif(${ELSA_CREATE_JUNIT_REPORTS})
# let Catch discover and register all the test cases
catch_discover_tests(test_${NAME} TEST_SPEC ${ELSA_JUNIT_ARGUMENTS})
ENDMACRO (ELSA_TEST)
# add the elsa modules
add_subdirectory(core)
......@@ -16,11 +33,33 @@ add_subdirectory(functionals)
add_subdirectory(problems)
add_subdirectory(solvers)
add_subdirectory(projectors)
if(BUILD_ELSA_PROJECTORS_CUDA)
if(ELSA_BUILD_CUDA_PROJECTORS)
add_subdirectory(projectors_cuda)
endif(BUILD_ELSA_PROJECTORS_CUDA)
endif(ELSA_BUILD_CUDA_PROJECTORS)
add_subdirectory(generators)
#---------------------------------------------------------------------------------------
# Turn on compiler warnings and sanitizers for all components on, if wanted
#---------------------------------------------------------------------------------------
if(${ELSA_MASTER_PROJECT})
foreach (_component ${ELSA_REGISTERED_COMPONENTS})
# add warnings if enabled
if(${ELSA_BUILD_WITH_MORE_WARNINGS})
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
target_compile_options( elsa_${_component} PUBLIC -Wall -Wextra -Wconversion -pedantic -Wfatal-errors)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options( elsa_${_component} PUBLIC /W3 /WX )
endif()
endif(${ELSA_BUILD_WITH_MORE_WARNINGS})
endforeach (_component ELSA_REGISTERED_COMPONENTS)
# add sanitizers if enabled
if(${ELSA_BUILD_WITH_SANITIZERS})
include(${PROJECT_SOURCE_DIR}/cmake/Sanitizers.cmake)
endif(${ELSA_BUILD_WITH_SANITIZERS})
endif(${ELSA_MASTER_PROJECT})
# propogate the variable to the parent scope
set(ELSA_REGISTERED_COMPONENTS "${ELSA_REGISTERED_COMPONENTS};" PARENT_SCOPE)
......@@ -4,19 +4,6 @@ cmake_minimum_required(VERSION 3.9)
include(CTest)
include(Catch)
# macro for the unit tests
MACRO (ELSA_TEST NAME)
# create the test executable
add_executable(test_${NAME} test_${NAME}.cpp test_main.cpp)
# add catch and the corresponding elsa library
target_link_libraries(test_${NAME} PRIVATE Catch2::Catch2 ${ELSA_MODULE_TARGET_NAME})
# enable C++17
target_compile_features(test_${NAME} PUBLIC cxx_std_17)
# let Catch discover and register all the test cases
catch_discover_tests(test_${NAME})
ENDMACRO (ELSA_TEST)
# the actual tests
ELSA_TEST(DataDescriptor)
ELSA_TEST(BlockDescriptor)
......
......@@ -4,19 +4,6 @@ cmake_minimum_required(VERSION 3.9)
include(CTest)
include(Catch)
# macro for the unit tests
MACRO (ELSA_TEST NAME)
# create the test executable
add_executable(test_${NAME} test_${NAME}.cpp test_main.cpp)
# add catch and the corresponding elsa library
target_link_libraries(test_${NAME} PRIVATE Catch2::Catch2 ${ELSA_MODULE_TARGET_NAME})
# enable C++17
target_compile_features(test_${NAME} PUBLIC cxx_std_17)
# let Catch discover and register all the test cases
catch_discover_tests(test_${NAME})
ENDMACRO (ELSA_TEST)
# the actual tests
ELSA_TEST(LinearResidual)
ELSA_TEST(L1Norm)
......
......@@ -4,19 +4,6 @@ cmake_minimum_required(VERSION 3.9)
include(CTest)
include(Catch)
# macro for the unit tests
MACRO (ELSA_TEST NAME)
# create the test executable
add_executable(test_${NAME} test_${NAME}.cpp test_main.cpp)
# add catch and the corresponding elsa library
target_link_libraries(test_${NAME} PRIVATE Catch2::Catch2 ${ELSA_MODULE_TARGET_NAME} elsa_io)
# enable C++17
target_compile_features(test_${NAME} PUBLIC cxx_std_17)
# let Catch discover and register all the test cases
catch_discover_tests(test_${NAME})
ENDMACRO (ELSA_TEST)
# the actual tests
ELSA_TEST(EllipseGenerator)
ELSA_TEST(PhantomGenerator)
......
......@@ -4,19 +4,6 @@ cmake_minimum_required(VERSION 3.9)
include(CTest)
include(Catch)
# macro for the unit tests
MACRO (ELSA_TEST NAME)
# create the test executable
add_executable(test_${NAME} test_${NAME}.cpp test_main.cpp)
# add catch and the corresponding elsa library
target_link_libraries(test_${NAME} PRIVATE Catch2::Catch2 ${ELSA_MODULE_TARGET_NAME})
# enable C++17
target_compile_features(test_${NAME} PUBLIC cxx_std_17)
# let Catch discover and register all the test cases
catch_discover_tests(test_${NAME})
ENDMACRO (ELSA_TEST)
# the actual tests
ELSA_TEST(ioUtils)
ELSA_TEST(EDFHandler)
......
......@@ -4,19 +4,6 @@ cmake_minimum_required(VERSION 3.9)
include(CTest)
include(Catch)
# macro for the unit tests
MACRO (ELSA_TEST NAME)
# create the test executable
add_executable(test_${NAME} test_${NAME}.cpp test_main.cpp)
# add catch and the corresponding elsa library
target_link_libraries(test_${NAME} PRIVATE Catch2::Catch2 ${ELSA_MODULE_TARGET_NAME})
# enable C++17
target_compile_features(test_${NAME} PUBLIC cxx_std_17)
# let Catch discover and register all the test cases
catch_discover_tests(test_${NAME})
ENDMACRO (ELSA_TEST)
# the actual tests
ELSA_TEST(Logger)
ELSA_TEST(LogGuard)
......
......@@ -4,19 +4,6 @@ cmake_minimum_required(VERSION 3.9)
include(CTest)
include(Catch)
# macro for the unit tests
MACRO (ELSA_TEST NAME)
# create the test executable
add_executable(test_${NAME} test_${NAME}.cpp test_main.cpp)
# add catch and the corresponding elsa library
target_link_libraries(test_${NAME} PRIVATE Catch2::Catch2 ${ELSA_MODULE_TARGET_NAME})
# enable C++17
target_compile_features(test_${NAME} PUBLIC cxx_std_17)
# let Catch discover and register all the test cases
catch_discover_tests(test_${NAME})
ENDMACRO (ELSA_TEST)
# the actual tests
ELSA_TEST(Identity)
ELSA_TEST(Scaling)
......
......@@ -4,19 +4,6 @@ cmake_minimum_required(VERSION 3.9)
include(CTest)
include(Catch)
# macro for the unit tests
MACRO (ELSA_TEST NAME)
# create the test executable
add_executable(test_${NAME} test_${NAME}.cpp test_main.cpp)
# add catch and the corresponding elsa library
target_link_libraries(test_${NAME} PRIVATE Catch2::Catch2 ${ELSA_MODULE_TARGET_NAME})
# enable C++17
target_compile_features(test_${NAME} PUBLIC cxx_std_17)
# let Catch discover and register all the test cases
catch_discover_tests(test_${NAME})
ENDMACRO (ELSA_TEST)
# the actual tests
ELSA_TEST(WLSProblem)
ELSA_TEST(RegularizationTerm)
......
......@@ -4,18 +4,6 @@ cmake_minimum_required(VERSION 3.9)
include(CTest)
include(Catch)
# macro for the unit tests
MACRO (ELSA_TEST NAME)
# create the test executable
add_executable(test_${NAME} test_${NAME}.cpp test_main.cpp)
# add catch and the corresponding elsa library
target_link_libraries(test_${NAME} PRIVATE Catch2::Catch2 ${ELSA_MODULE_TARGET_NAME})
# enable C++17
target_compile_features(test_${NAME} PUBLIC cxx_std_17)
# let Catch discover and register all the test cases
catch_discover_tests(test_${NAME})
ENDMACRO (ELSA_TEST)
# the actual tests
ELSA_TEST(Geometry)
......
......@@ -4,17 +4,5 @@ cmake_minimum_required(VERSION 3.9)
include(CTest)
include(Catch)
# macro for the unit tests
MACRO (ELSA_TEST NAME)
# create the test executable
add_executable(test_${NAME} test_${NAME}.cpp test_main.cpp)
# add catch and the corresponding elsa library
target_link_libraries(test_${NAME} PRIVATE Catch2::Catch2 ${ELSA_MODULE_TARGET_NAME})
# enable C++17
target_compile_features(test_${NAME} PUBLIC cxx_std_17)
# let Catch discover and register all the test cases
catch_discover_tests(test_${NAME})
ENDMACRO (ELSA_TEST)
ELSA_TEST(SiddonsMethodCUDA)
ELSA_TEST(JosephsMethodCUDA)
\ No newline at end of file
......@@ -4,18 +4,5 @@ cmake_minimum_required(VERSION 3.9)
include(CTest)
include(Catch)
# macro for the unit tests
MACRO (ELSA_TEST NAME)
# create the test executable
add_executable(test_${NAME} test_${NAME}.cpp test_main.cpp)
# add catch and the corresponding elsa library
target_link_libraries(test_${NAME} PRIVATE Catch2::Catch2 ${ELSA_MODULE_TARGET_NAME})
# enable C++17
target_compile_features(test_${NAME} PUBLIC cxx_std_17)
# let Catch discover and register all the test cases
catch_discover_tests(test_${NAME})
ENDMACRO (ELSA_TEST)
# the actual tests
ELSA_TEST(GradientDescent)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment