Skip to content
Snippets Groups Projects
Commit df1c127d authored by Aaron Bray's avatar Aaron Bray
Browse files

Merge branch 'dev/find_pthreads_improvement' into 'iMSTK'

Support finding both debug and optimized pthread libraries

See merge request iMSTK/VegaFEM-CMake!2
parents 7bc1bda6 4d5b70be
No related branches found
No related tags found
No related merge requests found
find_path(PTHREAD_INCLUDE_DIR
pthread.h
)
set(PTHREAD_INCLUDE_DIR ${PTHREAD_INCLUDE_DIR})
find_library(PTHREAD_LIBRARY
find_library(PTHREAD_RELEASE_LIBRARY
NAMES
pthread
libpthread
)
set(PTHREAD_INCLUDE_DIRS "${PTHREAD_INCLUDE_DIR}")
set(PTHREAD_LIBRARIES "${PTHREAD_LIBRARY}")
if (EXISTS ${PTHREAD_RELEASE_LIBRARY})
list(APPEND PTHREAD_LIBRARIES optimized ${PTHREAD_RELEASE_LIBRARY})
endif()
find_library(PTHREAD_DEBUG_LIBRARY
NAMES
pthreadd
libpthreadd
)
if (EXISTS ${PTHREAD_DEBUG_LIBRARY})
list(APPEND PTHREAD_LIBRARIES debug ${PTHREAD_DEBUG_LIBRARY})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PTHREAD
REQUIRED_VARS
PTHREAD_INCLUDE_DIR
PTHREAD_LIBRARY)
PTHREAD_LIBRARIES)
mark_as_advanced(
PTHREAD_INCLUDE_DIR
PTHREAD_LIBRARY)
PTHREAD_DEBUG_LIBRARY
PTHREAD_RELEASE_LIBRARY)
if(PTHREAD_FOUND AND NOT TARGET Threads::Threads)
add_library(Threads::Threads INTERFACE IMPORTED)
set_target_properties(Threads::Threads PROPERTIES
INTERFACE_LINK_LIBRARIES "${PTHREAD_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${PTHREAD_INCLUDE_DIRS}")
target_include_directories(Threads::Threads INTERFACE "${PTHREAD_INCLUDE_DIR}")
if (EXISTS ${PTHREAD_DEBUG_LIBRARY})
target_link_libraries(Threads::Threads INTERFACE debug ${PTHREAD_DEBUG_LIBRARY})
endif()
if (EXISTS ${PTHREAD_RELEASE_LIBRARY})
target_link_libraries(Threads::Threads INTERFACE optimized ${PTHREAD_RELEASE_LIBRARY})
endif()
endif()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment