Commit 637591a3 authored by Laurent Belcour's avatar Laurent Belcour

[CMake] Added all the static unit tests.

parent bf3b81fd
......@@ -2,20 +2,25 @@ cmake_minimum_required (VERSION 3.2)
project (alta CXX)
# Find required packages
find_package(Eigen3 REQUIRED)
find_package(Eigen3)
find_package(OpenMP)
add_definitions(-DALTA_PLUGIN_DIRECTORY="/usr/lib/alta_plugins")
# Add core and library include files
include_directories("external/build" "sources" ${EIGEN3_INCLUDE_DIR})
include_directories("external")
include_directories("external" "external/Catch/include")
# TODO Look for Eigen library there (do not rely on find_package)
# Update compilation option to include OpenMP if present
if(OPENMP_FOUND)
set (CMAKE_CXX_FLAGS ${OpenMP_CXX_FLAGS})
endif(OPENMP_FOUND)
# TODO Look for catch library
set(CATCH_FOUND TRUE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
#############################
......@@ -34,6 +39,14 @@ function(alta_add_soft name sources)
target_compile_features(${name} PRIVATE cxx_range_for)
endfunction(alta_add_soft)
function(alta_add_test name sources)
add_executable(${name} sources/tests/${sources})
target_link_libraries(${name} core)
target_compile_features(${name} PRIVATE cxx_range_for)
add_test(NAME ${name} COMMAND ${CMAKE_BINARY_DIR}/tests/${name})
set_tests_properties(${name} PROPERTIES ENVIRONMENT "TEST_DATA_DIRECTORY=${CMAKE_SOURCE_DIR}/sources/tests")
endfunction(alta_add_test)
#############################
# ALTA core #
......@@ -78,26 +91,33 @@ alta_add_plugin(nonlinear_fitter_eigen nonlinear_fitter_eigen/fitter.cpp)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/softs)
add_executable(brdf2data sources/softs/brdf2data/main.cpp)
target_link_libraries(brdf2data core)
target_compile_features(brdf2data PRIVATE cxx_range_for)
alta_add_soft(data2data data2data/main.cpp)
alta_add_soft(data2brdf data2brdf/main.cpp)
alta_add_soft(brdf2data brdf2data/main.cpp)
alta_add_soft(data2data data2data/main.cpp)
alta_add_soft(data2brdf data2brdf/main.cpp)
alta_add_soft(data2stats data2stats/data2stats.cpp)
#############################
# Tests #
#############################
enable_testing()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
include_directories("sources/tests")
add_executable(test_data_io sources/tests/core/data-io.cpp)
target_link_libraries(test_data_io core)
target_compile_features(test_data_io PRIVATE cxx_range_for)
enable_testing()
add_test(data_io test_data_io)
set_tests_properties(data_io PROPERTIES ENVIRONMENT "TEST_DATA_DIRECTORY=${CMAKE_SOURCE_DIR}/sources/tests")
alta_add_test(test_data_io core/data-io.cpp)
alta_add_test(half-test-1 core/half-test-1.cpp)
alta_add_test(half-test-2 core/half-test-2.cpp)
alta_add_test(half-test-3 core/half-test-3.cpp)
alta_add_test(half-test-4 core/half-test-4.cpp)
alta_add_test(nonlinear-fit core/nonlinear-fit.cpp)
alta_add_test(params-test-1 core/params-test-1.cpp)
alta_add_test(params-test-2 core/params-test-2.cpp)
if(CPPQUICKCHECK_FOUND)
alta_add_test(params-qc-1 core/params-qc-1.cpp)
endif()
if(CATCH_FOUND)
alta_add_test(conversion-catch-1 core/conversion-catch-1.cpp )
endif()
Markdown is supported
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