Skip to content

Commit 5102588

Browse files
committed
Attempt 3 to address issues with pthreads needed only for certain systems
1 parent aac3399 commit 5102588

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

cmake/thirdpartylibraries/SetupThirdPartyLibraries.cmake

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ endif()
144144
################################
145145
# Threads (platform-specific)
146146
################################
147+
148+
set(EXACONSTIT_THREADS_EXPLICIT_LINK FALSE CACHE INTERNAL "Whether explicit thread linking is required")
149+
147150
if(UNIX AND NOT APPLE)
148151
find_package(Threads REQUIRED)
149152
include(CheckCXXSourceCompiles)
@@ -194,14 +197,7 @@ if(UNIX AND NOT APPLE)
194197
# Register if needed
195198
if(NOT THREADS_IMPLICIT_LINK)
196199
message(STATUS " Result: Explicit pthread linking REQUIRED")
197-
198-
if(TARGET Threads::Threads)
199-
blt_import_library(NAME threads
200-
LIBRARIES Threads::Threads)
201-
else()
202-
blt_import_library(NAME threads
203-
LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
204-
endif()
200+
set(EXACONSTIT_THREADS_EXPLICIT_LINK TRUE CACHE INTERNAL "Whether explicit thread linking is required")
205201
else()
206202
message(STATUS " Result: pthread implicitly linked (no action needed)")
207203
endif()

src/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ endif()
8282
set(EXACONSTIT_DEPENDS)
8383

8484
exaconstit_fill_depends_list(LIST_NAME EXACONSTIT_DEPENDS
85-
DEPENDS_ON mfem ecmech snls RAJA camp mpi threads)
85+
DEPENDS_ON mfem ecmech snls RAJA camp mpi)
8686

8787
if (${BLT_VERSION} VERSION_GREATER_EQUAL 0.6.0)
8888
if(ENABLE_CUDA)
@@ -112,6 +112,13 @@ if(ENABLE_CALIPER)
112112
list(APPEND EXACONSTIT_DEPENDS caliper)
113113
endif()
114114

115+
if(UNIX AND NOT APPLE AND TARGET Threads::Threads)
116+
# Check if we determined explicit linking is needed
117+
if(EXACONSTIT_THREADS_EXPLICIT_LINK)
118+
list(APPEND EXACONSTIT_DEPENDS Threads::Threads)
119+
endif()
120+
endif()
121+
115122
list(APPEND EXACONSTIT_DEPENDS ${DYNAMIC_LOADING_LIBS})
116123

117124
message("-- EXACONSTIT_DEPENDS: ${EXACONSTIT_DEPENDS}")

0 commit comments

Comments
 (0)