-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
51 lines (47 loc) · 2.44 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
cmake_minimum_required(VERSION 3.1)
project(cadmium)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
add_library(cadmium INTERFACE)
target_include_directories(cadmium INTERFACE include/ json/include)
FILE(GLOB Examples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} example/*/main_*.cpp)
foreach(exampleSrc ${Examples})
get_filename_component(exampleName ${exampleSrc} NAME_WE)
get_filename_component(dirname ${exampleSrc} DIRECTORY)
file(GLOB directorySrc CONFIGURE_DEPENDS "${dirname}/src/*.cpp")
add_executable(${exampleName} ${exampleSrc} ${directorySrc})
target_include_directories(${exampleName} PUBLIC "${dirname}/include")
target_link_libraries(${exampleName} cadmium)
endforeach(exampleSrc)
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
FILE(GLOB Examples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} example/*/parallel_main_*.cpp)
foreach(exampleSrc ${Examples})
get_filename_component(exampleName ${exampleSrc} NAME_WE)
get_filename_component(dirname ${exampleSrc} DIRECTORY)
file(GLOB directorySrc CONFIGURE_DEPENDS "${dirname}/src/*.cpp")
add_executable(${exampleName} ${exampleSrc} ${directorySrc})
target_include_directories(${exampleName} PUBLIC "${dirname}/include")
target_link_libraries(${exampleName} PUBLIC cadmium OpenMP::OpenMP_CXX)
endforeach(exampleSrc)
else()
message(STATUS "OpenMP not found. You won't be able to use parallel simulation.")
endif()
find_package(Boost COMPONENTS system filesystem unit_test_framework)
if(Boost_FOUND)
add_definitions(-DBOOST_TEST_DYN_LINK)
enable_testing()
FILE(GLOB Tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} test/*/test_*.cpp)
foreach(testSrc ${Tests})
get_filename_component(testName ${testSrc} NAME_WE)
string(REGEX MATCH "[a-z]+$" useCase ${testName})
file(GLOB directorySrc CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/example/${useCase}/src/*.cpp")
add_executable(${testName} ${testSrc} ${directorySrc})
target_include_directories(${testName} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/example/${useCase}/include")
target_link_libraries(${testName} cadmium ${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
add_test(NAME ${testName} COMMAND ${testName})
endforeach(testSrc)
else()
message(STATUS "Boost not found. You won't be able to run nor develop tests for Cadmium.")
endif()