Revision: 77653
http://sourceforge.net/p/brlcad/code/77653
Author: starseeker
Date: 2020-10-28 01:56:50 +0000 (Wed, 28 Oct 2020)
Log Message:
-----------
Update to more modern find_package(Threads) style
Modified Paths:
--------------
brlcad/branches/extbuild/CMakeLists.txt
brlcad/branches/extbuild/misc/tools/env2c/CMakeLists.txt
brlcad/branches/extbuild/regress/coverage/CMakeLists.txt
brlcad/branches/extbuild/regress/pkg/CMakeLists.txt
brlcad/branches/extbuild/regress/repository/CMakeLists.txt
brlcad/branches/extbuild/src/art/CMakeLists.txt
brlcad/branches/extbuild/src/libbu/CMakeLists.txt
brlcad/branches/extbuild/src/other/ext/bson/CMakeLists.txt
brlcad/branches/extbuild/src/other/ext/gdal/CMakeLists.txt
brlcad/branches/extbuild/src/rt/CMakeLists.txt
brlcad/branches/extbuild/src/rtwizard/CMakeLists.txt
Modified: brlcad/branches/extbuild/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/CMakeLists.txt 2020-10-28 01:32:37 UTC (rev
77652)
+++ brlcad/branches/extbuild/CMakeLists.txt 2020-10-28 01:56:50 UTC (rev
77653)
@@ -790,6 +790,7 @@
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
endif (PROBE_PTHREAD_H_CLOCKID_T)
endif (NOT PROBE_PTHREAD_H)
+ set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
# -O3/-Ofast can enable -ffast-math which can provoke a stack
# corruption in the shadow computations because of strict aliasing
@@ -1202,9 +1203,17 @@
# be referenced in a pkgconfig file
# Look for threads (doesn't check for headers)
-# The variable CMAKE_THREAD_LIBS_INIT is the one of interest
-# when writing target_link_libraries lists.
+# Post 3.1 CMake has switched to recommending using an imported target
+# and setting a "prefer pthreads" flag - previously we were using the
+# CMAKE_THREAD_LIBS_INIT variable
+set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
+# By default, the Threads package doesn't stash any of its values in
+# cache. This is inconvenient for debugging, so we set them ourselves.
+set(CMAKE_THREAD_LIBS_INIT ${CMAKE_THREAD_LIBS_INIT} CACHE STRING "Threads")
+set(CMAKE_USE_WIN32_THREADS_INIT ${CMAKE_USE_WIN32_THREADS_INIT} CACHE STRING
"Threads")
+set(CMAKE_USE_PTHREADS_INIT ${CMAKE_USE_PTHREADS_INIT} CACHE STRING "Threads")
+set(CMAKE_HP_PTHREADS_INIT ${CMAKE_HP_PTHREADS_INIT} CACHE STRING "Threads")
# Check for the C++ STL library - need to link it explicitly in
# some compilation situations
Modified: brlcad/branches/extbuild/misc/tools/env2c/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/misc/tools/env2c/CMakeLists.txt 2020-10-28
01:32:37 UTC (rev 77652)
+++ brlcad/branches/extbuild/misc/tools/env2c/CMakeLists.txt 2020-10-28
01:56:50 UTC (rev 77653)
@@ -55,7 +55,7 @@
target_compile_options(env2c PRIVATE "-O3")
endif (O3_COMPILER_FLAG)
-target_link_libraries(env2c ${CMAKE_THREAD_LIBS_INIT})
+target_link_libraries(env2c Threads::Threads)
# Local Variables:
# tab-width: 8
Modified: brlcad/branches/extbuild/regress/coverage/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/regress/coverage/CMakeLists.txt 2020-10-28
01:32:37 UTC (rev 77652)
+++ brlcad/branches/extbuild/regress/coverage/CMakeLists.txt 2020-10-28
01:56:50 UTC (rev 77653)
@@ -24,7 +24,7 @@
endforeach(rf ${REGRESS_FILES_CMAKE})
# Build a scanner to introspect the tests
-BRLCAD_ADDEXEC(covgcheck covgcheck.cpp "libbu;${CMAKE_THREAD_LIBS_INIT}" TEST)
+BRLCAD_ADDEXEC(covgcheck covgcheck.cpp "libbu;Threads::Threads" TEST)
if (O3_COMPILER_FLAG)
# This check benefits greatly from optimization. If we have the O3 flag, use
# it - whether or not the standard build settings would add it.
Modified: brlcad/branches/extbuild/regress/pkg/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/regress/pkg/CMakeLists.txt 2020-10-28 01:32:37 UTC
(rev 77652)
+++ brlcad/branches/extbuild/regress/pkg/CMakeLists.txt 2020-10-28 01:56:50 UTC
(rev 77653)
@@ -5,7 +5,7 @@
${PKG_INCLUDE_DIRS}
)
-BRLCAD_ADDEXEC(regress_pkg regress_pkg.cpp
"libpkg;libbu;${CMAKE_THREAD_LIBS_INIT}" NO_INSTALL)
+BRLCAD_ADDEXEC(regress_pkg regress_pkg.cpp "libpkg;libbu;Threads::Threads"
NO_INSTALL)
set_target_properties(regress_pkg PROPERTIES FOLDER "BRL-CAD Regression
Tests/libpkg")
BRLCAD_REGRESSION_TEST(regress-pkg "regress_pkg" EXEC regress_pkg STAND_ALONE)
Modified: brlcad/branches/extbuild/regress/repository/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/regress/repository/CMakeLists.txt 2020-10-28
01:32:37 UTC (rev 77652)
+++ brlcad/branches/extbuild/regress/repository/CMakeLists.txt 2020-10-28
01:56:50 UTC (rev 77653)
@@ -5,7 +5,7 @@
# Build a scanner to check the repository for various problems
-BRLCAD_ADDEXEC(repocheck "repocheck.cpp;strnstr.c"
"libbu;${CMAKE_THREAD_LIBS_INIT}" TEST)
+BRLCAD_ADDEXEC(repocheck "repocheck.cpp;strnstr.c" "libbu;Threads::Threads"
TEST)
if (O3_COMPILER_FLAG)
# This check benefits greatly from optimization. If we have the O3 flag, use
# it - whether or not the standard build settings would add it.
Modified: brlcad/branches/extbuild/src/art/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/src/art/CMakeLists.txt 2020-10-28 01:32:37 UTC
(rev 77652)
+++ brlcad/branches/extbuild/src/art/CMakeLists.txt 2020-10-28 01:56:50 UTC
(rev 77653)
@@ -9,7 +9,7 @@
BRLCAD_INCLUDE_DIRS(ART_INCLUDE_DIRS)
set(RT_STD_LIBS
- ${CMAKE_THREAD_LIBS_INIT}
+ Threads::Threads
librt
libnmg
libdm
Modified: brlcad/branches/extbuild/src/libbu/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/src/libbu/CMakeLists.txt 2020-10-28 01:32:37 UTC
(rev 77652)
+++ brlcad/branches/extbuild/src/libbu/CMakeLists.txt 2020-10-28 01:56:50 UTC
(rev 77653)
@@ -141,7 +141,7 @@
CMAKEFILES(parallel_cpp11thread.cpp)
endif(NOT CMAKE_CXX_STANDARD EQUAL 98)
-BRLCAD_ADDLIB(libbu "${LIBBU_SOURCES}"
"${Foundation_LIBRARIES};${CMAKE_THREAD_LIBS_INIT};${DL_LIBRARY};${WINSOCK_LIB};${PSAPI_LIB};${BSON_LIBRARIES};${UUID_LIBRARIES};${M_LIBRARY}")
+BRLCAD_ADDLIB(libbu "${LIBBU_SOURCES}"
"${Foundation_LIBRARIES};Threads::Threads;${DL_LIBRARY};${WINSOCK_LIB};${PSAPI_LIB};${BSON_LIBRARIES};${UUID_LIBRARIES};${M_LIBRARY}")
set_target_properties(libbu PROPERTIES VERSION 20.0.1 SOVERSION 20)
# Define a pre-build test for libbu to check the semaphores in BRL-CAD's
headers for
Modified: brlcad/branches/extbuild/src/other/ext/bson/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/src/other/ext/bson/CMakeLists.txt 2020-10-28
01:32:37 UTC (rev 77652)
+++ brlcad/branches/extbuild/src/other/ext/bson/CMakeLists.txt 2020-10-28
01:56:50 UTC (rev 77653)
@@ -214,8 +214,8 @@
endif()
if (UNIX)
- target_link_libraries (bson_shared ${CMAKE_THREAD_LIBS_INIT})
- target_link_libraries (bson_static ${CMAKE_THREAD_LIBS_INIT})
+ target_link_libraries (bson_shared Threads::Threads)
+ target_link_libraries (bson_static Threads::Threads)
else()
target_link_libraries (bson_shared ws2_32)
target_link_libraries (bson_static ws2_32)
Modified: brlcad/branches/extbuild/src/other/ext/gdal/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/src/other/ext/gdal/CMakeLists.txt 2020-10-28
01:32:37 UTC (rev 77652)
+++ brlcad/branches/extbuild/src/other/ext/gdal/CMakeLists.txt 2020-10-28
01:56:50 UTC (rev 77653)
@@ -368,7 +368,7 @@
set_target_properties(ogr_frmt_${frmt} PROPERTIES FOLDER "Third Party
Libraries/GDAL")
endforeach(frmt ${OGR_FORMATS})
-set(gdal_libs ${PROJ4_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})
+set(gdal_libs ${PROJ4_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES}
Threads::Threads)
set(lib_list M DL ICONV)
foreach(ll ${lib_list})
if(${ll}_LIBRARY)
Modified: brlcad/branches/extbuild/src/rt/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/src/rt/CMakeLists.txt 2020-10-28 01:32:37 UTC
(rev 77652)
+++ brlcad/branches/extbuild/src/rt/CMakeLists.txt 2020-10-28 01:56:50 UTC
(rev 77653)
@@ -31,7 +31,7 @@
if(MPI_C_LIBRARIES AND BRLCAD_ENABLE_MPI)
set(RT_STD_LIBS
- ${CMAKE_THREAD_LIBS_INIT}
+ Threads::Threads
${MPI_C_LIBRARIES}
librt
libnmg
@@ -41,7 +41,7 @@
)
else()
set(RT_STD_LIBS
- ${CMAKE_THREAD_LIBS_INIT}
+ Threads::Threads
librt
libnmg
liboptical
@@ -54,12 +54,12 @@
BRLCAD_ADDEXEC(rtexample "rtexample.c" "librt;libdm;liboptical;libicv"
NO_INSTALL)
-BRLCAD_ADDEXEC(reshoot "reshoot.c"
"${CMAKE_THREAD_LIBS_INIT};librt;libdm;liboptical;libicv")
+BRLCAD_ADDEXEC(reshoot "reshoot.c"
"Threads::Threads;librt;libdm;liboptical;libicv")
BRLCAD_ADDEXEC(rtshot "rtshot.c" "${RT_STD_LIBS};libdm")
ADD_TARGET_DEPS(rtshot dm_plugins)
-BRLCAD_ADDEXEC(rtscale "read-rtlog.c;rtscale.c"
"${CMAKE_THREAD_LIBS_INIT};librt;libdm;liboptical;libicv;${M_LIBRARY}")
+BRLCAD_ADDEXEC(rtscale "read-rtlog.c;rtscale.c"
"Threads::Threads;librt;libdm;liboptical;libicv;${M_LIBRARY}")
ADD_TARGET_DEPS(rtscale dm_plugins)
BRLCAD_ADDEXEC(rt "${LIBRTUIF_SOURCES};view.c"
"${OPENCL_LIBS};${RT_STD_LIBS};libdm")
Modified: brlcad/branches/extbuild/src/rtwizard/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/src/rtwizard/CMakeLists.txt 2020-10-28
01:32:37 UTC (rev 77652)
+++ brlcad/branches/extbuild/src/rtwizard/CMakeLists.txt 2020-10-28
01:56:50 UTC (rev 77653)
@@ -20,7 +20,7 @@
endif (HAVE_WINDOWS_H)
- BRLCAD_ADDEXEC(rtwizard "${RTWIZARD_SRCS}"
"libtclcad;librt;libdm;liboptical;libicv;${ITCL_LIBRARY};${ITK_LIBRARY};${CMAKE_THREAD_LIBS_INIT};${M_LIBRARY}")
+ BRLCAD_ADDEXEC(rtwizard "${RTWIZARD_SRCS}"
"libtclcad;librt;libdm;liboptical;libicv;${ITCL_LIBRARY};${ITK_LIBRARY};Threads::Threads;${M_LIBRARY}")
ADD_TARGET_DEPS(rtwizard rt rtedge fbserv fb-png fb-pix fbclear fblabel
fbfree fbline fb-fb pix-bw bwmod bw-pix pixmatte pix-fb tkpng dm_plugins)
foreach(item ${tclindex_target_list})
add_dependencies(rtwizard ${item})
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits