FindOpenThreads.cmake 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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
  13. #
  14. # $OPENTHREADS_DIR is an environment variable that would
  15. # correspond to the ./configure --prefix=$OPENTHREADS_DIR
  16. # used in building osg.
  17. #
  18. # Created by Eric Wing.
  19. # Header files are presumed to be included like
  20. # #include <OpenThreads/Thread>
  21. # To make it easier for one-step automated configuration/builds,
  22. # we leverage environmental paths. This is preferable
  23. # to the -DVAR=value switches because it insulates the
  24. # users from changes we may make in this script.
  25. # It also offers a little more flexibility than setting
  26. # the CMAKE_*_PATH since we can target specific components.
  27. # However, the default CMake behavior will search system paths
  28. # before anything else. This is problematic in the cases
  29. # where you have an older (stable) version installed, but
  30. # are trying to build a newer version.
  31. # CMake doesn't offer a nice way to globally control this behavior
  32. # so we have to do a nasty "double FIND_" in this module.
  33. # The first FIND disables the CMAKE_ search paths and only checks
  34. # the environmental paths.
  35. # If nothing is found, then the second find will search the
  36. # standard install paths.
  37. # Explicit -DVAR=value arguments should still be able to override everything.
  38. # Note: We have added an additional check for ${CMAKE_PREFIX_PATH}.
  39. # This is not an official CMake variable, but one we are proposing be
  40. # added to CMake. Be warned that this may go away or the variable name
  41. # may change.
  42. FIND_PATH(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread
  43. PATHS
  44. $ENV{OPENTHREADS_INCLUDE_DIR}
  45. $ENV{OPENTHREADS_DIR}/include
  46. $ENV{OPENTHREADS_DIR}
  47. $ENV{OSG_INCLUDE_DIR}
  48. $ENV{OSG_DIR}/include
  49. $ENV{OSG_DIR}
  50. $ENV{OSGDIR}/include
  51. $ENV{OSGDIR}
  52. NO_DEFAULT_PATH
  53. )
  54. FIND_PATH(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread
  55. PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
  56. NO_DEFAULT_PATH
  57. PATH_SUFFIXES include
  58. )
  59. FIND_PATH(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread
  60. ~/Library/Frameworks
  61. /Library/Frameworks
  62. /usr/local/include
  63. /usr/include
  64. /sw/include # Fink
  65. /opt/local/include # DarwinPorts
  66. /opt/csw/include # Blastwave
  67. /opt/include
  68. [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT]/include
  69. [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include
  70. )
  71. FIND_LIBRARY(OPENTHREADS_LIBRARY
  72. NAMES OpenThreads OpenThreadsWin32
  73. PATHS
  74. $ENV{OPENTHREADS_LIBRARY_DIR}
  75. $ENV{OPENTHREADS_DIR}/lib64
  76. $ENV{OPENTHREADS_DIR}/lib
  77. $ENV{OPENTHREADS_DIR}
  78. $ENV{OSG_LIBRARY_DIR}
  79. $ENV{OSG_DIR}/lib64
  80. $ENV{OSG_DIR}/lib
  81. $ENV{OSG_DIR}
  82. $ENV{OSGDIR}/lib64
  83. $ENV{OSGDIR}/lib
  84. $ENV{OSGDIR}
  85. NO_DEFAULT_PATH
  86. )
  87. FIND_LIBRARY(OPENTHREADS_LIBRARY
  88. NAMES OpenThreads OpenThreadsWin32
  89. PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
  90. NO_DEFAULT_PATH
  91. PATH_SUFFIXES lib64 lib
  92. )
  93. FIND_LIBRARY(OPENTHREADS_LIBRARY
  94. NAMES OpenThreads OpenThreadsWin32
  95. PATHS
  96. ~/Library/Frameworks
  97. /Library/Frameworks
  98. /usr/local/lib64
  99. /usr/local/lib
  100. /usr/lib64
  101. /usr/lib
  102. /sw/lib64
  103. /sw/lib
  104. /opt/local/lib64
  105. /opt/local/lib
  106. /opt/csw/lib64
  107. /opt/csw/lib
  108. /opt/lib64
  109. /opt/lib
  110. [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT]/lib
  111. [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
  112. )
  113. FIND_LIBRARY(OPENTHREADS_LIBRARY_DEBUG
  114. NAMES OpenThreadsd OpenThreadsWin32d
  115. PATHS
  116. $ENV{OPENTHREADS_DEBUG_LIBRARY_DIR}
  117. $ENV{OPENTHREADS_LIBRARY_DIR}
  118. $ENV{OPENTHREADS_DIR}/lib64
  119. $ENV{OPENTHREADS_DIR}/lib
  120. $ENV{OPENTHREADS_DIR}
  121. $ENV{OSG_LIBRARY_DIR}
  122. $ENV{OSG_DIR}/lib64
  123. $ENV{OSG_DIR}/lib
  124. $ENV{OSG_DIR}
  125. $ENV{OSGDIR}/lib64
  126. $ENV{OSGDIR}/lib
  127. $ENV{OSGDIR}
  128. NO_DEFAULT_PATH
  129. )
  130. FIND_LIBRARY(OPENTHREADS_LIBRARY_DEBUG
  131. NAMES OpenThreadsd OpenThreadsWin32d
  132. PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
  133. NO_DEFAULT_PATH
  134. PATH_SUFFIXES lib64 lib
  135. )
  136. FIND_LIBRARY(OPENTHREADS_LIBRARY_DEBUG
  137. NAMES OpenThreadsd OpenThreadsWin32d
  138. PATHS
  139. /usr/local/lib64
  140. /usr/local/lib
  141. /usr/lib64
  142. /usr/lib
  143. /sw/lib64
  144. /sw/lib
  145. /opt/local/lib64
  146. /opt/local/lib
  147. /opt/csw/lib64
  148. /opt/csw/lib
  149. /opt/lib64
  150. /opt/lib
  151. [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT]/lib
  152. [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
  153. )
  154. IF(OPENTHREADS_LIBRARY)
  155. IF(NOT OPENTHREADS_LIBRARY_DEBUG)
  156. #MESSAGE("-- Warning Debug OpenThreads not found, using: ${OPENTHREADS_LIBRARY}")
  157. #SET(OPENTHREADS_LIBRARY_DEBUG "${OPENTHREADS_LIBRARY}")
  158. SET(OPENTHREADS_LIBRARY_DEBUG "${OPENTHREADS_LIBRARY}" CACHE FILEPATH "Debug version of OpenThreads Library (use regular version if not available)" FORCE)
  159. ENDIF(NOT OPENTHREADS_LIBRARY_DEBUG)
  160. ENDIF(OPENTHREADS_LIBRARY)
  161. SET(OPENTHREADS_FOUND "NO")
  162. IF(OPENTHREADS_INCLUDE_DIR AND OPENTHREADS_LIBRARY)
  163. SET(OPENTHREADS_FOUND "YES")
  164. # MESSAGE("-- Found OpenThreads: "${OPENTHREADS_LIBRARY})
  165. ENDIF(OPENTHREADS_INCLUDE_DIR AND OPENTHREADS_LIBRARY)