Prompted by a mail from "EdaSky"

(http://marc.info/?l=openbsd-misc&m=143552406830762):

automagically add pthread to Boost_LIBRARIES and '-pthread' to
compiler flags if the boost_thread component is requested.

Fix boost_thread's "Compiler threading support is not turned on,
please set the correct command line options for threading" error
without the need to tamper with CMAKE_CXX_FLAGS.

Based on a patch found in the Debian package for cmake, which I've
enhanced/modernized a bit.
This commit is contained in:
dcoppa 2015-07-01 08:08:18 +00:00
parent 6af7a54149
commit 3c70fd267f
3 changed files with 39 additions and 4 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.128 2015/06/24 06:39:03 dcoppa Exp $
# $OpenBSD: Makefile,v 1.129 2015/07/01 08:08:18 dcoppa Exp $
DPB_PROPERTIES =parallel
@ -11,7 +11,7 @@ COMMENT = portable build system
VER = 3.2.3
DISTNAME = cmake-${VER}
REVISION = 0
REVISION = 1
CATEGORIES = devel
HOMEPAGE = http://www.cmake.org/

View File

@ -1,6 +1,6 @@
# $OpenBSD: cmake.port.mk,v 1.45 2015/06/24 06:39:03 dcoppa Exp $
# $OpenBSD: cmake.port.mk,v 1.46 2015/07/01 08:08:18 dcoppa Exp $
BUILD_DEPENDS+= devel/cmake>=3.2.3p0
BUILD_DEPENDS+= devel/cmake>=3.2.3p1
.for _n _v in ${SHARED_LIBS}
CONFIGURE_ENV+=LIB${_n}_VERSION=${_v}

View File

@ -0,0 +1,35 @@
$OpenBSD: patch-Modules_FindBoost_cmake,v 1.7 2015/07/01 08:08:18 dcoppa Exp $
--- Modules/FindBoost.cmake.orig Mon Jun 1 17:56:08 2015
+++ Modules/FindBoost.cmake Wed Jul 1 08:07:12 2015
@@ -447,6 +447,22 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret)
set(${_ret} ${_boost_COMPILER} PARENT_SCOPE)
endfunction()
+function(_Boost_consider_adding_pthread _outvar)
+ # On Unix platforms (excluding Cygwin) add pthread to Boost_LIBRARIES
+ # if the user is searching for the boost-thread component.
+ if(UNIX AND NOT CYGWIN)
+ list(FIND Boost_FIND_COMPONENTS thread _using_boost_thread)
+ if(_using_boost_thread GREATER -1)
+ set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
+ set(THREADS_PREFER_PTHREAD_FLAG TRUE)
+ find_package(Threads)
+ if(Threads_FOUND)
+ set(${_outvar} ${ARGN} Threads::Threads PARENT_SCOPE)
+ endif()
+ endif()
+ endif()
+endfunction()
+
#
# End functions/macros
#
@@ -1177,6 +1193,8 @@ if(Boost_FOUND)
list(APPEND Boost_LIBRARIES ${Boost_${UPPERCOMPONENT}_LIBRARY})
endif()
endforeach()
+ # Add pthread library if thread component was found
+ _Boost_consider_adding_pthread(Boost_LIBRARIES ${Boost_LIBRARIES})
else()
if(Boost_FIND_REQUIRED)
message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")