FindOpenThreads.cmake 4.2 KB

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