2020-04-08 20:06:35 +00:00
|
|
|
cmake_minimum_required(VERSION 3.14)
|
2019-07-13 09:41:34 +00:00
|
|
|
project(FEX)
|
|
|
|
|
|
|
|
option(BUILD_TESTS "Build unit tests to ensure sanity" TRUE)
|
|
|
|
option(ENABLE_CLANG_FORMAT "Run clang format over the source" FALSE)
|
|
|
|
option(ENABLE_LTO "Enable LTO with compilation" TRUE)
|
|
|
|
option(ENABLE_XRAY "Enable building with LLVM X-Ray" FALSE)
|
|
|
|
option(ENABLE_LLD "Enable linking with LLD" FALSE)
|
|
|
|
option(ENABLE_ASAN "Enables Clang ASAN" FALSE)
|
|
|
|
option(ENABLE_TSAN "Enables Clang TSAN" FALSE)
|
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Bin)
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
2020-03-12 23:26:13 +00:00
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
2020-04-08 20:06:35 +00:00
|
|
|
cmake_policy(SET CMP0083 NEW) # Follow new PIE policy
|
|
|
|
include(CheckPIESupported)
|
|
|
|
check_pie_supported()
|
2019-07-13 09:41:34 +00:00
|
|
|
|
|
|
|
if (ENABLE_LTO)
|
|
|
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
2020-02-18 23:48:53 +00:00
|
|
|
else()
|
|
|
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE)
|
2019-07-13 09:41:34 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (ENABLE_XRAY)
|
|
|
|
add_compile_options(-fxray-instrument)
|
|
|
|
link_libraries(-fxray-instrument)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (ENABLE_LLD)
|
|
|
|
link_libraries(-fuse-ld=lld)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (ENABLE_ASAN)
|
|
|
|
add_compile_options(-fno-omit-frame-pointer -fsanitize=address)
|
|
|
|
link_libraries(-fno-omit-frame-pointer -fsanitize=address)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (ENABLE_TSAN)
|
|
|
|
add_compile_options(-fno-omit-frame-pointer -fsanitize=thread)
|
|
|
|
link_libraries(-fno-omit-frame-pointer -fsanitize=thread)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer")
|
|
|
|
set (CMAKE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_LINKER_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer")
|
|
|
|
|
|
|
|
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer")
|
|
|
|
set (CMAKE_LINKER_FLAGS_RELEASE "${CMAKE_LINKER_FLAGS_RELEASE} -fomit-frame-pointer")
|
|
|
|
|
2020-03-12 23:28:51 +00:00
|
|
|
if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
|
|
|
|
set(_M_X86_64 1)
|
2020-04-08 07:17:54 +00:00
|
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcx16")
|
2020-03-12 23:28:51 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (FORCE_AARCH64 OR CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
|
|
|
|
set(_M_ARM_64 1)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (FORCE_AARCH64 OR CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
|
|
|
|
add_subdirectory(External/vixl/)
|
|
|
|
include_directories(External/vixl/src/)
|
|
|
|
endif()
|
|
|
|
|
2019-07-13 09:41:34 +00:00
|
|
|
add_definitions(-Wno-trigraphs)
|
|
|
|
|
2020-03-06 06:44:10 +00:00
|
|
|
add_subdirectory(External/SonicUtils/)
|
2019-11-15 07:33:55 +00:00
|
|
|
include_directories(External/SonicUtils/include/SonicUtils)
|
2019-07-13 09:41:34 +00:00
|
|
|
|
|
|
|
add_subdirectory(External/cpp-optparse/)
|
|
|
|
include_directories(External/cpp-optparse/)
|
|
|
|
|
|
|
|
add_subdirectory(External/imgui/)
|
|
|
|
include_directories(External/imgui/)
|
|
|
|
|
|
|
|
add_subdirectory(External/json-maker/)
|
|
|
|
include_directories(External/json-maker/)
|
|
|
|
|
|
|
|
add_subdirectory(External/tiny-json/)
|
|
|
|
include_directories(External/tiny-json/)
|
2020-03-06 07:41:29 +00:00
|
|
|
|
|
|
|
include_directories(External/xbyak/)
|
2019-07-13 09:41:34 +00:00
|
|
|
|
|
|
|
include_directories(Source/)
|
|
|
|
include_directories("${CMAKE_BINARY_DIR}/Source/")
|
|
|
|
|
|
|
|
add_subdirectory(External/FEXCore)
|
|
|
|
|
|
|
|
find_package(LLVM CONFIG QUIET)
|
|
|
|
if(LLVM_FOUND AND TARGET LLVM)
|
|
|
|
message(STATUS "LLVM found!")
|
|
|
|
include_directories(${LLVM_INCLUDE_DIRS})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
|
|
|
|
# Add in diagnostic colours if the option is available.
|
|
|
|
# Ninja code generator will kill colours if this isn't here
|
|
|
|
check_cxx_compiler_flag(-fdiagnostics-color=always GCC_COLOR)
|
|
|
|
check_cxx_compiler_flag(-fcolor-diagnostics CLANG_COLOR)
|
|
|
|
|
|
|
|
if (GCC_COLOR)
|
|
|
|
add_compile_options(-fdiagnostics-color=always)
|
|
|
|
endif()
|
|
|
|
if (CLANG_COLOR)
|
|
|
|
add_compile_options(-fcolor-diagnostics)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
check_cxx_compiler_flag("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
|
|
|
|
if(COMPILER_SUPPORTS_MARCH_NATIVE)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_compile_options(-Wall)
|
|
|
|
|
|
|
|
add_subdirectory(Source/)
|
|
|
|
|
|
|
|
if (BUILD_TESTS)
|
|
|
|
enable_testing()
|
|
|
|
message(STATUS "Unit tests are enabled")
|
|
|
|
add_subdirectory(unittests/)
|
|
|
|
endif()
|