WIP: Refactor CMake build system to more modular

This commit is contained in:
Konstantinos Margaritis
2023-10-08 23:26:07 +03:00
parent f4e91b8226
commit 7dbcab34c2
11 changed files with 625 additions and 759 deletions

36
cmake/osdetection.cmake Normal file
View File

@@ -0,0 +1,36 @@
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(LINUX TRUE)
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(FREEBSD true)
endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
option(FAT_RUNTIME "Build a library that supports multiple microarchitectures" OFF)
message("Checking Fat Runtime Requirements...")
if (FAT_RUNTIME AND NOT LINUX)
message(FATAL_ERROR "Fat runtime is only supported on Linux OS")
endif()
if (FAT_RUNTIME AND LINUX)
if (NOT (ARCH_IA32 OR ARCH_X86_64 OR ARCH_AARCH64))
message(FATAL_ERROR "Fat runtime is only supported on Intel and Aarch64 architectures")
else()
message(STATUS "Building Fat runtime for multiple microarchitectures")
message(STATUS "generator is ${CMAKE_GENERATOR}")
if (NOT (CMAKE_GENERATOR MATCHES "Unix Makefiles" OR
(CMAKE_VERSION VERSION_GREATER "3.0" AND CMAKE_GENERATOR MATCHES "Ninja")))
message (FATAL_ERROR "Building the fat runtime requires the Unix Makefiles generator, or Ninja with CMake v3.0 or higher")
else()
include (${CMAKE_MODULE_PATH}/attrib.cmake)
if (NOT HAS_C_ATTR_IFUNC)
message(FATAL_ERROR "Compiler does not support ifunc attribute, cannot build fat runtime")
endif()
endif()
endif()
if (NOT RELEASE_BUILD)
message(FATAL_ERROR "Fat runtime is only built on Release builds")
endif()
endif ()