1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2025-01-29 02:29:57 +03:00

Improve the usage of cpu_features

- Add USE_SYSTEM_CPU_FEATURES flag to use system's cpu_features
  instead of the bundled one
- Allow the use of cpu_features for more architectures on Linux [1]

[1] https://github.com/google/cpu_features/tree/v0.9.0?tab=readme-ov-file#whats-supported
This commit is contained in:
Koichiro Iwao 2025-01-14 22:58:20 +09:00
parent 71b6aa7a8c
commit e2e8193495
2 changed files with 15 additions and 1 deletions

View File

@ -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

View File

@ -109,8 +109,19 @@ if(UNIX)
$<$<BOOL:${LIB_RT}>:${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)
target_link_libraries(mayaqua PRIVATE cpu_features)
else()
add_subdirectory(3rdparty/cpu_features)
set_property(TARGET cpu_features PROPERTY POSITION_INDEPENDENT_CODE ON)