FindOpenThreads.cmake 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. FIND_PATH(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread
  39. PATHS
  40. $ENV{OPENTHREADS_INCLUDE_DIR}
  41. $ENV{OPENTHREADS_DIR}/include
  42. $ENV{OPENTHREADS_DIR}
  43. $ENV{OSG_INCLUDE_DIR}
  44. $ENV{OSG_DIR}/include
  45. $ENV{OSG_DIR}
  46. $ENV{OSGDIR}/include
  47. $ENV{OSGDIR}
  48. NO_DEFAULT_PATH
  49. )
  50. FIND_PATH(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread
  51. ~/Library/Frameworks
  52. /Library/Frameworks
  53. /usr/local/include
  54. /usr/include
  55. /sw/include # Fink
  56. /opt/local/include # DarwinPorts
  57. /opt/csw/include # Blastwave
  58. /opt/include
  59. [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT]/include
  60. [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include
  61. )
  62. FIND_LIBRARY(OPENTHREADS_LIBRARY
  63. NAMES OpenThreads OpenThreadsWin32
  64. PATHS
  65. $ENV{OPENTHREADS_LIBRARY_DIR}
  66. $ENV{OPENTHREADS_DIR}/lib64
  67. $ENV{OPENTHREADS_DIR}/lib
  68. $ENV{OPENTHREADS_DIR}
  69. $ENV{OSG_LIBRARY_DIR}
  70. $ENV{OSG_DIR}/lib64
  71. $ENV{OSG_DIR}/lib
  72. $ENV{OSG_DIR}
  73. $ENV{OSGDIR}/lib64
  74. $ENV{OSGDIR}/lib
  75. $ENV{OSGDIR}
  76. NO_DEFAULT_PATH
  77. )
  78. FIND_LIBRARY(OPENTHREADS_LIBRARY
  79. NAMES OpenThreads OpenThreadsWin32
  80. PATHS
  81. ~/Library/Frameworks
  82. /Library/Frameworks
  83. /usr/local/lib64
  84. /usr/local/lib
  85. /usr/lib64
  86. /usr/lib
  87. /sw/lib64
  88. /sw/lib
  89. /opt/local/lib64
  90. /opt/local/lib
  91. /opt/csw/lib64
  92. /opt/csw/lib
  93. /opt/lib64
  94. /opt/lib
  95. [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT]/lib
  96. [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
  97. )
  98. FIND_LIBRARY(OPENTHREADS_LIBRARY_DEBUG
  99. NAMES OpenThreadsd OpenThreadsWin32d
  100. PATHS
  101. $ENV{OPENTHREADS_DEBUG_LIBRARY_DIR}
  102. $ENV{OPENTHREADS_LIBRARY_DIR}
  103. $ENV{OPENTHREADS_DIR}/lib64
  104. $ENV{OPENTHREADS_DIR}/lib
  105. $ENV{OPENTHREADS_DIR}
  106. $ENV{OSG_LIBRARY_DIR}
  107. $ENV{OSG_DIR}/lib64
  108. $ENV{OSG_DIR}/lib
  109. $ENV{OSG_DIR}
  110. $ENV{OSGDIR}/lib64
  111. $ENV{OSGDIR}/lib
  112. $ENV{OSGDIR}
  113. NO_DEFAULT_PATH
  114. )
  115. FIND_LIBRARY(OPENTHREADS_LIBRARY_DEBUG
  116. NAMES OpenThreadsd OpenThreadsWin32d
  117. PATHS
  118. /usr/local/lib64
  119. /usr/local/lib
  120. /usr/lib64
  121. /usr/lib
  122. /sw/lib64
  123. /sw/lib
  124. /opt/local/lib64
  125. /opt/local/lib
  126. /opt/csw/lib64
  127. /opt/csw/lib
  128. /opt/lib64
  129. /opt/lib
  130. [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT]/lib
  131. [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
  132. )
  133. IF(OPENTHREADS_LIBRARY)
  134. IF(NOT OPENTHREADS_LIBRARY_DEBUG)
  135. #MESSAGE("-- Warning Debug OpenThreads not found, using: ${OPENTHREADS_LIBRARY}")
  136. #SET(OPENTHREADS_LIBRARY_DEBUG "${OPENTHREADS_LIBRARY}")
  137. SET(OPENTHREADS_LIBRARY_DEBUG "${OPENTHREADS_LIBRARY}" CACHE FILEPATH "Debug version of OpenThreads Library (use regular version if not available)" FORCE)
  138. ENDIF(NOT OPENTHREADS_LIBRARY_DEBUG)
  139. ENDIF(OPENTHREADS_LIBRARY)
  140. SET(OPENTHREADS_FOUND "NO")
  141. IF(OPENTHREADS_INCLUDE_DIR AND OPENTHREADS_LIBRARY)
  142. SET(OPENTHREADS_FOUND "YES")
  143. # MESSAGE("-- Found OpenThreads: "${OPENTHREADS_LIBRARY})
  144. ENDIF(OPENTHREADS_INCLUDE_DIR AND OPENTHREADS_LIBRARY)