File: CMakeLists.txt

package info (click to toggle)
level-zero-gpu-raytracing 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,428 kB
  • sloc: cpp: 20,903; makefile: 9
file content (144 lines) | stat: -rw-r--r-- 6,304 bytes parent folder | download
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
## Copyright 2009-2021 Intel Corporation
## SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.1.0)

project(ze_raytracing)

SET(ZE_RAYTRACING_VERSION_MAJOR 1)
SET(ZE_RAYTRACING_VERSION_MINOR 1)
SET(ZE_RAYTRACING_VERSION_PATCH 0)
SET(ZE_RAYTRACING_VERSION ${ZE_RAYTRACING_VERSION_MAJOR}.${ZE_RAYTRACING_VERSION_MINOR}.${ZE_RAYTRACING_VERSION_PATCH})
IF (ZE_RAYTRACING_VERSION_BUILD)
  SET(ZE_RAYTRACING_VERSION ${ZE_RAYTRACING_VERSION}.${ZE_RAYTRACING_VERSION_BUILD})
ENDIF()

IF(COMMAND cmake_policy)
  if(POLICY CMP0135)
    message("set policy CMP0135 to NEW")
    cmake_policy(SET CMP0135 NEW)
  endif()
ENDIF()

SET(CMAKE_CXX_STANDARD 17)
SET(EMBREE_CMAKEEXPORT_DIR "cmake")

SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

# Build configurations to use
SET(CMAKE_BUILD_TYPE "ReleaseInternal" CACHE STRING "Specifies the build type.")
SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release ReleaseInternal)
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release;ReleaseInternal" CACHE STRING "List of generated configurations." FORCE)

# Debug build configuration
IF (WIN32) # Link runtime statically under Windows
  STRING(REGEX REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
  STRING(REGEX REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
ENDIF()
MESSAGE("CMAKE_CXX_FLAGS_DEBUG = ${CMAKE_CXX_FLAGS_DEBUG}")
MESSAGE("CMAKE_C_FLAGS_DEBUG = ${CMAKE_C_FLAGS_DEBUG}")
MESSAGE("CMAKE_SHARED_LINKER_FLAGS_DEBUG = ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
MESSAGE("CMAKE_EXE_LINKER_FLAGS_DEBUG = ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")

# Release build configuration
SET(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
SET(CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELWITHDEBINFO})
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO})
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
IF (WIN32) # Link runtime statically under Windows
  STRING(REGEX REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
  STRING(REGEX REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
ENDIF()
IF (WIN32) # enable dynamic control flow guard mitigation under windows
  SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /guard:cf")
  SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /guard:cf")
  SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DynamicBase /guard:cf")
  SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DynamicBase /guard:cf")
ENDIF()
MESSAGE("CMAKE_CXX_FLAGS_RELEASE = ${CMAKE_CXX_FLAGS_RELEASE}")
MESSAGE("CMAKE_C_FLAGS_RELEASE = ${CMAKE_C_FLAGS_RELEASE}")
MESSAGE("CMAKE_SHARED_LINKER_FLAGS_RELEASE = ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
MESSAGE("CMAKE_EXE_LINKER_FLAGS_RELEASE = ${CMAKE_EXE_LINKER_FLAGS_RELEASE}")

# ReleaseInternal build configuration
string(REPLACE "DNDEBUG" "DDEBUG" CMAKE_CXX_FLAGS_RELEASEINTERNAL "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
string(REPLACE "DNDEBUG" "DDEBUG" CMAKE_C_FLAGS_RELEASEINTERNAL   "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASEINTERNAL ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO})
SET(CMAKE_EXE_LINKER_FLAGS_RELEASEINTERNAL ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
IF (WIN32) # Link runtime statically under Windows
  STRING(REGEX REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASEINTERNAL "${CMAKE_C_FLAGS_RELEASEINTERNAL}")
  STRING(REGEX REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASEINTERNAL "${CMAKE_CXX_FLAGS_RELEASEINTERNAL}")
ENDIF()
MESSAGE("CMAKE_CXX_FLAGS_RELEASEINTERNAL = ${CMAKE_CXX_FLAGS_RELEASEINTERNAL}")
MESSAGE("CMAKE_C_FLAGS_RELEASEINTERNAL = ${CMAKE_C_FLAGS_RELEASEINTERNAL}")
MESSAGE("CMAKE_SHARED_LINKER_FLAGS_RELEASEINTERNAL = ${CMAKE_SHARED_LINKER_FLAGS_RELEASEINTERNAL}")
MESSAGE("CMAKE_EXE_LINKER_FLAGS_RELEASEINTERNAL = ${CMAKE_EXE_LINKER_FLAGS_RELEASEINTERNAL}")

# configure resource file file
CONFIGURE_FILE(
  "${PROJECT_SOURCE_DIR}/level_zero_raytracing.rc.in"
  "${PROJECT_SOURCE_DIR}/level_zero_raytracing.rc"
)

# we support building TBB statically
OPTION(ZE_RAYTRACING_TBB_STATIC "Using statically build TBB" ON)
IF (ZE_RAYTRACING_TBB_STATIC)
  INCLUDE(fetchtbb)
ELSE()
  FIND_PACKAGE(TBB REQUIRED)
ENDIF()
ADD_DEFINITIONS(-DTASKING_TBB)

OPTION(ZE_RAYTRACING_RT_SIMULATION "Using hardware simulation" OFF)
IF (ZE_RAYTRACING_RT_SIMULATION AND (NOT ZE_RAYTRACING_RT_VALIDATION_API OR ZE_RAYTRACING_IMPLICIT_DISPATCH_GLOBALS))
  MESSAGE(FATAL_ERROR "Using ZE_RAYTRACING_RT_SIMULATION requires ZE_RAYTRACING_RT_VALIDATION_API=ON and ZE_RAYTRACING_IMPLICIT_DISPATCH_GLOBALS=OFF")
ENDIF()

IF (ZE_RAYTRACING_RT_SIMULATION)
  FIND_PACKAGE(rtcore)
  ADD_DEFINITIONS("-DEMBREE_SYCL_RT_SIMULATION")
ENDIF()

OPTION(ZE_RAYTRACING_RT_VALIDATION_API "Use rt_validation API instead of IGC provided rt_production API" OFF)
IF (ZE_RAYTRACING_RT_VALIDATION_API)
  ADD_DEFINITIONS("-DEMBREE_SYCL_RT_VALIDATION_API")
ENDIF()

SET(ZE_RAYTRACING_DEVICE -1 CACHE STRING "Forces Xe device to use.")
ADD_DEFINITIONS("-DZE_RAYTRACING_DEVICE=${ZE_RAYTRACING_DEVICE}")

OPTION(ZE_RAYTRACING_IMPLICIT_DISPATCH_GLOBALS "Using L0 allocated Dispatch Globals" ON)
IF (NOT ZE_RAYTRACING_IMPLICIT_DISPATCH_GLOBALS)
  ADD_DEFINITIONS("-DEMBREE_SYCL_ALLOC_DISPATCH_GLOBALS")
ENDIF()

SET(ZE_RAYTRACING_SYCL_TESTS "OFF" CACHE STRING "Enable SYCL tests.")
SET_PROPERTY(CACHE ZE_RAYTRACING_SYCL_TESTS PROPERTY STRINGS OFF DEFAULT_RTAS_BUILDER INTERNAL_RTAS_BUILDER LEVEL_ZERO_RTAS_BUILDER)

STRING(TOLOWER "${CMAKE_CXX_COMPILER_ID}" LOWER_CXX_COMPILER_ID)
include(${LOWER_CXX_COMPILER_ID})

INCLUDE(CTest)
include(package)
INCLUDE(CPack)

IF (ZE_RAYTRACING_RT_VALIDATION_API)
  ADD_SUBDIRECTORY(rttrace)
  SET(EMBREE_RTHWIF_SYCL embree_rthwif_sycl)
ENDIF()

ADD_SUBDIRECTORY(rtbuild/sys)
ADD_SUBDIRECTORY(rtbuild/simd)
ADD_SUBDIRECTORY(level_zero)

IF (NOT ZE_RAYTRACING_SYCL_TESTS STREQUAL "LEVEL_ZERO_RTAS_BUILDER") # do not build RTAS builder when building LEVEL_ZERO test
  ADD_SUBDIRECTORY(rtbuild)
ENDIF()

IF (NOT ZE_RAYTRACING_SYCL_TESTS STREQUAL "OFF")
  ADD_SUBDIRECTORY(testing)
ENDIF()