Skip to content

Commit

Permalink
Merge pull request #1164 from mathstuf/cmake-pthread-mutex-recursive-…
Browse files Browse the repository at this point in the history
…detection

cmake: detect PTHREAD_MUTEX_RECURSIVE by compiling
  • Loading branch information
kbevers authored Oct 27, 2018
2 parents f5ccbae + 2437bbb commit 22c52cf
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package (Threads)

include(CheckIncludeFiles)
include(CheckSymbolExists)
CHECK_SYMBOL_EXISTS(PTHREAD_MUTEX_RECURSIVE pthread.h HAVE_PTHREAD_MUTEX_RECURSIVE_DEFN)
if (HAVE_PTHREAD_MUTEX_RECURSIVE_DEFN)
add_definitions(-DHAVE_PTHREAD_MUTEX_RECURSIVE=1)
endif()

include (CheckCSourceCompiles)
if (MSVC)
Expand All @@ -112,6 +107,22 @@ else ()
add_definitions (-DHAVE_C99_MATH=0)
endif ()

if (Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}")
check_c_source_compiles("
#include <pthread.h>
int main(int argc, char* argv[]) {
(void)PTHREAD_MUTEX_RECURSIVE;
(void)argv;
return argc;
}
" HAVE_PTHREAD_MUTEX_RECURSIVE_DEFN)
if (HAVE_PTHREAD_MUTEX_RECURSIVE_DEFN)
add_definitions(-DHAVE_PTHREAD_MUTEX_RECURSIVE=1)
endif()
endif ()

boost_report_value(PROJ_PLATFORM_NAME)
boost_report_value(PROJ_COMPILER_NAME)

Expand Down

0 comments on commit 22c52cf

Please sign in to comment.