FindOpenThreads.cmake 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindOpenThreads
  5. ---------------
  6. OpenThreads is a C++ based threading library. Its largest userbase
  7. seems to OpenSceneGraph so you might notice I accept OSGDIR as an
  8. environment path. I consider this part of the Findosg* suite used to
  9. find OpenSceneGraph components. Each component is separate and you
  10. must opt in to each module.
  11. Locate OpenThreads This module defines OPENTHREADS_LIBRARY
  12. OPENTHREADS_FOUND, if false, do not try to link to OpenThreads
  13. OPENTHREADS_INCLUDE_DIR, where to find the headers
  14. $OPENTHREADS_DIR is an environment variable that would correspond to
  15. the ./configure --prefix=$OPENTHREADS_DIR used in building osg.
  16. [CMake 2.8.10]: The CMake variables OPENTHREADS_DIR or OSG_DIR can now
  17. be used as well to influence detection, instead of needing to specify
  18. an environment variable.
  19. Created by Eric Wing.
  20. #]=======================================================================]
  21. # Header files are presumed to be included like
  22. # #include <OpenThreads/Thread>
  23. # To make it easier for one-step automated configuration/builds,
  24. # we leverage environmental paths. This is preferable
  25. # to the -DVAR=value switches because it insulates the
  26. # users from changes we may make in this script.
  27. # It also offers a little more flexibility than setting
  28. # the CMAKE_*_PATH since we can target specific components.
  29. # However, the default CMake behavior will search system paths
  30. # before anything else. This is problematic in the cases
  31. # where you have an older (stable) version installed, but
  32. # are trying to build a newer version.
  33. # CMake doesn't offer a nice way to globally control this behavior
  34. # so we have to do a nasty "double FIND_" in this module.
  35. # The first FIND disables the CMAKE_ search paths and only checks
  36. # the environmental paths.
  37. # If nothing is found, then the second find will search the
  38. # standard install paths.
  39. # Explicit -DVAR=value arguments should still be able to override everything.
  40. include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
  41. find_path(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread
  42. HINTS
  43. ENV OPENTHREADS_INCLUDE_DIR
  44. ENV OPENTHREADS_DIR
  45. ENV OSG_INCLUDE_DIR
  46. ENV OSG_DIR
  47. ENV OSGDIR
  48. ENV OpenThreads_ROOT
  49. ENV OSG_ROOT
  50. ${OPENTHREADS_DIR}
  51. ${OSG_DIR}
  52. PATH_SUFFIXES include
  53. )
  54. find_library(OPENTHREADS_LIBRARY_RELEASE
  55. NAMES OpenThreads OpenThreadsWin32
  56. HINTS
  57. ENV OPENTHREADS_LIBRARY_DIR
  58. ENV OPENTHREADS_DIR
  59. ENV OSG_LIBRARY_DIR
  60. ENV OSG_DIR
  61. ENV OSGDIR
  62. ENV OpenThreads_ROOT
  63. ENV OSG_ROOT
  64. ${OPENTHREADS_DIR}
  65. ${OSG_DIR}
  66. PATH_SUFFIXES lib
  67. )
  68. find_library(OPENTHREADS_LIBRARY_DEBUG
  69. NAMES OpenThreadsd OpenThreadsWin32d
  70. HINTS
  71. ENV OPENTHREADS_DEBUG_LIBRARY_DIR
  72. ENV OPENTHREADS_LIBRARY_DIR
  73. ENV OPENTHREADS_DIR
  74. ENV OSG_LIBRARY_DIR
  75. ENV OSG_DIR
  76. ENV OSGDIR
  77. ENV OpenThreads_ROOT
  78. ENV OSG_ROOT
  79. ${OPENTHREADS_DIR}
  80. ${OSG_DIR}
  81. PATH_SUFFIXES lib
  82. )
  83. select_library_configurations(OPENTHREADS)
  84. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  85. FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenThreads DEFAULT_MSG
  86. OPENTHREADS_LIBRARY OPENTHREADS_INCLUDE_DIR)