Skip to content

Commit 31206fc

Browse files
committed
cmake: Fix openbsd/freebsd error caused by CMP0137
CMake 3.24 started passing more compiler flags to try-compiler targets as described https://cmake.org/cmake/help/latest/policy/CMP0137.html. Revert to previous behavior by setting CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES Error is: + cmake /home/runner/work/libmultiprocess/libmultiprocess -G Ninja -- The CXX compiler identification is Clang 16.0.6 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - not found -- Check if compiler accepts -pthread -- Check if compiler accepts -pthread - no CMake Error at /usr/local/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:233 (message): Could NOT find Threads (missing: Threads_FOUND) Call Stack (most recent call first): /usr/local/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE) /usr/local/share/cmake/Modules/FindThreads.cmake:226 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:41 (find_package)
1 parent 6eafe4f commit 31206fc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cmake/compat_find.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@
1818
# been noticed upstream because it only affects CMake packages depending on
1919
# capnproto, not autoconf packages.
2020
set(FOUND_LIBATOMIC TRUE)
21+
22+
# Prevent env CXXFLAGS=-Werror from leaking into CMake's try-compile checks
23+
# and causing find_package(Threads REQUIRED) to fail on FreeBSD/OpenBSD.
24+
# In the future, prefer adding warning flags via an INTERFACE target rather
25+
# than environment variables.
26+
set(CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES TRUE)

0 commit comments

Comments
 (0)