From d626381ad059628931c122f4b7ef1410408efa76 Mon Sep 17 00:00:00 2001 From: Duncan Bellamy Date: Sun, 20 Feb 2022 13:14:11 +0000 Subject: [PATCH 1/2] change FAT_RUNTIME to a normal option so it can be set to off fixes #89 --- CMakeLists.txt | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57a54033..01c3676e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,6 +136,32 @@ if (BUILD_AVX512VBMI) set(BUILD_AVX512 ON) endif () +option(FAT_RUNTIME "Build a library that supports multiple microarchitectures" ON) +if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND FAT_RUNTIME MATCHES "ON") + # This is a Linux-only feature for now - requires platform support + # elsewhere + message(STATUS "generator is ${CMAKE_GENERATOR}") + if (CMAKE_C_COMPILER_IS_CLANG AND CMAKE_C_COMPILER_VERSION VERSION_LESS "3.9") + message (STATUS "Clang v3.9 or higher required for fat runtime, cannot build fat runtime") + set (FAT_RUNTIME_REQUISITES FALSE) + elseif (NOT (CMAKE_GENERATOR MATCHES "Unix Makefiles" OR + (CMAKE_VERSION VERSION_GREATER "3.0" AND CMAKE_GENERATOR MATCHES "Ninja"))) + message (STATUS "Building the fat runtime requires the Unix Makefiles generator, or Ninja with CMake v3.0 or higher") + set (FAT_RUNTIME_REQUISITES FALSE) + else() + include (${CMAKE_MODULE_PATH}/attrib.cmake) + if (NOT HAS_C_ATTR_IFUNC) + message(STATUS "Compiler does not support ifunc attribute, cannot build fat runtime") + set (FAT_RUNTIME_REQUISITES FALSE) + else () + set (FAT_RUNTIME_REQUISITES TRUE) + endif() + endif() + if (NOT FAT_RUNTIME_REQUISITES OR NOT RELEASE_BUILD) + set (FAT_RUNTIME OFF) + endif() +endif () + # TODO: per platform config files? # remove CMake's idea of optimisation @@ -361,29 +387,6 @@ if (RELEASE_BUILD) endif() endif() -if (CMAKE_SYSTEM_NAME MATCHES "Linux") - # This is a Linux-only feature for now - requires platform support - # elsewhere - message(STATUS "generator is ${CMAKE_GENERATOR}") - if (CMAKE_C_COMPILER_IS_CLANG AND CMAKE_C_COMPILER_VERSION VERSION_LESS "3.9") - message (STATUS "Clang v3.9 or higher required for fat runtime, cannot build fat runtime") - set (FAT_RUNTIME_REQUISITES FALSE) - elseif (NOT (CMAKE_GENERATOR MATCHES "Unix Makefiles" OR - (CMAKE_VERSION VERSION_GREATER "3.0" AND CMAKE_GENERATOR MATCHES "Ninja"))) - message (STATUS "Building the fat runtime requires the Unix Makefiles generator, or Ninja with CMake v3.0 or higher") - set (FAT_RUNTIME_REQUISITES FALSE) - else() - include (${CMAKE_MODULE_PATH}/attrib.cmake) - if (NOT HAS_C_ATTR_IFUNC) - message(STATUS "Compiler does not support ifunc attribute, cannot build fat runtime") - set (FAT_RUNTIME_REQUISITES FALSE) - else () - set (FAT_RUNTIME_REQUISITES TRUE) - endif() - endif() - CMAKE_DEPENDENT_OPTION(FAT_RUNTIME "Build a library that supports multiple microarchitectures" ${RELEASE_BUILD} "FAT_RUNTIME_REQUISITES" OFF) -endif () - include (${CMAKE_MODULE_PATH}/arch.cmake) # testing a builtin takes a little more work From b34aacdb947bfc51c5f3777b5342bb1e66610dca Mon Sep 17 00:00:00 2001 From: Duncan Bellamy Date: Tue, 22 Feb 2022 19:21:18 +0000 Subject: [PATCH 2/2] move to original position --- CMakeLists.txt | 52 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 01c3676e..c90c36be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,32 +136,6 @@ if (BUILD_AVX512VBMI) set(BUILD_AVX512 ON) endif () -option(FAT_RUNTIME "Build a library that supports multiple microarchitectures" ON) -if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND FAT_RUNTIME MATCHES "ON") - # This is a Linux-only feature for now - requires platform support - # elsewhere - message(STATUS "generator is ${CMAKE_GENERATOR}") - if (CMAKE_C_COMPILER_IS_CLANG AND CMAKE_C_COMPILER_VERSION VERSION_LESS "3.9") - message (STATUS "Clang v3.9 or higher required for fat runtime, cannot build fat runtime") - set (FAT_RUNTIME_REQUISITES FALSE) - elseif (NOT (CMAKE_GENERATOR MATCHES "Unix Makefiles" OR - (CMAKE_VERSION VERSION_GREATER "3.0" AND CMAKE_GENERATOR MATCHES "Ninja"))) - message (STATUS "Building the fat runtime requires the Unix Makefiles generator, or Ninja with CMake v3.0 or higher") - set (FAT_RUNTIME_REQUISITES FALSE) - else() - include (${CMAKE_MODULE_PATH}/attrib.cmake) - if (NOT HAS_C_ATTR_IFUNC) - message(STATUS "Compiler does not support ifunc attribute, cannot build fat runtime") - set (FAT_RUNTIME_REQUISITES FALSE) - else () - set (FAT_RUNTIME_REQUISITES TRUE) - endif() - endif() - if (NOT FAT_RUNTIME_REQUISITES OR NOT RELEASE_BUILD) - set (FAT_RUNTIME OFF) - endif() -endif () - # TODO: per platform config files? # remove CMake's idea of optimisation @@ -387,6 +361,32 @@ if (RELEASE_BUILD) endif() endif() +option(FAT_RUNTIME "Build a library that supports multiple microarchitectures" ON) +if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND FAT_RUNTIME MATCHES "ON") + # This is a Linux-only feature for now - requires platform support + # elsewhere + message(STATUS "generator is ${CMAKE_GENERATOR}") + if (CMAKE_C_COMPILER_IS_CLANG AND CMAKE_C_COMPILER_VERSION VERSION_LESS "3.9") + message (STATUS "Clang v3.9 or higher required for fat runtime, cannot build fat runtime") + set (FAT_RUNTIME_REQUISITES FALSE) + elseif (NOT (CMAKE_GENERATOR MATCHES "Unix Makefiles" OR + (CMAKE_VERSION VERSION_GREATER "3.0" AND CMAKE_GENERATOR MATCHES "Ninja"))) + message (STATUS "Building the fat runtime requires the Unix Makefiles generator, or Ninja with CMake v3.0 or higher") + set (FAT_RUNTIME_REQUISITES FALSE) + else() + include (${CMAKE_MODULE_PATH}/attrib.cmake) + if (NOT HAS_C_ATTR_IFUNC) + message(STATUS "Compiler does not support ifunc attribute, cannot build fat runtime") + set (FAT_RUNTIME_REQUISITES FALSE) + else () + set (FAT_RUNTIME_REQUISITES TRUE) + endif() + endif() + if (NOT FAT_RUNTIME_REQUISITES OR NOT RELEASE_BUILD) + set (FAT_RUNTIME OFF) + endif() +endif () + include (${CMAKE_MODULE_PATH}/arch.cmake) # testing a builtin takes a little more work