-
Notifications
You must be signed in to change notification settings - Fork 27
/
CMakeLists.txt
124 lines (88 loc) · 3.15 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
## Copyright 2019 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)
# required for Windows GPU builds
set(CMAKE_NINJA_CMCLDEPS_RC OFF)
cmake_policy(SET CMP0074 NEW)
## Establish project ##
project(openvkl VERSION 2.0.1 LANGUAGES C CXX)
## Add openvkl specific macros ##
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
include(openvkl_macros)
include(openvkl_ispc)
## Version header ##
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/openvkl/include/${PROJECT_NAME}/version.h.in
${CMAKE_CURRENT_BINARY_DIR}/openvkl/include/${PROJECT_NAME}/version.h
@ONLY
)
include_directories_ispc(${CMAKE_CURRENT_BINARY_DIR}/openvkl/include/${PROJECT_NAME})
include(GNUInstallDirs)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openvkl/include/${PROJECT_NAME}/version.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
)
set(CMAKE_SKIP_INSTALL_RPATH OFF)
if (APPLE)
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_INSTALL_RPATH "@loader_path/" "@loader_path/../${CMAKE_INSTALL_LIBDIR}")
else()
set(CMAKE_INSTALL_RPATH "\$ORIGIN:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
endif()
## openvkl specific configuration ##
option(BUILD_EXAMPLES "Build example applications." ON)
option(BUILD_BENCHMARKS "Build benchmark applications." OFF)
include(CTest) # Adds 'BUILD_TESTING' variable
if (BUILD_TESTING)
enable_testing()
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
openvkl_configure_build_type()
openvkl_configure_global_build_flags()
openvkl_configure_ispc_isa()
set(RKCOMMON_VERSION_REQUIRED 1.11.0)
find_package(rkcommon ${RKCOMMON_VERSION_REQUIRED} REQUIRED)
get_target_property(RKCOMMON_INCLUDE_DIRS rkcommon::rkcommon
INTERFACE_INCLUDE_DIRECTORIES)
# rkcommon includes FindTBB.cmake, needed by Embree
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${rkcommon_DIR})
find_package(embree 4.0.0 REQUIRED)
openvkl_create_embree_target()
## Build library, examples, and tests ##
add_subdirectory(openvkl)
add_subdirectory(utility)
if (BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
add_subdirectory(testing)
## 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/openvkl-${PROJECT_VERSION}
)
# Must be last
include(CPack)