diff --git a/.cirrus.yml b/.cirrus.yml index fc939cbc..339ae243 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -13,10 +13,10 @@ FreeBSD_task: freebsd_instance: image_family: freebsd-14-2 prepare_script: - - pkg install -y pkgconf cmake git libsodium $SSL + - pkg install -y pkgconf cmake git libsodium cpu_features $SSL - git submodule update --init --recursive configure_script: - - ./configure + - CMAKE_FLAGS="-DUSE_SYSTEM_CPU_FEATURES=1" CFLAGS="-I/usr/local/include/cpu_features" ./configure build_script: - make -j $(sysctl -n hw.ncpu || echo 4) -C build test_script: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c49a3c78..8f9f9843 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -127,6 +127,9 @@ if(UNIX) if(SE_PIDDIR) add_definitions(-DSE_PIDDIR="${SE_PIDDIR}") endif() + + # Use system libraries instead of bundled + set(USE_SYSTEM_CPU_FEATURES false CACHE BOOL "Use system cpu_features") endif() # Cedar communication module diff --git a/src/Mayaqua/3rdparty/cpu_features b/src/Mayaqua/3rdparty/cpu_features index 26133d3b..ba4bffa8 160000 --- a/src/Mayaqua/3rdparty/cpu_features +++ b/src/Mayaqua/3rdparty/cpu_features @@ -1 +1 @@ -Subproject commit 26133d3b620c2c27f31d571efd27371100f891e9 +Subproject commit ba4bffa86cbb5456bdb34426ad22b9551278e2c0 diff --git a/src/Mayaqua/CMakeLists.txt b/src/Mayaqua/CMakeLists.txt index 51acec0b..9418b824 100644 --- a/src/Mayaqua/CMakeLists.txt +++ b/src/Mayaqua/CMakeLists.txt @@ -109,8 +109,21 @@ if(UNIX) $<$:${LIB_RT}> ) - if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv7l|aarch64|s390x)$" OR NOT HAVE_SYS_AUXV OR SKIP_CPU_FEATURES) + if (NOT HAVE_SYS_AUXV OR SKIP_CPU_FEATURES) add_definitions(-DSKIP_CPU_FEATURES) + elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(amd64|i386)") + message("cpu_features is not available on FreeBSD/${CMAKE_SYSTEM_PROCESSOR}") + add_definitions(-DSKIP_CPU_FEATURES) + elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" AND NOT CMAKE_SYSTEM_NAME MATCHES "^(arm64|x86_64)") + # macOS runs only on Intel or ARM architecrues, should not reach here + add_definitions(-DSKIP_CPU_FEATURES) + elseif(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" OR ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") + message("cpu_features is not available on ${CMAKE_SYSTEM_NAME}") + add_definitions(-DSKIP_CPU_FEATURES) + elseif(USE_SYSTEM_CPU_FEATURES) + CHECK_INCLUDE_FILE(cpu_features_macros.h HAVE_CPU_FEATURES) + message("-- Using system's cpu_features") + target_link_libraries(mayaqua PRIVATE cpu_features) else() add_subdirectory(3rdparty/cpu_features) set_property(TARGET cpu_features PROPERTY POSITION_INDEPENDENT_CODE ON)