forked from BCCF-UBCO-AD/Orthanc-TMI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
55 lines (47 loc) · 1.83 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
52
53
54
55
cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_STANDARD 20)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options("-fsanitize=address,undefined")
add_link_options("-fsanitize=address,undefined")
endif()
set(BSL ${BUILD_SHARED_LIBS})
# project variables
project(Orthanc-TMI)
set(PROJECT_DIR ${CMAKE_CURRENT_LIST_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
# target names
set(PLUGIN_TARGET data-anonymizer)
set(TEST_TARGET all-tests)
# dependencies
file(GLOB_RECURSE PLUGIN_SOURCES LIST_DIRECTORIES false src/*)
file(GLOB_RECURSE TEST_SOURCES LIST_DIRECTORIES false tests/*)
list(FILTER TEST_SOURCES EXCLUDE REGEX .*main.cpp)
message("Plugin sources: ${PLUGIN_SOURCES}")
message("Common test sources: ${TEST_SOURCES}")
add_subdirectory(extern/googletest EXCLUDE_FROM_ALL)
set(BUILD_SHARED_LIBS ON)
add_subdirectory(extern/libpqxx EXCLUDE_FROM_ALL)
set(BUILD_SHARED_LIBS ${BSL})
# include directories
include_directories(include)
include_directories(include/dicom)
include_directories(include/data)
include_directories(include/plugin)
include_directories(include/functions)
include_directories(extern/nlohmann-json/single_include/)
# test targets
add_executable(${TEST_TARGET} tests/main.cpp ${TEST_SOURCES} ${PLUGIN_SOURCES})
target_link_libraries(${TEST_TARGET} PUBLIC gtest pqxx)
add_test(NAME ${TEST_TARGET} COMMAND ${TEST_TARGET})
# plugin target
set(CMAKE_SHARED_LIBRARY_PREFIX_CXX "")
add_library(${PLUGIN_TARGET} SHARED ${PLUGIN_SOURCES})
target_link_libraries(${PLUGIN_TARGET} PUBLIC pqxx)
add_custom_command(
TARGET ${PLUGIN_TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_BINARY_DIR}/bin/${PLUGIN_TARGET}.so
${PROJECT_DIR}/docker/orthanc/plugins/${PLUGIN_TARGET}.so)
install(TARGETS ${PLUGIN_TARGET}
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX})