forked from UniStuttgart-VISUS/megamol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
205 lines (175 loc) · 7.62 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# MegaMol
# Copyright (c) 2020, MegaMol Dev Team
# All rights reserved.
#
cmake_minimum_required(VERSION 3.15...3.24 FATAL_ERROR)
# vcpkg
include(FetchContent)
mark_as_advanced(FORCE
FETCHCONTENT_BASE_DIR
FETCHCONTENT_FULLY_DISCONNECTED
FETCHCONTENT_QUIET
FETCHCONTENT_UPDATES_DISCONNECTED)
# Require git for download
find_package(Git REQUIRED)
FetchContent_Declare(vcpkg-download
GIT_REPOSITORY https://github.com/microsoft/vcpkg.git
GIT_TAG 2022.10.19 # Update default-registry baseline in vcpkg-configuration.json when changing!
GIT_SHALLOW TRUE)
FetchContent_GetProperties(vcpkg-download)
if (NOT vcpkg-download_POPULATED)
message(STATUS "Fetch vcpkg ...")
FetchContent_Populate(vcpkg-download)
mark_as_advanced(FORCE
FETCHCONTENT_SOURCE_DIR_VCPKG-DOWNLOAD
FETCHCONTENT_UPDATES_DISCONNECTED_VCPKG-DOWNLOAD)
endif ()
include(cmake/megamol_feature_option.cmake)
megamol_feature_option(CGAL "Enable CGAL support" OFF)
megamol_feature_option(CUDA "Enable CUDA support" OFF)
megamol_feature_option(MPI "Enable MPI support" OFF)
megamol_feature_option(OPENGL "Enable OpenGL support" ON)
megamol_feature_option(OSPRAY "Enable OSPRay support" OFF)
megamol_feature_option(PROFILING "Enable profiling support" OFF)
megamol_feature_option(VTKM "Enable VTK-m support" OFF)
# dependent options
megamol_feature_option(CUESDK "Enable Corsair CUESDK support" OFF "WIN32")
megamol_feature_option(VR_INTEROP "Enable MegaMol-Unity VR Interop via Spout2" OFF "MEGAMOL_USE_OPENGL")
megamol_feature_option(OPENGL_DEBUGGROUPS "Automatically inject OpenGL debug groups into MegaMol Call callback invocations" OFF "MEGAMOL_USE_OPENGL")
include(cmake/megamol_vcpkg_empty_port.cmake)
# option(X_VCPKG_APPLOCAL_DEPS_INSTALL "" ON) # Does currently not not work as expected, see comment on manual install below!
set(VCPKG_OVERLAY_PORTS "${mm_empty_ports_dir}${CMAKE_CURRENT_LIST_DIR}/cmake/vcpkg_ports")
set(VCPKG_OVERLAY_TRIPLETS "${CMAKE_CURRENT_LIST_DIR}/cmake/vcpkg_triplets") # We are using triplets with VCPKG_DISABLE_COMPILER_TRACKING set (on Windows).
set(VCPKG_BOOTSTRAP_OPTIONS "-disableMetrics") # Disable Telemetry
set(VCPKG_INSTALL_OPTIONS "--clean-after-build" "--no-print-usage") # Build dirs get quite large and are usually only needed for debugging new ports.
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_BINARY_DIR}/_deps/vcpkg-download-src/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file")
set(ENV{VCPKG_FORCE_DOWNLOADED_BINARIES} ON) # Vcpkg should always download tools (i.e. CMake) to have consistent versions over all systems.
option(MEGAMOL_DOWNLOAD_VCPKG_CACHE "Download prebuilt dependency binaries if available" OFF)
if (MEGAMOL_DOWNLOAD_VCPKG_CACHE)
set(ENV{VCPKG_BINARY_SOURCES} "clear;default,readwrite;http,https://vcpkg-cache.megamol.org/{triplet}-{name}-{sha},read")
endif ()
# Disable in source build
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
# Project
project(megamol
VERSION 1.3.0
LANGUAGES C CXX)
# Allow CI dependency build to stop here.
if (MEGAMOL_STOP_AFTER_VCPKG)
return()
endif ()
# Default build type
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel")
endif ()
# Default install prefix
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE)
endif ()
set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE PATH "default install path" FORCE) # This will replace "\" by "/"
# Modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
# Dependencies
add_subdirectory(externals/glad)
# MegaMol config
include(megamol_config)
# MegaMol build info library (version + config)
include(megamol_build_info)
# MegaMol targets
# Frontend Resources, Input Events interfaces
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/frontend/resources)
# Frontend Services (e.g. OpenGL_GLFW provider)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/frontend/services)
# Vislib
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/vislib)
if (MEGAMOL_USE_OPENGL)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/vislib_gl)
endif ()
# Core
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/core)
if (MEGAMOL_USE_OPENGL)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/core_gl)
endif ()
# MegaMol.exe
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/frontend/main)
# Remoteconsole
add_subdirectory(remoteconsole)
# Plugins
add_subdirectory(plugins)
if (BUILD_FRONTEND)
if (MEGAMOL_USE_OPENGL)
target_link_libraries(plugins INTERFACE core_gl)
target_sources(plugins INTERFACE $<TARGET_OBJECTS:core_gl>)
endif ()
target_link_libraries(megamol PRIVATE plugins)
endif ()
# Utils
add_subdirectory(utils)
# Add directory structure for visual studio
if (WIN32)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD TRUE)
endif ()
# Examples
option(EXAMPLES "Get the MegaMol example repository" ON)
if (EXAMPLES)
set(EXAMPLES_DIR "${CMAKE_BINARY_DIR}/examples" CACHE PATH "Download directory of the examples")
option(EXAMPLES_UPDATE "Pull updates from the examples repo" ON)
if (NOT EXISTS "${EXAMPLES_DIR}")
message(STATUS "Downloading examples")
execute_process(COMMAND
${GIT_EXECUTABLE} clone https://github.com/UniStuttgart-VISUS/megamol-examples.git "${EXAMPLES_DIR}" --depth 1
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
elseif (EXAMPLES_UPDATE)
message(STATUS "Pull example updates")
execute_process(COMMAND
${GIT_EXECUTABLE} pull
WORKING_DIRECTORY "${EXAMPLES_DIR}"
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif ()
option(EXAMPLES_INSTALL "Install examples" ON)
if (EXAMPLES_INSTALL)
install(DIRECTORY "${EXAMPLES_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/examples" PATTERN ".git" EXCLUDE)
endif ()
endif ()
# Tests
option(TESTS "Get the MegaMol tests repository" OFF)
if (TESTS)
set(TESTS_DIR "${CMAKE_BINARY_DIR}/tests" CACHE PATH "Download directory of the tests")
option(TESTS_UPDATE "Pull updates from the tests repo" ON)
if (NOT EXISTS "${TESTS_DIR}")
message(STATUS "Downloading tests")
execute_process(COMMAND
${GIT_EXECUTABLE} clone https://github.com/UniStuttgart-VISUS/megamol-tests.git "${TESTS_DIR}" --depth 1
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
elseif (TESTS_UPDATE)
message(STATUS "Pull tests updates")
execute_process(COMMAND
${GIT_EXECUTABLE} pull
WORKING_DIRECTORY "${TESTS_DIR}"
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif ()
install(DIRECTORY "${TESTS_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/tests" PATTERN ".git" EXCLUDE)
endif ()
# Install vcpkg libraries
# X_VCPKG_APPLOCAL_DEPS_INSTALL currently does only work for windows, in addition only actually used dll's are
# installed. This is a problem for libraries that load dll's dynamically on runtime (.i.e. ospray).
# Therefore, we just copy all vcpkg libraries to our install dir, until vcpkg may has a better option in future.
if (WIN32)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-windows/$<$<CONFIG:Debug>:debug/>bin/
DESTINATION "${CMAKE_INSTALL_BINDIR}"
FILES_MATCHING PATTERN "*.dll" PATTERN "*.pdb")
else ()
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-linux/$<$<CONFIG:Debug>:debug/>lib/
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
FILES_MATCHING PATTERN "*.so*")
endif ()