|
| 1 | +cmake_minimum_required(VERSION 3.5) |
| 2 | +project(PAL LANGUAGES C CXX) |
| 3 | + |
| 4 | +### CMake Includes ##################################################################################################### |
| 5 | +include(CMakeDependentOption) |
| 6 | +include(AmdCmakeHelper) |
| 7 | + |
| 8 | +### Cached Project Options ############################################################################################# |
| 9 | +# CMAKE-TODO: To support multiple configurations for Visual Studio we can't use CMAKE_BUILD_TYPE |
| 10 | +# We would have to override the options using cmake generator expressions and possibly include an |
| 11 | +# option to disable overrides such as PAL_DISABLE_INTERNAL_OPTION_OVERRIDES |
| 12 | + |
| 13 | +option(PAL_CLOSED_SOURCE "Build closed source PAL?" OFF) |
| 14 | + |
| 15 | +option(PAL_BUILD_GPUOPEN "Build GPUOpen developer driver support?" OFF) |
| 16 | + |
| 17 | +option(PAL_DBG_COMMAND_COMMENTS "Command with comments" OFF) |
| 18 | + |
| 19 | +option(PAL_DEVELOPER_BUILD "Enable developer build" OFF) |
| 20 | + |
| 21 | +option(PAL_ENABLE_PRINTS_ASSERTS "Enable print assertions?" ${CMAKE_BUILD_TYPE_DEBUG}) |
| 22 | +cmake_dependent_option(PAL_MEMTRACK "Enable PAL memory tracker?" ${CMAKE_BUILD_TYPE_DEBUG} "PAL_ENABLE_PRINTS_ASSERTS" OFF) |
| 23 | + |
| 24 | +option(PAL_BUILD_JEMALLOC "Use jemalloc as the default PAL allocator?" ON) |
| 25 | +cmake_dependent_option(PAL_JEMALLOC_STATS "Enable jemalloc statistice reporting?" OFF "PAL_BUILD_JEMALLOC" OFF) |
| 26 | +cmake_dependent_option(PAL_JEMALLOC_DEBUG "Build jemalloc in debug mode?" OFF "PAL_BUILD_JEMALLOC" OFF) |
| 27 | + |
| 28 | +option(PAL_BUILD_CORE "Build PAL Core?" ON) |
| 29 | +option(PAL_BUILD_GPUUTIL "Build PAL GPU Util?" ON) |
| 30 | +cmake_dependent_option(PAL_BUILD_LAYERS "Build PAL Layers?" ON "PAL_BUILD_GPUUTIL" OFF) |
| 31 | + |
| 32 | +option(PAL_BUILD_DBG_OVERLAY "Build PAL Debug Overlay?" ON) |
| 33 | + |
| 34 | +option(PAL_BUILD_GPU_PROFILER "Build PAL GPU Profiler?" ON) |
| 35 | + |
| 36 | +option(PAL_BUILD_CMD_BUFFER_LOGGER "Build PAL Command Buffer Logger?" ${CMAKE_BUILD_TYPE_DEBUG}) |
| 37 | +option(PAL_BUILD_INTERFACE_LOGGER "Build PAL Interface Logger?" ${CMAKE_BUILD_TYPE_DEBUG}) |
| 38 | + |
| 39 | +option(PAL_BUILD_GFX "Build PAL with Graphics support?" ON) |
| 40 | +cmake_dependent_option(PAL_BUILD_GFX6 "Build PAL with GFX6 support?" ON "PAL_BUILD_GFX" OFF) |
| 41 | +cmake_dependent_option(PAL_BUILD_GFX9 "Build PAL with GFX9 support?" ON "PAL_BUILD_GFX" OFF) |
| 42 | + |
| 43 | +option(PAL_BUILD_OSS "Build PAL with Operating System support?" ON) |
| 44 | +cmake_dependent_option(PAL_BUILD_OSS1 "Build PAL with OSS1?" ON "PAL_BUILD_OSS" OFF) |
| 45 | +cmake_dependent_option(PAL_BUILD_OSS2 "Build PAL with OSS2?" ON "PAL_BUILD_OSS" OFF) |
| 46 | +cmake_dependent_option(PAL_BUILD_OSS2_4 "Build PAL with OSS2_4?" ON "PAL_BUILD_OSS" OFF) |
| 47 | +cmake_dependent_option(PAL_BUILD_OSS4 "Build PAL with OSS4?" ON "PAL_BUILD_OSS" OFF) |
| 48 | + |
| 49 | +option(PAL_BUILD_DTIF "Build PAL with Driver-to-TCore2 InterFace support?" OFF) |
| 50 | + |
| 51 | +# PAL Client Options ############################################################################### |
| 52 | +# Use Vulkan as the default client. |
| 53 | +set(PAL_CLIENT "VULKAN" CACHE STRING "Client interfacing with PAL.") |
| 54 | + |
| 55 | +# Read the latest version from palLib.h |
| 56 | +if(DEFINED PAL_CLIENT_INTERFACE_MAJOR_VERSION) |
| 57 | + message(STATUS "Client configured PAL_INTERFACE_MAJOR_VERSION as " ${PAL_CLIENT_INTERFACE_MAJOR_VERSION}) |
| 58 | +else() |
| 59 | + file(STRINGS inc/core/palLib.h PAL_MAJOR_VERSION REGEX "^#define PAL_INTERFACE_MAJOR_VERSION [0-9]+") |
| 60 | + |
| 61 | + if(PAL_MAJOR_VERSION STREQUAL "") |
| 62 | + message(STATUS "Failed to find PAL_INTERFACE_MAJOR_VERSION") |
| 63 | + else() |
| 64 | + string(REGEX REPLACE "^#define PAL_INTERFACE_MAJOR_VERSION " "" PAL_MAJOR_VERSION ${PAL_MAJOR_VERSION}) |
| 65 | + message(STATUS "Detected PAL_INTERFACE_MAJOR_VERSION is " ${PAL_MAJOR_VERSION}) |
| 66 | + endif() |
| 67 | + set(PAL_CLIENT_INTERFACE_MAJOR_VERSION ${PAL_MAJOR_VERSION}) |
| 68 | +endif() |
| 69 | + |
| 70 | +# Option Overrides ################################################################################# |
| 71 | +# These are options that override PAL subproject options. As these overrides are managed and force |
| 72 | +# set by PAL, mark_as_advanced is used to hide them from the CMake GUI. |
| 73 | + |
| 74 | +# ADDRLIB |
| 75 | +set(PAL_ADDR_PATH ${PROJECT_SOURCE_DIR}/src/core/imported/addrlib CACHE PATH "Specify the path to the ADDRLIB project.") |
| 76 | +set(ADDR_OPTIONS_MARK_ADVANCED ON) |
| 77 | + |
| 78 | +set(ADDR_SI_BUILD ON CACHE BOOL "PAL override to build ADDRLIB with SI support." FORCE) |
| 79 | +set(ADDR_CI_BUILD ON CACHE BOOL "PAL override to build ADDRLIB with CI support." FORCE) |
| 80 | +set(ADDR_VI_BUILD ON CACHE BOOL "PAL override to build ADDRLIB with VI support." FORCE) |
| 81 | + |
| 82 | +set(ADDR_SI_CHIP_DIR ${PROJECT_SOURCE_DIR}/src/core/hw/gfxip/gfx6/chip CACHE PATH "PAL override for ADDRLIB SI/CI/VI register chip headers." FORCE) |
| 83 | + |
| 84 | +if(PAL_BUILD_GFX9) |
| 85 | + set(ADDR_GFX9_BUILD ON CACHE BOOL "PAL override to build ADDRLIB with GFX9 support." FORCE) |
| 86 | + set(ADDR_GFX9_CHIP_DIR ${PROJECT_SOURCE_DIR}/src/core/hw/gfxip/gfx9/chip CACHE PATH "PAL override for ADDRLIB GFX9 register chip headers." FORCE) |
| 87 | +endif() |
| 88 | + |
| 89 | +# JEMALLOC |
| 90 | +if(PAL_BUILD_JEMALLOC) |
| 91 | + set(PAL_JEMALLOC_PATH ${PROJECT_SOURCE_DIR}/src/core/imported/jemalloc CACHE PATH "Specify the path to the jemalloc project.") |
| 92 | + set(JEMALLOC_OPTIONS_MARK_ADVANCED ON) |
| 93 | + |
| 94 | + set(JEMALLOC_STATS ${PAL_JEMALLOC_STATS} CACHE BOOL "PAL override." FORCE) |
| 95 | + set(JEMALLOC_DEBUG ${PAL_JEMALLOC_DEBUG} CACHE BOOL "PAL override." FORCE) |
| 96 | +endif() |
| 97 | + |
| 98 | +# METROHASH |
| 99 | +set(PAL_METROHASH_PATH ${PROJECT_SOURCE_DIR}/src/core/imported/metrohash CACHE PATH "Specify the path to the MetroHash project.") |
| 100 | + |
| 101 | +# VAM |
| 102 | +set(PAL_VAM_PATH ${PROJECT_SOURCE_DIR}/src/core/imported/vam CACHE PATH "Specify the path to the VAM project.") |
| 103 | + |
| 104 | +# GPUOPEN |
| 105 | +if(PAL_BUILD_GPUOPEN) |
| 106 | + set(PAL_GPUOPEN_PATH ${PROJECT_SOURCE_DIR}/shared/gpuopen CACHE PATH "Specify the path to the GPUOPEN_PATH project.") |
| 107 | +endif() |
| 108 | + |
| 109 | +### Generator Dependencies ############################################################################################# |
| 110 | +find_package(PythonInterp 3) |
| 111 | +if(NOT PYTHONINTERP_FOUND) |
| 112 | + if(UNIX) |
| 113 | + message(FATAL_ERROR "Python 3 is needed to generate some source files.") |
| 114 | + endif() |
| 115 | +endif() |
| 116 | +set(PYTHON_CMD ${PYTHON_EXECUTABLE}) |
| 117 | + |
| 118 | +find_package(Perl 5) |
| 119 | +if(NOT PERL_FOUND) |
| 120 | + if(UNIX) |
| 121 | + message(FATAL_ERROR "Perl 5 is needed to generate some source files.") |
| 122 | + endif() |
| 123 | +endif() |
| 124 | +set(PERL_CMD ${PERL_EXECUTABLE}) |
| 125 | + |
| 126 | +### Add Subdirectories ################################################################################################# |
| 127 | +add_subdirectory(src) |
0 commit comments