-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
112 lines (91 loc) · 3.3 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
cmake_minimum_required(VERSION 3.22)
project(genogrove VERSION 0.1.0)
set(CMAKE_CXX_STANDARD 20)
configure_file(include/genogrove/Config.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/include/genogrove/Config.hpp)
##### genogrove library #####
#file(GLOB SOURCES "src/*.cpp")
#
##add_library(genogrove ${SOURCES})
##target_include_directories(genogrove PUBLIC
## $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
## $<INSTALL_INTERFACE:include>
##)
#add_executable(genogrove ${SOURCES})
#target_include_directories(genogrove PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
##### Add GenoGrove as a library #####
file(GLOB SOURCES "src/*.cpp")
add_library(genogrove ${SOURCES})
target_include_directories(genogrove PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
include(GenerateExportHeader)
generate_export_header(genogrove)
set_target_properties(genogrove PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
# install targets
install(TARGETS genogrove
EXPORT genogrove-targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
install(FILES include/genogrove/all.hpp DESTINATION include/genogrove)
install(DIRECTORY include/genogrove
DESTINATION include/genogrove
FILES_MATCHING PATTERN "*.hpp"
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/genogrove_export.h DESTINATION include/genogrove)
export(EXPORT genogrove-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/genogrove-targets.cmake"
NAMESPACE genogrove::
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/genogrove-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
# create Config.cmake file
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/genogrove-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/genogrove-config.cmake"
INSTALL_DESTINATION lib/cmake/genogrove
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/genogrove-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/genogrove-config-version.cmake"
DESTINATION lib/cmake/genogrove
)
# generate and install cmake config files
install(EXPORT genogrove-targets
FILE genogrove-targets.cmake
NAMESPACE genogrove::
DESTINATION lib/cmake/genogrove
)
##### Tests #####
option(TESTS "building unit tests" OFF)
if(TESTS)
message(STATUS "Building unit tests")
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.15.0
)
FetchContent_MakeAvailable(googletest)
enable_testing() # enable the testing framework
include(GoogleTest)
file(GLOB SOURCES "src/*.cpp")
file(GLOB TEST_SOURCES "tests/*.cpp")
add_executable(IBPTree_Test ${SOURCES} ${TEST_SOURCES})
target_include_directories(IBPTree_Test PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(IBPTree_Test GTest::gtest_main)
gtest_discover_tests(IBPTree_Test)
else()
message(STATUS "Building unit tests disabled")
endif()