-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
151 lines (115 loc) · 5.22 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
cmake_minimum_required(VERSION 3.17.0)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.27.0")
cmake_policy(SET CMP0144 NEW) # Remove once we set min cmake version accordingly
endif()
project("SNE-Analyses" C CXX)
# -----------------------------------------------------------------------------
# User options
# -----------------------------------------------------------------------------
option(MV_SNE_USE_ARTIFACTORY_LIBS "Use the prebuilt libraries from artifactory" ON)
option(MV_SNE_USE_AVX "Enable AVX support" OFF)
option(MV_UNITY_BUILD "Combine target source files into batches for faster compilation" OFF)
set(MV_SNE_OPTIMIZATION_LEVEL "2" CACHE STRING "Optimization level for all targets in release builds, e.g. 0, 1, 2")
# -----------------------------------------------------------------------------
# CMake options
# -----------------------------------------------------------------------------
set(VERBOSE TRUE)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
# macros for linking both prebuilt artifactory libraries and locally built ones
include(CMakeLinkUtilities)
# Test hardware avx capabilities
include(CMakeSetOptimizationAndAVX)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DWIN32 /EHsc /MP /permissive- /Zc:__cplusplus")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
endif(MSVC)
# -----------------------------------------------------------------------------
# Install dependency libraries
# -----------------------------------------------------------------------------
# HDILib, flann and lz4 are available prebuilt in the lkeb-artifactory
if (MV_SNE_USE_ARTIFACTORY_LIBS AND NOT MV_SNE_ARTIFACTORY_LIBS_INSTALLED)
set(LIBRARY_INSTALL_DIR ${PROJECT_BINARY_DIR})
message(STATUS "Installing artifactory packages to: ${LIBRARY_INSTALL_DIR}")
set(HDILib_VERSION 1.2.8)
set(flann_VERSION 1.9.2)
set(lz4_VERSION 1.10.0)
include(FetchContent)
FetchContent_Declare(cmakesupport
GIT_REPOSITORY https://github.com/ManiVaultStudio/github-actions
GIT_TAG main
GIT_SHALLOW TRUE
SOURCE_SUBDIR CMakeSupport
)
FetchContent_MakeAvailable(cmakesupport)
message(STATUS "FetchContent: ${cmakesupport_SOURCE_DIR} ${cmakesupport_BINARY_DIR}")
include("${cmakesupport_SOURCE_DIR}/CMakeSupport/InstallArtifactoryPackage.cmake")
install_artifactory_package(HDILib ${HDILib_VERSION} biovault TRUE)
install_artifactory_package(flann ${flann_VERSION} lkeb TRUE)
install_artifactory_package(lz4 ${lz4_VERSION} lkeb TRUE)
set(lz4_ROOT "${LIBRARY_INSTALL_DIR}/lz4/lib/cmake/lz4" CACHE PATH "Location of lz4 cmake file")
set(flann_ROOT "${LIBRARY_INSTALL_DIR}/flann/lib/cmake/flann" CACHE PATH "Location of flann cmake file")
set(HDILIB_ROOT "${LIBRARY_INSTALL_DIR}/HDILib/lib/cmake/HDILib" CACHE PATH "Location of HDILib cmake file")
set(MV_SNE_ARTIFACTORY_LIBS_INSTALLED TRUE CACHE BOOL "Use the prebuilt libraries from artifactory" FORCE)
endif()
# -----------------------------------------------------------------------------
# Dependencies
# -----------------------------------------------------------------------------
find_package(Qt6 COMPONENTS Widgets WebEngineWidgets REQUIRED)
find_package(ManiVault COMPONENTS Core PointData ImageData CONFIG)
find_package(lz4 CONFIG)
if(NOT ${lz4_FOUND})
find_package(PkgConfig REQUIRED)
pkg_check_modules(lz4 REQUIRED IMPORTED_TARGET liblz4)
set(LZ4_TARGET PkgConfig::lz4)
endif()
if(NOT ${lz4_FOUND})
message (FATAL_ERROR "lz4 NOT found")
endif()
message (STATUS "Found lz4 version ${lz4_VERSION}")
find_package(flann CONFIG)
if(NOT ${flann_FOUND})
find_package(PkgConfig REQUIRED)
pkg_check_modules(flann REQUIRED flann)
set(FLANN_TARGET flann_cpp)
set(flann_INCLUDE_DIR "${flann_INCLUDE_DIRS}/flann")
endif()
if(NOT ${flann_FOUND})
message (FATAL_ERROR "flann NOT found")
endif()
message (STATUS "Found flann version ${flann_VERSION}")
if(NOT HDILIB_ROOT)
message(FATAL_ERROR "Define HDILIB_ROOT")
endif()
find_package(HDILib COMPONENTS hdidimensionalityreduction hdiutils hdidata CONFIG REQUIRED)
if(${HDILib_FOUND})
message(STATUS "HDILib found at ${HDILIB_ROOT} with ${HDILib_LINK_LIBS}")
endif()
find_package(OpenGL REQUIRED)
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
message(STATUS "Found OpenMP")
endif()
if(UNIX)
message(STATUS "pThreads for Linux")
find_package(Threads REQUIRED)
endif(UNIX)
set(THIRD_PARTY_JSON
${CMAKE_CURRENT_SOURCE_DIR}/third_party/json/nlohmann/json.hpp
)
# Checks whether this is the first CMake run for this project.
# If so, sets the CMake Install Prefix to the ManiVault install directory.
# This if-statement must be placed after the project() command to work.
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${MV_INSTALL_DIR} CACHE PATH "..." FORCE)
endif()
# -----------------------------------------------------------------------------
# Project targets
# -----------------------------------------------------------------------------
# Source files shared by both Hsne and Tsne plugins
add_subdirectory(src/Common)
include(CMakeTsneProject)
include(CMakeHsneProject)