|
| 1 | +cmake_minimum_required(VERSION 3.11) |
| 2 | + |
| 3 | +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/source/renderer/cmake") |
| 4 | + |
| 5 | +## Specify the top level name of the project - this will define the solution name for Visual Studio |
| 6 | +project(RRA) |
| 7 | + |
| 8 | +option(RDF_ENABLE_CXX_BINDINGS "Allow usage of C++ interface for RDF library" ON) |
| 9 | +option(RDF_STATIC "Build RDF as a static library" OFF) |
| 10 | + |
| 11 | +## For RRA we only care about the Debug and Release configuration types |
| 12 | +set(CMAKE_CONFIGURATION_TYPES Debug Release) |
| 13 | + |
| 14 | +## Determine build suffixes based on configuration and bitness |
| 15 | +## These values will be inherited by all child projects |
| 16 | +set(ADT_PLATFORM_POSTFIX "-x86") |
| 17 | +IF(CMAKE_SIZEOF_VOID_P EQUAL 8) |
| 18 | + set(ADT_PLATFORM_POSTFIX "-x64") |
| 19 | +ENDIF() |
| 20 | + |
| 21 | +set (CMAKE_DEBUG_POSTFIX -d) |
| 22 | +set (CMAKE_RELEASE_POSTFIX ) |
| 23 | + |
| 24 | +IF(WIN32) |
| 25 | + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../release) |
| 26 | + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../debug) |
| 27 | +ELSE(WIN32) |
| 28 | + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/../../release) |
| 29 | + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/../../debug) |
| 30 | +ENDIF(WIN32) |
| 31 | + |
| 32 | +# Add for CentOS compiler warning |
| 33 | +add_definitions(-DJSON_SKIP_UNSUPPORTED_COMPILER_CHECK) |
| 34 | + |
| 35 | +include_directories("${PROJECT_SOURCE_DIR}/external/qt_common/") |
| 36 | +include_directories("${PROJECT_SOURCE_DIR}/external/") |
| 37 | + |
| 38 | +# Global compiler options |
| 39 | +IF(WIN32) |
| 40 | + add_compile_options(/MP) |
| 41 | + # disable warning C4201: nonstandard extension used: nameless struct/union |
| 42 | + add_compile_options(/wd4201) |
| 43 | + # this warning is caused by the QT header files - use pragma to disable at source |
| 44 | + # disable warning C4127: conditional expression is constant |
| 45 | + add_compile_options(/wd4127) |
| 46 | + # this warning is caused by QT header files and has been introduced by VS2019 16.9.6 |
| 47 | + # disable warning C5240: 'nodiscard': attribute is ignored in this syntactic position |
| 48 | + add_compile_options(/wd5240) |
| 49 | + # bump the stack size |
| 50 | + add_link_options(/STACK:16777216) |
| 51 | +ELSEIF(UNIX) |
| 52 | + # Use -Wno-missing-field-initializers for CentOS compiler warning |
| 53 | + add_compile_options(-D_LINUX -Wno-missing-field-initializers -Wno-ignored-qualifiers) |
| 54 | + # Allow executable to be double clicked. |
| 55 | + add_link_options(-no-pie) |
| 56 | + # Use _DEBUG on Unix for Debug Builds (defined automatically on Windows) |
| 57 | + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") |
| 58 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") |
| 59 | + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") |
| 60 | +ENDIF(WIN32) |
| 61 | + |
| 62 | +IF(WIN32) |
| 63 | + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") |
| 64 | + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG") |
| 65 | +ENDIF(WIN32) |
| 66 | + |
| 67 | +# Macro to build source groups to match directory structure |
| 68 | +MACRO(SOURCE_GROUP_BY_FOLDER target) |
| 69 | + SET(SOURCE_GROUP_DELIMITER "/") |
| 70 | + SET(last_dir "") |
| 71 | + SET(files "") |
| 72 | + FOREACH(file ${SOURCES}) |
| 73 | + GET_FILENAME_COMPONENT(dir "${file}" PATH) |
| 74 | + IF (NOT "${dir}" STREQUAL "${last_dir}") |
| 75 | + IF (files) |
| 76 | + SOURCE_GROUP("${last_dir}" FILES ${files}) |
| 77 | + ENDIF (files) |
| 78 | + SET(files "") |
| 79 | + ENDIF (NOT "${dir}" STREQUAL "${last_dir}") |
| 80 | + SET(files ${files} ${file}) |
| 81 | + SET(last_dir "${dir}") |
| 82 | + ENDFOREACH(file) |
| 83 | + IF (files) |
| 84 | + SOURCE_GROUP("${last_dir}" FILES ${files}) |
| 85 | + ENDIF (files) |
| 86 | +ENDMACRO(SOURCE_GROUP_BY_FOLDER) |
| 87 | + |
| 88 | +add_subdirectory(external/qt_common/custom_widgets QtCommon/custom_widgets) |
| 89 | +add_subdirectory(external/qt_common/utils QtCommon/utils) |
| 90 | +add_subdirectory(external/rdf/imported/zstd) |
| 91 | +add_subdirectory(external/rdf/rdf) |
| 92 | +add_subdirectory(source/backend backend) |
| 93 | +add_subdirectory(source/frontend frontend) |
| 94 | +add_subdirectory(source/renderer renderer) |
| 95 | + |
| 96 | +# Group external dependency targets into folder |
| 97 | +IF(WIN32) |
| 98 | +set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 99 | +set_target_properties(QtCustomWidgets |
| 100 | + QtUtils |
| 101 | + PROPERTIES |
| 102 | + FOLDER Dependencies |
| 103 | +) |
| 104 | +ELSEIF(APPLE) |
| 105 | +set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 106 | +set_target_properties(QtCustomWidgets |
| 107 | + QtUtils |
| 108 | + PROPERTIES |
| 109 | + FOLDER Dependencies |
| 110 | +) |
| 111 | +ENDIF() |
| 112 | + |
| 113 | +IF(WIN32) |
| 114 | + set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT RadeonRaytracingAnalyzer) |
| 115 | +ENDIF(WIN32) |
| 116 | + |
| 117 | +## Copy Documentation and Samples to output directory. Note - this target is intentionally not included in |
| 118 | +## the default project build. It needs to be explicitly built as a separate project |
| 119 | + |
| 120 | +# Determine where the build process will be placing the binary files |
| 121 | +# This is evaluated at project build time - not at CMake generation time |
| 122 | +set(BUILD_ROOT $<$<CONFIG:debug>:${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}>$<$<CONFIG:release>:${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}>) |
| 123 | + |
| 124 | +# Define the option to pass to the sphinx documentation job |
| 125 | +set(SPHINX_OPTION public) |
| 126 | + |
| 127 | +find_program(SPHINX_EXECUTABLE sphinx-build) |
| 128 | +if(NOT SPHINX_EXECUTABLE) |
| 129 | + message(FATAL_ERROR "SPHINX_EXECUTABLE (sphinx-build) is not found!") |
| 130 | +endif() |
| 131 | + |
| 132 | +# group sphinx source files into a sphinx folder |
| 133 | +file(GLOB SPHINX_DOC_FILES ${SPHINX_DOC_FILES} ${CMAKE_SOURCE_DIR}/documentation/source/*.rst) |
| 134 | +set (SPHINX_DOC_MAIN ${CMAKE_SOURCE_DIR}/documentation/source/conf.py) |
| 135 | +source_group("sphinx" FILES ${SPHINX_DOC_FILES} ${SPHINX_DOC_MAIN}) |
| 136 | + |
| 137 | +# group release documents into a release_docs folder |
| 138 | +set (RELEASE_DOCS_IN_ROOT |
| 139 | + ${CMAKE_SOURCE_DIR}/README.md |
| 140 | + ${CMAKE_SOURCE_DIR}/Release_Notes.txt |
| 141 | + ${CMAKE_SOURCE_DIR}/NOTICES.txt |
| 142 | + ${CMAKE_SOURCE_DIR}/License.txt |
| 143 | +) |
| 144 | +set (RELEASE_DOCS ${RELEASE_DOCS_IN_ROOT}) |
| 145 | +source_group("release_docs" FILES ${RELEASE_DOCS}) |
| 146 | + |
| 147 | +# hang the sphinx build on the conf.py file and specify a dummy output ("sphinx_output") |
| 148 | +# this ensures the sphinx docs are built everytime you ask to build the Documentation target |
| 149 | +# Sphinx has proper dependency checking, so this works as expected. |
| 150 | +# Once built, clean up any unneeded files. |
| 151 | +add_custom_target(Documentation SOURCES ${SPHINX_DOC_FILES} ${RELEASE_DOCS} DEPENDS sphinx_output) |
| 152 | +add_custom_command(MAIN_DEPENDENCY ${SPHINX_DOC_MAIN} OUTPUT sphinx_output |
| 153 | + COMMAND ${CMAKE_COMMAND} -E echo "building Sphinx documentation" |
| 154 | + COMMAND ${SPHINX_EXECUTABLE} ${CMAKE_SOURCE_DIR}/documentation/source ${BUILD_ROOT}/docs/help/rra/html/. -t ${SPHINX_OPTION} |
| 155 | + COMMAND ${CMAKE_COMMAND} -E remove_directory ${BUILD_ROOT}/docs/help/rra/html/.doctrees |
| 156 | + COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_ROOT}/docs/help/rra/html/blas_instance_list.html |
| 157 | + COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_ROOT}/docs/help/rra/html/blas_list.html |
| 158 | + COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_ROOT}/docs/help/rra/html/blas_properties.html |
| 159 | + COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_ROOT}/docs/help/rra/html/blas_viewer.html |
| 160 | + COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_ROOT}/docs/help/rra/html/capture.html |
| 161 | + COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_ROOT}/docs/help/rra/html/overview.html |
| 162 | + COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_ROOT}/docs/help/rra/html/settings.html |
| 163 | + COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_ROOT}/docs/help/rra/html/tlas_instance_list.html |
| 164 | + COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_ROOT}/docs/help/rra/html/tlas_properties.html |
| 165 | + COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_ROOT}/docs/help/rra/html/tlas_viewer.html |
| 166 | + COMMAND ${CMAKE_COMMAND} -E remove ${BUILD_ROOT}/docs/help/rra/html/triangle_list.html |
| 167 | +) |
| 168 | + |
| 169 | +add_custom_command(TARGET Documentation POST_BUILD |
| 170 | + COMMAND ${CMAKE_COMMAND} -E echo "copying Documentation to output directory" |
| 171 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_ROOT}/docs |
| 172 | + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${RELEASE_DOCS_IN_ROOT} ${BUILD_ROOT}/. |
| 173 | + COMMAND ${CMAKE_COMMAND} -E echo "copying Samples to output directory" |
| 174 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${BUILD_ROOT}/samples |
| 175 | + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/samples/landscape.rra ${BUILD_ROOT}/samples/sample_trace.rra |
| 176 | +) |
0 commit comments