FindOpenThreads.cmake 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #.rst:
  2. # FindOpenThreads
  3. # ---------------
  4. #
  5. #
  6. #
  7. # OpenThreads is a C++ based threading library. Its largest userbase
  8. # seems to OpenSceneGraph so you might notice I accept OSGDIR as an
  9. # environment path. I consider this part of the Findosg* suite used to
  10. # find OpenSceneGraph components. Each component is separate and you
  11. # must opt in to each module.
  12. #
  13. # Locate OpenThreads This module defines OPENTHREADS_LIBRARY
  14. # OPENTHREADS_FOUND, if false, do not try to link to OpenThreads
  15. # OPENTHREADS_INCLUDE_DIR, where to find the headers
  16. #
  17. # $OPENTHREADS_DIR is an environment variable that would correspond to
  18. # the ./configure --prefix=$OPENTHREADS_DIR used in building osg.
  19. #
  20. # [CMake 2.8.10]: The CMake variables OPENTHREADS_DIR or OSG_DIR can now
  21. # be used as well to influence detection, instead of needing to specify
  22. # an environment variable.
  23. #
  24. # Created by Eric Wing.
  25. #=============================================================================
  26. # Copyright 2007-2009 Kitware, Inc.
  27. # Copyright 2012 Philip Lowman <philip@yhbt.com>
  28. #
  29. # Distributed under the OSI-approved BSD License (the "License");
  30. # see accompanying file Copyright.txt for details.
  31. #
  32. # This software is distributed WITHOUT ANY WARRANTY; without even the
  33. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  34. # See the License for more information.
  35. #=============================================================================
  36. # (To distribute this file outside of CMake, substitute the full
  37. # License text for the above reference.)
  38. # Header files are presumed to be included like
  39. # #include <OpenThreads/Thread>
  40. # To make it easier for one-step automated configuration/builds,
  41. # we leverage environmental paths. This is preferable
  42. # to the -DVAR=value switches because it insulates the
  43. # users from changes we may make in this script.
  44. # It also offers a little more flexibility than setting
  45. # the CMAKE_*_PATH since we can target specific components.
  46. # However, the default CMake behavior will search system paths
  47. # before anything else. This is problematic in the cases
  48. # where you have an older (stable) version installed, but
  49. # are trying to build a newer version.
  50. # CMake doesn't offer a nice way to globally control this behavior
  51. # so we have to do a nasty "double FIND_" in this module.
  52. # The first FIND disables the CMAKE_ search paths and only checks
  53. # the environmental paths.
  54. # If nothing is found, then the second find will search the
  55. # standard install paths.
  56. # Explicit -DVAR=value arguments should still be able to override everything.
  57. find_path(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread
  58. HINTS
  59. ENV OPENTHREADS_INCLUDE_DIR
  60. ENV OPENTHREADS_DIR
  61. ENV OSG_INCLUDE_DIR
  62. ENV OSG_DIR
  63. ENV OSGDIR
  64. ENV OpenThreads_ROOT
  65. ENV OSG_ROOT
  66. ${OPENTHREADS_DIR}
  67. ${OSG_DIR}
  68. PATHS
  69. /sw # Fink
  70. /opt/local # DarwinPorts
  71. /opt/csw # Blastwave
  72. /opt
  73. /usr/freeware
  74. PATH_SUFFIXES include
  75. )
  76. find_library(OPENTHREADS_LIBRARY
  77. NAMES OpenThreads OpenThreadsWin32
  78. HINTS
  79. ENV OPENTHREADS_LIBRARY_DIR
  80. ENV OPENTHREADS_DIR
  81. ENV OSG_LIBRARY_DIR
  82. ENV OSG_DIR
  83. ENV OSGDIR
  84. ENV OpenThreads_ROOT
  85. ENV OSG_ROOT
  86. ${OPENTHREADS_DIR}
  87. ${OSG_DIR}
  88. PATHS
  89. /sw
  90. /opt/local
  91. /opt/csw
  92. /opt
  93. /usr/freeware
  94. PATH_SUFFIXES lib
  95. )
  96. find_library(OPENTHREADS_LIBRARY_DEBUG
  97. NAMES OpenThreadsd OpenThreadsWin32d
  98. HINTS
  99. ENV OPENTHREADS_DEBUG_LIBRARY_DIR
  100. ENV OPENTHREADS_LIBRARY_DIR
  101. ENV OPENTHREADS_DIR
  102. ENV OSG_LIBRARY_DIR
  103. ENV OSG_DIR
  104. ENV OSGDIR
  105. ENV OpenThreads_ROOT
  106. ENV OSG_ROOT
  107. ${OPENTHREADS_DIR}
  108. ${OSG_DIR}
  109. PATHS
  110. /sw
  111. /opt/local
  112. /opt/csw
  113. /opt
  114. /usr/freeware
  115. PATH_SUFFIXES lib
  116. )
  117. if(OPENTHREADS_LIBRARY_DEBUG)
  118. set(OPENTHREADS_LIBRARIES
  119. optimized ${OPENTHREADS_LIBRARY}
  120. debug ${OPENTHREADS_LIBRARY_DEBUG})
  121. else()
  122. set(OPENTHREADS_LIBRARIES ${OPENTHREADS_LIBRARY})
  123. endif()
  124. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  125. FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenThreads DEFAULT_MSG
  126. OPENTHREADS_LIBRARY OPENTHREADS_INCLUDE_DIR)