FindOpenThreads.cmake 4.6 KB

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