1# Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2# file Copyright.txt or https://cmake.org/licensing for details. 3 4#[=======================================================================[.rst: 5FindOpenThreads 6--------------- 7 8 9 10OpenThreads is a C++ based threading library. Its largest userbase 11seems to OpenSceneGraph so you might notice I accept OSGDIR as an 12environment path. I consider this part of the Findosg* suite used to 13find OpenSceneGraph components. Each component is separate and you 14must opt in to each module. 15 16Locate OpenThreads This module defines OPENTHREADS_LIBRARY 17OPENTHREADS_FOUND, if false, do not try to link to OpenThreads 18OPENTHREADS_INCLUDE_DIR, where to find the headers 19 20$OPENTHREADS_DIR is an environment variable that would correspond to 21the ./configure --prefix=$OPENTHREADS_DIR used in building osg. 22 23[CMake 2.8.10]: The CMake variables OPENTHREADS_DIR or OSG_DIR can now 24be used as well to influence detection, instead of needing to specify 25an environment variable. 26 27Created by Eric Wing. 28#]=======================================================================] 29 30# Header files are presumed to be included like 31# #include <OpenThreads/Thread> 32 33# To make it easier for one-step automated configuration/builds, 34# we leverage environmental paths. This is preferable 35# to the -DVAR=value switches because it insulates the 36# users from changes we may make in this script. 37# It also offers a little more flexibility than setting 38# the CMAKE_*_PATH since we can target specific components. 39# However, the default CMake behavior will search system paths 40# before anything else. This is problematic in the cases 41# where you have an older (stable) version installed, but 42# are trying to build a newer version. 43# CMake doesn't offer a nice way to globally control this behavior 44# so we have to do a nasty "double FIND_" in this module. 45# The first FIND disables the CMAKE_ search paths and only checks 46# the environmental paths. 47# If nothing is found, then the second find will search the 48# standard install paths. 49# Explicit -DVAR=value arguments should still be able to override everything. 50 51include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) 52 53find_path(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread 54 HINTS 55 ENV OPENTHREADS_INCLUDE_DIR 56 ENV OPENTHREADS_DIR 57 ENV OSG_INCLUDE_DIR 58 ENV OSG_DIR 59 ENV OSGDIR 60 ENV OpenThreads_ROOT 61 ENV OSG_ROOT 62 ${OPENTHREADS_DIR} 63 ${OSG_DIR} 64 PATH_SUFFIXES include 65) 66 67 68find_library(OPENTHREADS_LIBRARY_RELEASE 69 NAMES OpenThreads OpenThreadsWin32 70 HINTS 71 ENV OPENTHREADS_LIBRARY_DIR 72 ENV OPENTHREADS_DIR 73 ENV OSG_LIBRARY_DIR 74 ENV OSG_DIR 75 ENV OSGDIR 76 ENV OpenThreads_ROOT 77 ENV OSG_ROOT 78 ${OPENTHREADS_DIR} 79 ${OSG_DIR} 80 PATH_SUFFIXES lib 81) 82 83find_library(OPENTHREADS_LIBRARY_DEBUG 84 NAMES OpenThreadsd OpenThreadsWin32d 85 HINTS 86 ENV OPENTHREADS_DEBUG_LIBRARY_DIR 87 ENV OPENTHREADS_LIBRARY_DIR 88 ENV OPENTHREADS_DIR 89 ENV OSG_LIBRARY_DIR 90 ENV OSG_DIR 91 ENV OSGDIR 92 ENV OpenThreads_ROOT 93 ENV OSG_ROOT 94 ${OPENTHREADS_DIR} 95 ${OSG_DIR} 96 PATH_SUFFIXES lib 97) 98 99select_library_configurations(OPENTHREADS) 100 101include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) 102FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenThreads DEFAULT_MSG 103 OPENTHREADS_LIBRARY OPENTHREADS_INCLUDE_DIR) 104