1 # OpenThreads is a C++ based threading library. Its largest userbase
2 # seems to OpenSceneGraph so you might notice I accept OSGDIR as an
4 # I consider this part of the Findosg* suite used to find OpenSceneGraph
6 # Each component is separate and you must opt in to each module.
11 # OPENTHREADS_FOUND, if false, do not try to link to OpenThreads
12 # OPENTHREADS_INCLUDE_DIR, where to find the headers
14 # $OPENTHREADS_DIR is an environment variable that would
15 # correspond to the ./configure --prefix=$OPENTHREADS_DIR
16 # used in building osg.
18 # Created by Eric Wing.
20 # Header files are presumed to be included like
21 # #include <OpenThreads/Thread>
23 # To make it easier for one-step automated configuration/builds,
24 # we leverage environmental paths. This is preferable
25 # to the -DVAR=value switches because it insulates the
26 # users from changes we may make in this script.
27 # It also offers a little more flexibility than setting
28 # the CMAKE_*_PATH since we can target specific components.
29 # However, the default CMake behavior will search system paths
30 # before anything else. This is problematic in the cases
31 # where you have an older (stable) version installed, but
32 # are trying to build a newer version.
33 # CMake doesn't offer a nice way to globally control this behavior
34 # so we have to do a nasty "double FIND_" in this module.
35 # The first FIND disables the CMAKE_ search paths and only checks
36 # the environmental paths.
37 # If nothing is found, then the second find will search the
38 # standard install paths.
39 # Explicit -DVAR=value arguments should still be able to override everything.
41 find_path(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread
43 # enough environment variables?
44 $ENV{OPENTHREADS_INCLUDE_DIR}
49 $ENV{OpenThreads_ROOT}
53 /opt/local # DarwinPorts
61 find_library(OPENTHREADS_LIBRARY
62 NAMES OpenThreads OpenThreadsWin32
64 $ENV{OPENTHREADS_LIBRARY_DIR}
69 $ENV{OpenThreads_ROOT}
77 PATH_SUFFIXES lib64 lib
80 find_library(OPENTHREADS_LIBRARY_DEBUG
81 NAMES OpenThreadsd OpenThreadsWin32d
83 $ENV{OPENTHREADS_DEBUG_LIBRARY_DIR}
84 $ENV{OPENTHREADS_LIBRARY_DIR}
89 $ENV{OpenThreads_ROOT}
97 PATH_SUFFIXES lib64 lib
100 if(OPENTHREADS_LIBRARY_DEBUG)
101 set(OPENTHREADS_LIBRARIES
102 optimized ${OPENTHREADS_LIBRARY}
103 debug ${OPENTHREADS_LIBRARY_DEBUG})
105 set(OPENTHREADS_LIBRARIES ${OPENTHREADS_LIBRARY})
108 include(FindPackageHandleStandardArgs)
109 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenThreads DEFAULT_MSG
110 OPENTHREADS_LIBRARY OPENTHREADS_INCLUDE_DIR)