-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
81 lines (61 loc) · 2.7 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project(TOctreeLookup)
set(CMAKE_CXX_STANDARD 17)
if(DEFINED ENV{ROOTSYS})
message("Found ROOTSYS at $ENV{ROOTSYS}")
else()
message("ROOTSYS not found. Searching in /cern.")
message(" => This will match the first ROOT install it finds, which might not be what you want!")
list(APPEND CMAKE_PREFIX_PATH /cern)
endif()
find_package(ROOT 6.16 CONFIG REQUIRED)
# ROOT's CMake utilities
include(${ROOT_USE_FILE})
# Include directories
include_directories(${ROOT_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
# Set output paths for libraries and executables
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_INSTALL_LIBDIR ${CMAKE_BINARY_DIR}/lib)
MESSAGE("-- INCLUDING CUSTOM CMAKE TOOLS")
# import colors and dictionary builder
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/colors.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/root_tools.cmake)
MESSAGE("-- DONE INCLUDING CUSTOM CMAKE TOOLS")
# # Files for dictionary definition
# set(LINKDEF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/include/LinkDef.h)
# set(DICT_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/TOctreeLookup.h)
set(ALL_CLASSES
TOctreeLookup)
set(DICT_CLASSES
TOctreeLookup)
string(REGEX REPLACE "([^;]+)" "src/\\1.cpp" DICT_SOURCES "${DICT_CLASSES}")
string(REGEX REPLACE "([^;]+)" "\\1.h" DICT_HEADERS "${DICT_CLASSES}")
string(REGEX REPLACE "([^;]+)" "src/\\1.cpp" ALL_SOURCES "${ALL_CLASSES}")
string(REGEX REPLACE "([^;]+)" "\\1.h" ALL_HEADERS "${ALL_CLASSES}")
# Generate the dictionary
root_dictionary_builder(TARGET_NAME TOctreeLookupDictGenerated
CLASS_LIST ${DICT_CLASSES}
HEADER_LIST ${DICT_HEADERS})
# create library
set(LIB_SOURCES src/TOctreeLookup.cpp)
add_library(TOctreeLookup SHARED ${LIB_SOURCES} TOctreeLookupDictGenerated)
target_include_directories(TOctreeLookup PUBLIC include)
target_link_libraries(TOctreeLookup ROOT::Core ROOT::MathCore ROOT::Matrix ROOT::Physics)
# install library
install(TARGETS TOctreeLookup DESTINATION lib)
install(FILES ${DICT_HEADER_FILES} ${LINKDEF_FILE} DESTINATION ${CMAKE_BINARY_DIR}/include)
# install(FILES ${DICT_HEADER_FILES} DESTINATION ${CMAKE_BINARY_DIR}/include)
# testing
function(add_test_executable target)
add_executable(${target} test/${target}.cpp)
target_link_libraries(${target} TOctreeLookup)
set_target_properties(${target} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test)
add_test(NAME ${target} COMMAND ${target})
endfunction()
enable_testing()
# hello world
add_test_executable(hello_world)
add_test_executable(construct_tree)