-
Notifications
You must be signed in to change notification settings - Fork 25
/
CMakeLists.txt
135 lines (101 loc) · 4.44 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
## Copyright 2009-2020 Intel Corporation
## SPDX-License-Identifier: Apache-2.0
## Global CMake options ##
cmake_minimum_required(VERSION 3.1)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
enable_language(CXX)
include(GNUInstallDirs)
## Establish project ##
project(openpgl VERSION 0.7.0 LANGUAGES C CXX)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
include(openpgl_macros)
##############################################################
# Platform detection and defaults
##############################################################
SET(OPENPGL_ARM OFF)
IF (APPLE AND CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" OR CMAKE_OSX_ARCHITECTURES MATCHES "arm64"))
MESSAGE(STATUS "Building for Apple silicon")
SET(OPENPGL_ARM ON)
ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64")
MESSAGE(STATUS "Building for AArch64")
SET(OPENPGL_ARM ON)
ENDIF()
##############################################################
# Open PGL specific configuration
##############################################################
option(OPENPGL_BUILD_STATIC "Build OpenPGL as static library." OFF)
option(OPENPGL_BUILD_TOOLS "Build tool applications." OFF)
option(OPENPGL_BUILD_CHECK_TOOL "Build check tool application." OFF)
try_compile(COMPILER_SUPPORTS_ARM_NEON "${CMAKE_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/cmake/check_arm_neon.cpp")
OPTION(OPENPGL_EF_RADIANCE_CACHES "Enables experimental feature (ir)radiance caches." OFF)
OPTION(OPENPGL_EF_IMAGE_SPACE_GUIDING_BUFFER "Enables experimental feature ImageSpaceGuidignBuffer." OFF)
OPTION(OPENPGL_DIRECTION_COMPRESSION "Using 32-Bit compression to represent directions." OFF)
OPTION(OPENPGL_RADIANCE_COMPRESSION "Using RGBE 32-Bit compression to represent radiance data (linear RGB)." OFF)
if(COMPILER_SUPPORTS_ARM_NEON)
option(OPENPGL_ISA_NEON "Build with support for NEON." ON)
option(OPENPGL_ISA_NEON2X "Build with support for NEON double pumped." ON)
else()
option(OPENPGL_ISA_SSE4 "Build with support for SSE4." ON)
option(OPENPGL_ISA_AVX2 "Build with support for AVX2." ON)
option(OPENPGL_ISA_AVX512 "Build with support for AVX512." OFF)
endif()
if(NOT (OPENPGL_ISA_NEON OR
OPENPGL_ISA_NEON2X OR
OPENPGL_ISA_SSE4 OR
OPENPGL_ISA_AVX2 OR
OPENPGL_ISA_AVX512))
message(FATAL_ERROR "Must have at least one ISA enabled.")
endif()
SET(OPENPGL_LIBRARY_NAME "openpgl" CACHE STRING "Name of the Open PGL library file (default is openpgl)")
SET(OPENPGL_TBB_COMPONENT "tbb" CACHE STRING "The TBB component/library name.")
if (NOT ${OPENPGL_TBB_ROOT} STREQUAL "")
set(TBB_FIND_PACKAGE_OPTION "NO_DEFAULT_PATH")
set(TBB_ROOT ${OPENPGL_TBB_ROOT})
list(APPEND CMAKE_PREFIX_PATH ${OPENPGL_TBB_ROOT})
endif()
FIND_PACKAGE(TBB REQUIRED ${OPENPGL_TBB_COMPONENT})
if (OPENPGL_EF_IMAGE_SPACE_GUIDING_BUFFER)
FIND_PACKAGE(OpenImageDenoise 2.2.0 REQUIRED)
#FIND_PACKAGE(ZLIB REQUIRED)
endif()
## Global compiler setup
if(WIN32)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEPENDENTLOADFLAG:0x2000")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEPENDENTLOADFLAG:0x2000")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
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")
endif()
endif(WIN32)
## Build library and ##
add_subdirectory(openpgl)
add_subdirectory(tools)
## Configure CMake find_package() config files ##
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/rkcommon
)
write_basic_package_version_file(
"${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/openpgl-${PROJECT_VERSION}
)
# Must be last
include(CPack)