FindOpenThreads.cmake 3.9 KB

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