-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
99 lines (81 loc) · 2.38 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
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(
cluster
VERSION 0.0.1
LANGUAGES CXX
)
# include potential build options
include(options.cmake)
# add cmake modules to the include path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
add_library(
${PROJECT_NAME}
include/cluster/distance.hpp
include/cluster/pam.hpp
src/distance.cpp
src/pam.cpp
)
target_include_directories(
${PROJECT_NAME}
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
)
target_link_libraries(
${PROJECT_NAME}
PUBLIC Eigen3::Eigen
)
if(NOT CMAKE_DEBUG_POSTFIX)
set(CMAKE_DEBUG_POSTFIX "-debug")
endif()
set_target_properties(
${PROJECT_NAME} PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON
DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
)
if(CLUSTER_BUILD_EXAMPLES)
message(STATUS "cluster: Build examples option enabled.")
add_subdirectory(examples)
endif()
# create cmake package
set(CLUSTER_PACKAGE_DESTINATION "lib/cmake/${PROJECT_NAME}")
include(CMakePackageConfigHelpers)
# files to be generated
set(CLUSTER_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
set(CLUSTER_VERSION_CONFIG "${CLUSTER_GENERATED_DIR}/${PROJECT_NAME}-config-version.cmake")
set(CLUSTER_PROJECT_CONFIG "${CLUSTER_GENERATED_DIR}/${PROJECT_NAME}-config.cmake")
set(CLUSTER_EXPORTED_TARGET "${PROJECT_NAME}-target")
# use the version defined by the project command we issued at the top
write_basic_package_version_file(
"${CLUSTER_VERSION_CONFIG}" COMPATIBILITY SameMajorVersion
)
configure_package_config_file(
"cmake/ClusterConfig.cmake.in"
"${CLUSTER_PROJECT_CONFIG}"
INSTALL_DESTINATION "${CLUSTER_PACKAGE_DESTINATION}"
)
# install the library binary and export its properties to a .cmake file
install(
TARGETS ${PROJECT_NAME}
EXPORT "${CLUSTER_EXPORTED_TARGET}" # CMakeFiles/Export/
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
# install the library headers
install(
DIRECTORY include/cluster
DESTINATION include
)
# install the cluster-config.cmake file and its version info
install(
FILES "${CLUSTER_PROJECT_CONFIG}" "${CLUSTER_VERSION_CONFIG}"
DESTINATION "${CLUSTER_PACKAGE_DESTINATION}"
)
# install the cluster-target* information
install(
EXPORT "${CLUSTER_EXPORTED_TARGET}"
NAMESPACE "cluster::"
DESTINATION "${CLUSTER_PACKAGE_DESTINATION}"
)