Updated formatting of documentation plus a little reorganization.
[cmake.git] / Modules / FindOpenThreads.cmake
blob3fe44b5764708e3d57491aa0c26165673590f217
1 # OpenThreads is a C++ based threading library. Its largest userbase 
2 # seems to OpenSceneGraph so you might notice I accept OSGDIR as an
3 # environment path.
4 # I consider this part of the Findosg* suite used to find OpenSceneGraph 
5 # components.
6 # Each component is separate and you must opt in to each module.
7
8 # Locate OpenThreads
9 # This module defines
10 # OPENTHREADS_LIBRARY
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
42     HINTS
43         # enough environment variables?
44         $ENV{OPENTHREADS_INCLUDE_DIR}
45         $ENV{OPENTHREADS_DIR}
46         $ENV{OSG_INCLUDE_DIR}
47         $ENV{OSG_DIR}
48         $ENV{OSGDIR}
49         $ENV{OpenThreads_ROOT}
50         $ENV{OSG_ROOT}
51     PATHS
52         /sw # Fink
53         /opt/local # DarwinPorts
54         /opt/csw # Blastwave
55         /opt
56         /usr/freeware
57     PATH_SUFFIXES include
61 find_library(OPENTHREADS_LIBRARY 
62     NAMES OpenThreads OpenThreadsWin32 
63     HINTS
64         $ENV{OPENTHREADS_LIBRARY_DIR}
65         $ENV{OPENTHREADS_DIR}
66         $ENV{OSG_LIBRARY_DIR}
67         $ENV{OSG_DIR}
68         $ENV{OSGDIR}
69         $ENV{OpenThreads_ROOT}
70         $ENV{OSG_ROOT}
71     PATHS
72         /sw
73         /opt/local
74         /opt/csw
75         /opt
76         /usr/freeware
77     PATH_SUFFIXES lib64 lib
80 find_library(OPENTHREADS_LIBRARY_DEBUG 
81     NAMES OpenThreadsd OpenThreadsWin32d
82     HINTS
83         $ENV{OPENTHREADS_DEBUG_LIBRARY_DIR}
84         $ENV{OPENTHREADS_LIBRARY_DIR}
85         $ENV{OPENTHREADS_DIR}
86         $ENV{OSG_LIBRARY_DIR}
87         $ENV{OSG_DIR}
88         $ENV{OSGDIR}
89         $ENV{OpenThreads_ROOT}
90         $ENV{OSG_ROOT}
91     PATHS
92         /sw
93         /opt/local
94         /opt/csw
95         /opt
96         /usr/freeware
97     PATH_SUFFIXES lib64 lib
100 if(OPENTHREADS_LIBRARY_DEBUG)
101     set(OPENTHREADS_LIBRARIES
102         optimized ${OPENTHREADS_LIBRARY}
103         debug ${OPENTHREADS_LIBRARY_DEBUG})
104 else()
105     set(OPENTHREADS_LIBRARIES ${OPENTHREADS_LIBRARY})
106 endif()
108 include(FindPackageHandleStandardArgs)
109 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenThreads DEFAULT_MSG
110     OPENTHREADS_LIBRARY OPENTHREADS_INCLUDE_DIR)