mirror of
https://github.com/anrieff/libcpuid
synced 2024-12-16 16:35:45 +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:
parent
f1c96e1372
commit
09071d20f3
3 changed files with 40 additions and 0 deletions
|
@ -21,6 +21,18 @@ option(LIBCPUID_TESTS "Enable building tests" OFF)
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
set(CMAKE_C_STANDARD 99)
|
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
|
# Global variables
|
||||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
|
|
27
configure.ac
27
configure.ac
|
@ -62,18 +62,45 @@ fi
|
||||||
|
|
||||||
AC_CANONICAL_HOST
|
AC_CANONICAL_HOST
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([Whether we need POSIX threads])
|
||||||
|
AC_COMPILE_IFELSE([
|
||||||
|
AC_LANG_PROGRAM([
|
||||||
|
#if defined(__NetBSD__) || defined(__DragonFly__)
|
||||||
|
#else
|
||||||
|
# error "no pthreads needed"
|
||||||
|
#endif
|
||||||
|
])
|
||||||
|
], [
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
AC_SUBST([LIBCPUID_LDFLAGS], ["-pthread"])
|
||||||
|
], [
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
])
|
||||||
|
|
||||||
build_windows=no
|
build_windows=no
|
||||||
|
build_netbsd=no
|
||||||
|
build_dragonflybsd=no
|
||||||
|
|
||||||
case "${host_os}" in
|
case "${host_os}" in
|
||||||
cygwin*|mingw*)
|
cygwin*|mingw*)
|
||||||
build_windows=yes
|
build_windows=yes
|
||||||
;;
|
;;
|
||||||
|
netbsd*)
|
||||||
|
build_netbsd=yes
|
||||||
|
;;
|
||||||
|
dragonfly*)
|
||||||
|
build_dragonflybsd=yes
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if test "$build_windows" = "no"; then
|
if test "$build_windows" = "no"; then
|
||||||
AM_CPPFLAGS="$AM_CPPFLAGS -D_GNU_SOURCE"
|
AM_CPPFLAGS="$AM_CPPFLAGS -D_GNU_SOURCE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test "$build_netbsd" = "yes" || test "$build_dragonflybsd" = "yes"; then
|
||||||
|
AM_LDFLAGS="$AM_LDFLAGS -pthread"
|
||||||
|
fi
|
||||||
|
|
||||||
AM_CONDITIONAL([WINDOWS], [test "$build_windows" = "yes"])
|
AM_CONDITIONAL([WINDOWS], [test "$build_windows" = "yes"])
|
||||||
|
|
||||||
AC_SUBST(AM_CPPFLAGS)
|
AC_SUBST(AM_CPPFLAGS)
|
||||||
|
|
|
@ -23,6 +23,7 @@ add_library(cpuid ${cpuid_sources})
|
||||||
set_property(TARGET cpuid PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
set_property(TARGET cpuid PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||||
target_include_directories(cpuid SYSTEM PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
target_include_directories(cpuid SYSTEM PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
||||||
|
|
||||||
|
target_link_libraries(cpuid ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_compile_definitions(cpuid PRIVATE VERSION="${PROJECT_VERSION}")
|
target_compile_definitions(cpuid PRIVATE VERSION="${PROJECT_VERSION}")
|
||||||
set_target_properties(cpuid PROPERTIES VERSION "${LIBCPUID_CURRENT}.${LIBCPUID_AGE}.${LIBCPUID_REVISION}")
|
set_target_properties(cpuid PROPERTIES VERSION "${LIBCPUID_CURRENT}.${LIBCPUID_AGE}.${LIBCPUID_REVISION}")
|
||||||
set_target_properties(cpuid PROPERTIES SOVERSION "${LIBCPUID_CURRENT}")
|
set_target_properties(cpuid PROPERTIES SOVERSION "${LIBCPUID_CURRENT}")
|
||||||
|
|
Loading…
Reference in a new issue