CMakeLists.txt 1.76 KB
Newer Older
1
project(tests)
2

Michaël Roynard's avatar
Michaël Roynard committed
3
find_package(Threads REQUIRED)
4
find_package(GTest 1.10 REQUIRED)
5
find_package(TBB REQUIRED tbb)
Michaël Roynard's avatar
Michaël Roynard committed
6

Edwin Carlinet's avatar
Edwin Carlinet committed
7
# Register an executable test: add_core_test(Exe Source1 [Source2...])
Edwin Carlinet's avatar
Edwin Carlinet committed
8
# Executable: The name of the executable (default: ${Prefix}${TestName})
Edwin Carlinet's avatar
Edwin Carlinet committed
9
# Sources: The source files to compile (default: ${Prefix}${TestName}.cpp)
10
11
12
13
14
function(add_core_test Executable)
  set(core_test_SOURCES ${ARGN})
  set(core_test_NAME ${Executable})

  add_executable(${core_test_NAME} ${core_test_SOURCES})
15
  target_link_libraries(${core_test_NAME} PRIVATE Fixtures::ImagePath Fixtures::ImageCompare Pylene::Core Pylene::IO-freeimage GTest::GTest)
16
17
  set_target_properties(${core_test_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)

18
19
20
21
22
  add_test(NAME ${core_test_NAME} COMMAND ${core_test_NAME} --gtest_output=xml:${core_test_NAME}.xml WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
  set_tests_properties(${core_test_NAME} PROPERTIES LABELS UnitTests)
  add_dependencies(build-tests ${core_test_NAME})
endfunction(add_core_test)

23
24
25
26
27
28
29
30
# Windows required DLLs to be located near tests (suppose TBB is installed with conan)
# (Some libraries cannot be static (e.g. TBB)
if (WIN32 AND EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
  set(TBB_DLL "${CONAN_BIN_DIRS_TBB}/tbb$<$<CONFIG:DEBUG>:_debug>.dll")
  add_custom_target(copy-dlls-in-test-dir
    COMMAND ${CMAKE_COMMAND} -E copy_if_different "${TBB_DLL}" "${CMAKE_BINARY_DIR}/tests"
    )
  add_dependencies(build-tests copy-dlls-in-test-dir)
31
endif()
32
33

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
34
add_subdirectory(accu)
35
add_subdirectory(core)
36
37
add_subdirectory(io)
add_subdirectory(colors)
Michaël Roynard's avatar
Michaël Roynard committed
38
add_subdirectory(morpho)
Michaël Roynard's avatar
Michaël Roynard committed
39
add_subdirectory(labeling)
40
add_subdirectory(contrib)
Edwin Carlinet's avatar
Edwin Carlinet committed
41
add_subdirectory(bp)
42
if (PYLENE_BUILD_PYTHON)
43
44
  add_subdirectory(python)
endif()