Skip to content

Commit

Permalink
stable/2025: copy fix of pthread and sthread problems from master.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradbell committed Jan 24, 2025
1 parent 13003de commit a3af5aa
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
10 changes: 10 additions & 0 deletions appendix/whats_new/2025.xrst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ Release Notes for 2025
mm-dd
*****

01-24
=====
#. Fix linking the pthread examples ( e.g. :ref:`pthread_get_started.cpp-name` )
when the pthread library is in a non-standard location.

#. Fix linking the standard thread examples
( e.g. :ref:`sthread_get_started.cpp-name` )
when the standard thread library required the pthread library.


01-17
=====
#. Fix some errors of the form *function_name*\ ``(unsigned int)``
Expand Down
17 changes: 11 additions & 6 deletions example/multi_thread/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <[email protected]>
# SPDX-FileContributor: 2003-24 Bradley M. Bell
# SPDX-FileContributor: 2003-25 Bradley M. Bell
# ----------------------------------------------------------------------------

# initialize list as empty
Expand All @@ -14,18 +14,15 @@ SET(check_example_multi_thread_depends "")
# VARIABLE - variable to store the result
INCLUDE(CheckLibraryExists)

#
# sthread
ADD_SUBDIRECTORY(sthread)
#
# openmp
IF ( OpenMP_CXX_FOUND )
# OpenMP_CXX_FLAGS - flags to add to the CXX compiler for OpenMP support
ADD_SUBDIRECTORY(openmp)
ENDIF ( OpenMP_CXX_FOUND )
#
# pthread
SET(pthread_lib "pthread")
# pthread_lib_path
SET( pthread_ok FALSE )
FIND_LIBRARY(pthread_lib_path pthread)
MESSAGE(STATUS "pthread library path = ${pthread_lib_path}")
IF ( pthread_lib_path )
Expand All @@ -40,6 +37,14 @@ IF ( pthread_lib_path )
ADD_SUBDIRECTORY(pthread)
ENDIF ( pthread_ok )
ENDIF ( pthread_lib_path )
IF( NOT pthread_ok )
SET( pthread_lib_path "" )
ENDIF( NOT pthread_ok )
#
# sthread
# Put sthread after pthread because it can somtimes require pthread_lib_path
# https://stackoverflow.com/questions/46994982
ADD_SUBDIRECTORY(sthread)
#
# bthread
IF ( Boost_FOUND )
Expand Down
8 changes: 2 additions & 6 deletions example/multi_thread/pthread/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <[email protected]>
# SPDX-FileContributor: 2003-24 Bradley M. Bell
# SPDX-FileContributor: 2003-25 Bradley M. Bell
# ----------------------------------------------------------------------------
# Build the example/multi_thread/pthread directory tests
# Inherit build type from ../CMakeList.txt
Expand All @@ -27,15 +27,11 @@ set_compile_flags( example_multi_thread_pthread "${cppad_debug_which}" "${source
#
ADD_EXECUTABLE( example_multi_thread_pthread EXCLUDE_FROM_ALL ${source_list} )

# Paths in which the linker will search for libraries,
# only applies to targets created after it is called
LINK_DIRECTORIES( ${pthread_lib_path} )

# List of libraries to be linked into the specified target
TARGET_LINK_LIBRARIES(example_multi_thread_pthread
${cppad_lib}
${colpack_libs}
${pthread_lib}
${pthread_lib_path}
)

# check_example_multi_thread_pthread
Expand Down
3 changes: 2 additions & 1 deletion example/multi_thread/sthread/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <[email protected]>
# SPDX-FileContributor: 2003-24 Bradley M. Bell
# SPDX-FileContributor: 2003-25 Bradley M. Bell
# ----------------------------------------------------------------------------
# Build the example/multi_thread/sthread directory tests
# Inherit build type from ../CMakeList.txt
Expand Down Expand Up @@ -33,6 +33,7 @@ ADD_EXECUTABLE( example_multi_thread_sthread EXCLUDE_FROM_ALL ${source_list} )
TARGET_LINK_LIBRARIES(example_multi_thread_sthread
${cppad_lib}
${colpack_libs}
${pthread_lib_path}
)

# check_example_multi_thread_sthread
Expand Down

0 comments on commit a3af5aa

Please sign in to comment.