2018-08-23 09:59:57 +02:00
|
|
|
# This file has been adapted from dynarmic
|
|
|
|
|
|
|
|
cmake_minimum_required(VERSION 3.8)
|
|
|
|
project(sirit CXX)
|
|
|
|
|
|
|
|
# Determine if we're built as a subproject (using add_subdirectory)
|
|
|
|
# or if this is the master project.
|
|
|
|
set(MASTER_PROJECT OFF)
|
|
|
|
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
|
|
|
set(MASTER_PROJECT ON)
|
|
|
|
endif()
|
|
|
|
|
2021-08-09 23:26:14 +02:00
|
|
|
# Sirit project options
|
|
|
|
option(SIRIT_TESTS "Build tests" OFF)
|
|
|
|
option(SIRIT_USE_SYSTEM_SPIRV_HEADERS "Use system SPIR-V headers" OFF)
|
|
|
|
|
2018-08-23 09:59:57 +02:00
|
|
|
# Default to a Release build
|
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
|
|
|
|
message(STATUS "Defaulting to a Release build")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Set hard requirements for C++
|
2020-07-29 10:46:50 +02:00
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
2018-08-23 09:59:57 +02:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
|
|
|
# Warn on CMake API deprecations
|
|
|
|
set(CMAKE_WARN_DEPRECATED ON)
|
|
|
|
|
|
|
|
# Disable in-source builds
|
|
|
|
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
|
|
|
|
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
|
|
|
|
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
|
|
|
message(SEND_ERROR "In-source builds are not allowed.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Add the module directory to the list of paths
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules")
|
|
|
|
|
|
|
|
# Compiler flags
|
|
|
|
if (MSVC)
|
|
|
|
set(SIRIT_CXX_FLAGS
|
|
|
|
/std:c++latest # CMAKE_CXX_STANDARD as no effect on MSVC until CMake 3.10.
|
|
|
|
/W4
|
|
|
|
/w34263 # Non-virtual member function hides base class virtual function
|
|
|
|
/w44265 # Class has virtual functions, but destructor is not virtual
|
|
|
|
/w34456 # Declaration of 'var' hides previous local declaration
|
|
|
|
/w34457 # Declaration of 'var' hides function parameter
|
|
|
|
/w34458 # Declaration of 'var' hides class member
|
|
|
|
/w34459 # Declaration of 'var' hides global definition
|
|
|
|
/w34946 # Reinterpret-cast between related types
|
|
|
|
/wd4592 # Symbol will be dynamically initialized (implementation limitation)
|
|
|
|
/permissive- # Stricter C++ standards conformance
|
|
|
|
/MP
|
|
|
|
/Zi
|
|
|
|
/Zo
|
|
|
|
/EHsc
|
|
|
|
/Zc:throwingNew # Assumes new never returns null
|
|
|
|
/Zc:inline # Omits inline functions from object-file output
|
2019-11-27 09:25:27 +01:00
|
|
|
/DNOMINMAX
|
|
|
|
/WX)
|
2018-08-23 09:59:57 +02:00
|
|
|
|
|
|
|
if (CMAKE_VS_PLATFORM_TOOLSET MATCHES "LLVM-vs[0-9]+")
|
|
|
|
list(APPEND SIRIT_CXX_FLAGS
|
|
|
|
-Qunused-arguments
|
|
|
|
-Wno-missing-braces)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(SIRIT_CXX_FLAGS
|
|
|
|
-Wall
|
|
|
|
-Wextra
|
|
|
|
-Wcast-qual
|
|
|
|
-pedantic
|
|
|
|
-pedantic-errors
|
|
|
|
-Wfatal-errors
|
2019-11-27 09:25:27 +01:00
|
|
|
-Wno-missing-braces
|
|
|
|
-Wconversion
|
|
|
|
-Wsign-conversion
|
2019-11-27 09:46:03 +01:00
|
|
|
-Wshadow
|
2019-11-27 09:25:27 +01:00
|
|
|
-Werror)
|
2018-08-23 09:59:57 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Enable unit-testing.
|
|
|
|
enable_testing(true)
|
|
|
|
|
|
|
|
# SPIR-V headers
|
2021-08-09 23:26:14 +02:00
|
|
|
if (SIRIT_USE_SYSTEM_SPIRV_HEADERS)
|
|
|
|
find_package(SPIRV-Headers REQUIRED)
|
|
|
|
else()
|
|
|
|
add_subdirectory(externals/SPIRV-Headers EXCLUDE_FROM_ALL)
|
|
|
|
add_library(SPIRV-Headers::SPIRV-Headers ALIAS SPIRV-Headers)
|
|
|
|
endif()
|
2018-08-23 09:59:57 +02:00
|
|
|
|
|
|
|
# Sirit project files
|
|
|
|
add_subdirectory(src)
|
|
|
|
if (SIRIT_TESTS)
|
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|