forked from RenderKit/ospray-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
155 lines (124 loc) · 4.66 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
## Copyright 2009 Intel Corporation
## SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.15)
project(ospray_studio VERSION 1.0.0 LANGUAGES CXX C)
include(GNUInstallDirs)
include(ProcessorCount)
ProcessorCount(PROCESSOR_COUNT)
set(NUM_BUILD_JOBS ${PROCESSOR_COUNT} CACHE STRING "Number of build jobs '-j <n>'")
set(DEFAULT_BUILD_COMMAND cmake --build . --config release -j ${NUM_BUILD_JOBS})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Install location." FORCE)
endif()
set (CMAKE_CXX_STANDARD 14 CACHE STRING
"C++ standard for preference (11, 14, 17, 20, etc.)")
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS OFF)
message (STATUS "This build is for C++${CMAKE_CXX_STANDARD}")
# Quiet warning about DOWNLOAD_EXTRACT_TIMESTAMP since CMake 3.24:
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
## CTest testing ##
include(CTest) # Adds 'BUILD_TESTING' variable
if(BUILD_TESTING)
enable_testing()
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo")
if (WIN32)
if (NOT OSPRAY_DEFAULT_CMAKE_CONFIGURATION_TYPES_SET)
set(CMAKE_CONFIGURATION_TYPES "${CONFIGURATION_TYPES}"
CACHE STRING "List of generated configurations." FORCE)
set(OSPRAY_DEFAULT_CMAKE_CONFIGURATION_TYPES_SET ON
CACHE INTERNAL "Default CMake configuration types set.")
endif()
else()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the build type." FORCE)
endif()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CONFIGURATION_TYPES})
endif()
## Add dependent load for Windows dll injection load security
if (WIN32)
get_filename_component(COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME_WE)
if (COMPILER_NAME STREQUAL "icx" OR COMPILER_NAME STREQUAL "icpx")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /Qoption,link,/DEPENDENTLOADFLAG:0x2000")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /Qoption,link,/DEPENDENTLOADFLAG:0x2000")
elseif (MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEPENDENTLOADFLAG:0x2000")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEPENDENTLOADFLAG:0x2000")
else()
message(WARNING "Urecognized compiler, DEPENDENTLOADFLAG can't be set")
endif()
endif()
## global options and variables
option(OSPRAY_INSTALL "Install OSPRay libraries in addition to OSPRay Studio libraries / binaries" ON)
set(OSPRAY_STUDIO_RESOURCE_FILE "${PROJECT_SOURCE_DIR}/resources/ospray_studio.rc")
if(APPLE)
## ensures that build-time executables contain install-time rpaths, ensuring
## they are identical from a code-signing POV
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
endif()
list(APPEND CMAKE_MODULE_PATH
${PROJECT_SOURCE_DIR}/cmake
)
include(functions)
## Find dependencies ##
option(BUILD_APPS "Build OSPRay Studio Apps" ON)
if (BUILD_APPS)
set(OpenGL_GL_PREFERENCE "LEGACY")
find_package(OpenGL 2 REQUIRED)
include(glfw)
endif()
include(ospray)
option(USE_BENCHMARK "Build benchmarking support into ospStudio" ON)
if(USE_BENCHMARK)
include(benchmark)
endif()
## Build application ##
set(OSPRAY_DEFAULT_COMPONENT apps)
## Optional MPI Support ##
option(USE_MPI "Enable MPI" OFF)
if (USE_MPI)
find_package(MPI REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_MPI=1")
endif()
add_subdirectory(external)
add_subdirectory(sg)
## make pysg module optional
option(USE_PYSG "Enable PYSG module" ON)
if(USE_PYSG)
include(cmake/pybind11.cmake)
add_subdirectory(pysg)
endif()
if (BUILD_APPS)
add_subdirectory(app)
endif()
## Build plugins ##
option(BUILD_PLUGINS "Build plugins subtree" OFF)
if (BUILD_PLUGINS)
add_subdirectory(plugins)
endif()
install(FILES
${PROJECT_SOURCE_DIR}/LICENSE.txt
${PROJECT_SOURCE_DIR}/third-party-programs.txt
${PROJECT_SOURCE_DIR}/third-party-programs-OSPRay.txt
${PROJECT_SOURCE_DIR}/third-party-programs-DPCPP.txt
${PROJECT_SOURCE_DIR}/third-party-programs-Embree.txt
${PROJECT_SOURCE_DIR}/third-party-programs-ISPC.txt
${PROJECT_SOURCE_DIR}/third-party-programs-OIDN.txt
${PROJECT_SOURCE_DIR}/third-party-programs-oneAPI-DPCPP.txt
${PROJECT_SOURCE_DIR}/third-party-programs-oneDNN.txt
${PROJECT_SOURCE_DIR}/third-party-programs-oneTBB.txt
${PROJECT_SOURCE_DIR}/third-party-programs-OpenVKL.txt
${PROJECT_SOURCE_DIR}/CHANGELOG.md
${PROJECT_SOURCE_DIR}/README.md
DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT apps
)
include(package)
# must be last
include(CPack)