forked from biovault/HDILib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
99 lines (81 loc) · 3.48 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.21)
set(USE_AVX ON CACHE BOOL "Use AVX instructions sets if available")
set(USE_OPENMP ON CACHE BOOL "Use OpenMP - by default ON")
set(INSTALL_HDILibSlim ON CACHE BOOL "Whether to install the HDILibSlim")
set(PROJECT_HDILibSlim "HDILibSlim")
PROJECT(${PROJECT_HDILibSlim} C CXX)
set(HDILibSlim_VERSION "undefined" CACHE STRING "HDILibSlim Library version")
# Disallow in-source builds.
# Build in sub dir e.g. source/build* is still allowed!
if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}" AND NOT $ENV{CI})
message(FATAL_ERROR "In-source builds are not allowed!\n"
"Make sure to remove CMakeCache.txt and CMakeFiles/ "
"from the source directory!")
endif()
# If the CMAKE_INSTALL_PREFIX has not been set by the user, set it to the build folder
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
message(STATUS "Default CMAKE_INSTALL_PREFIX detected. Setting to build directory.")
set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "Default install path" FORCE )
else()
message(STATUS "Custom CMAKE_INSTALL_PREFIX detected. Leaving it untouched.")
endif()
if (CMAKE_GENERATOR STREQUAL Xcode)
add_definitions(-DGL_SILENCE_DEPRECATION)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version")
endif()
message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
# CMake Options
# Set the directory where CMake include files are to be found
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# cmake utils
include(CMakeCommon)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W2 /permissive- /Zc:__cplusplus")
endif()
# Dependencies
find_package(OpenMP)
find_package(Eigen3 3.4 CONFIG REQUIRED NO_MODULE)
if(OPENMP_FOUND)
message (STATUS "OpenMP found ${OpenMP_CXX_LIB_NAMES}")
endif()
# add projects
add_subdirectory (hdi/utils) # PROJECT_UTILS
add_subdirectory (hdi/data) # PROJECT_DATA
add_subdirectory (hdi/dimensionality_reduction) # PROJECT_DR
# build order
add_dependencies(hdidata hdiutils)
add_dependencies(hdidimensionalityreduction hdiutils)
add_dependencies(hdidimensionalityreduction hdidata)
if(INSTALL_HDILibSlim)
# NOTE CMake installs are defined in the sub-projects.
# ***Create a HdpsCore package to support the find_package command**
# Helper macro for packaging
include(CMakePackageConfigHelpers)
# Generate the version file for use with find_package
set(hdilibslim_package_version "${HDILibSlim_VERSION}")
configure_file(${PROJECT_SOURCE_DIR}/cmake/ConfigVersion.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/HDILibSlimConfigVersion.cmake" @ONLY)
#write_basic_package_version_file(
# "${CMAKE_CURRENT_BINARY_DIR}/HDILibSlimConfigVersion.cmake"
# VERSION "${HDILibSlim_VERSION}"
# # When the hdps core is stable compatibility can
# # change to AnyNewerVersion or SameMajorVersion
# COMPATIBILITY ExactVersion
#)
set(INCLUDE_INSTALL_DIR include)
set(LIB_INSTALL_DIR lib)
set(CURRENT_BUILD_DIR "${CMAKE_BINARY_DIR}")
# create config file
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/HDILibSlimConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/HDILibSlimConfig.cmake"
PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR CURRENT_BUILD_DIR
INSTALL_DESTINATION lib/cmake/HDILibSlim
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
# install the package files files
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/HDILibSlimConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/HDILibSlimConfigVersion.cmake"
DESTINATION lib/cmake/HDILibSlim
COMPONENT HDISlim_PACKAGE
)
endif()