2020-04-08 20:06:35 +00:00
|
|
|
cmake_minimum_required(VERSION 3.14)
|
2019-06-29 23:50:48 +00:00
|
|
|
set (PROJECT_NAME FEXCore)
|
|
|
|
project(${PROJECT_NAME}
|
|
|
|
VERSION 0.01
|
|
|
|
LANGUAGES CXX)
|
|
|
|
|
2021-03-05 02:07:10 +00:00
|
|
|
if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
|
|
|
|
set(_M_X86_64 1)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcx16")
|
|
|
|
endif()
|
|
|
|
|
2022-09-08 22:17:40 +00:00
|
|
|
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64|^arm64|^armv8\.*")
|
2021-03-05 02:07:10 +00:00
|
|
|
set(_M_ARM_64 1)
|
|
|
|
endif()
|
|
|
|
|
2020-04-08 20:06:35 +00:00
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
cmake_policy(SET CMP0083 NEW) # Follow new PIE policy
|
|
|
|
include(CheckPIESupported)
|
|
|
|
check_pie_supported()
|
|
|
|
|
2019-06-29 23:50:48 +00:00
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
include(CheckIncludeFileCXX)
|
2023-09-19 00:07:30 +00:00
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "-std=c++11 -Wattributes -Werror=attributes")
|
|
|
|
check_cxx_source_compiles(
|
|
|
|
"
|
|
|
|
__attribute__((preserve_all))
|
2024-02-11 03:55:51 +00:00
|
|
|
int Testy(int a, int b, int c, int d, int e, int f) {
|
|
|
|
return a + b + c + d + e + f;
|
2023-09-19 00:07:30 +00:00
|
|
|
}
|
|
|
|
int main() {
|
2024-02-11 03:55:51 +00:00
|
|
|
return Testy(0, 1, 2, 3, 4, 5);
|
2023-09-19 00:07:30 +00:00
|
|
|
}"
|
|
|
|
HAS_CLANG_PRESERVE_ALL)
|
|
|
|
unset(CMAKE_REQUIRED_FLAGS)
|
|
|
|
if (HAS_CLANG_PRESERVE_ALL)
|
2023-11-17 22:13:39 +00:00
|
|
|
if (MINGW_BUILD)
|
|
|
|
message(STATUS "Ignoring broken clang::preserve_all support")
|
|
|
|
set(HAS_CLANG_PRESERVE_ALL FALSE)
|
|
|
|
else()
|
|
|
|
message(STATUS "Has clang::preserve_all")
|
|
|
|
endif()
|
2024-02-05 21:31:45 +00:00
|
|
|
endif ()
|
2019-06-29 23:50:48 +00:00
|
|
|
|
2021-03-05 02:07:10 +00:00
|
|
|
if (EXISTS ${CMAKE_CURRENT_DIR}/External/vixl/)
|
2020-03-12 23:28:51 +00:00
|
|
|
# Useful to have for freestanding libFEXCore
|
|
|
|
add_subdirectory(External/vixl/)
|
|
|
|
include_directories(External/vixl/src/)
|
2019-06-29 23:50:48 +00:00
|
|
|
endif()
|
|
|
|
|
2020-10-14 00:51:28 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
2019-06-29 23:50:48 +00:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2020-09-05 08:02:55 +00:00
|
|
|
set(GIT_SHORT_HASH "Unknown")
|
2021-01-27 15:18:23 +00:00
|
|
|
set(GIT_DESCRIBE_STRING "FEX-Unknown")
|
2020-09-05 08:02:55 +00:00
|
|
|
|
2021-12-31 06:55:46 +00:00
|
|
|
if (OVERRIDE_VERSION STREQUAL "detect")
|
|
|
|
# Find our git hash
|
|
|
|
find_package(Git)
|
|
|
|
|
|
|
|
if (GIT_FOUND)
|
|
|
|
execute_process(
|
2022-08-15 15:12:59 +00:00
|
|
|
COMMAND ${GIT_EXECUTABLE} rev-parse --short=7 HEAD
|
2021-12-31 06:55:46 +00:00
|
|
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
|
|
|
OUTPUT_VARIABLE GIT_SHORT_HASH
|
|
|
|
ERROR_QUIET
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
execute_process(
|
2022-08-15 15:12:59 +00:00
|
|
|
COMMAND ${GIT_EXECUTABLE} describe --abbrev=7
|
2021-12-31 06:55:46 +00:00
|
|
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
|
|
|
OUTPUT_VARIABLE GIT_DESCRIBE_STRING
|
|
|
|
ERROR_QUIET
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(GIT_SHORT_HASH "${OVERRIDE_VERSION}")
|
|
|
|
set(GIT_DESCRIBE_STRING "FEX-${OVERRIDE_VERSION}")
|
2020-09-05 08:02:55 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include/git_version.h.in
|
|
|
|
${CMAKE_BINARY_DIR}/generated/git_version.h)
|
|
|
|
|
|
|
|
include_directories(${CMAKE_BINARY_DIR}/generated)
|
|
|
|
|
2023-05-04 21:42:02 +00:00
|
|
|
add_compile_options(-fno-exceptions)
|
2019-06-29 23:50:48 +00:00
|
|
|
add_subdirectory(Source/)
|
2019-11-15 07:23:23 +00:00
|
|
|
|
|
|
|
install (DIRECTORY include/FEXCore ${CMAKE_BINARY_DIR}/include/FEXCore
|
|
|
|
DESTINATION include
|
|
|
|
COMPONENT Development)
|
2022-12-26 10:15:37 +00:00
|
|
|
|
|
|
|
if (BUILD_TESTS)
|
|
|
|
add_subdirectory(unittests/)
|
|
|
|
endif()
|