1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2025-10-03 11:01:30 +00:00

Fix build for NetBSD (and presumably DragonFly BSD)

These both use POSIX threads. I got a link error when cross-compiling
using Nixpkgs (Linux -> NetBSD) that went away once I passed `-pthread`.

The autoconf is crafted to have the same conditional as the C code itself.
This commit is contained in:
John Ericson 2023-05-19 00:57:27 -04:00 committed by The Tumultuous Unicorn Of Darkness
commit 09071d20f3
No known key found for this signature in database
GPG key ID: 1E55EE2EFF18BC1A
3 changed files with 40 additions and 0 deletions

View file

@ -21,6 +21,18 @@ option(LIBCPUID_TESTS "Enable building tests" OFF)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 99)
# pthreads library
if(${CMAKE_SYSTEM_NAME} STREQUAL "DragonFly" OR ${CMAKE_SYSTEM_NAME} STREQUAL "NetBSD")
find_package(Threads REQUIRED)
endif()
# check if popcount64 is available
include(CheckSymbolExists)
check_symbol_exists(popcount64 "string.h" HAVE_POPCOUNT64)
if(HAVE_POPCOUNT64)
add_definitions(-DHAVE_POPCOUNT64)
endif(HAVE_POPCOUNT64)
# Global variables
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")