Skip to content

Commit

Permalink
[build] First try to find_package pthreads on Win
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko authored and rndi committed Sep 3, 2019
1 parent f426e9d commit ef9101c
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -453,19 +453,23 @@ if (PTHREAD_LIBRARY AND PTHREAD_INCLUDE_DIR)
message(STATUS "Pthread library: ${PTHREAD_LIBRARY}")
message(STATUS "Pthread include dir: ${PTHREAD_INCLUDE_DIR}")
elseif (WIN32 AND NOT MINGW)
# find pthread
find_path(PTHREAD_INCLUDE_DIR pthread.h HINTS C:/pthread-win32/include)
if (PTHREAD_INCLUDE_DIR)
message(STATUS "Pthread include dir: ${PTHREAD_INCLUDE_DIR}")
else()
message(FATAL_ERROR "Failed to find pthread.h. Specify PTHREAD_INCLUDE_DIR.")
endif()
find_package(pthreads QUIET)

find_library(PTHREAD_LIBRARY NAMES pthread pthread_dll pthread_lib HINTS C:/pthread-win32/lib C:/pthread-win64/lib)
if (PTHREAD_LIBRARY)
message(STATUS "Pthread library: ${PTHREAD_LIBRARY}")
else()
message(FATAL_ERROR "Failed to find pthread library. Specify PTHREAD_LIBRARY.")
if (NOT PTHREAD_INCLUDE_DIR OR NOT PTHREAD_LIBRARY)
# find pthread
find_path(PTHREAD_INCLUDE_DIR pthread.h HINTS C:/pthread-win32/include)
if (PTHREAD_INCLUDE_DIR)
message(STATUS "Pthread include dir: ${PTHREAD_INCLUDE_DIR}")
else()
message(FATAL_ERROR "Failed to find pthread.h. Specify PTHREAD_INCLUDE_DIR.")
endif()

find_library(PTHREAD_LIBRARY NAMES pthread pthread_dll pthread_lib HINTS C:/pthread-win32/lib C:/pthread-win64/lib)
if (PTHREAD_LIBRARY)
message(STATUS "Pthread library: ${PTHREAD_LIBRARY}")
else()
message(FATAL_ERROR "Failed to find pthread library. Specify PTHREAD_LIBRARY.")
endif()
endif()
else ()
find_package(Threads REQUIRED)
Expand Down

0 comments on commit ef9101c

Please sign in to comment.