FindOpenThreads.cmake 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. This module defines:
  12. ``OPENTHREADS_LIBRARY``
  13. ``OPENTHREADS_FOUND``
  14. if false, do not try to link to OpenThreads
  15. ``OPENTHREADS_INCLUDE_DIR``
  16. where to find the headers
  17. ``$OPENTHREADS_DIR`` is an environment variable that would correspond to the::
  18. ./configure --prefix=$OPENTHREADS_DIR
  19. used in building osg.
  20. .. versionadded:: 2.8.10
  21. The CMake variables ``OPENTHREADS_DIR`` or ``OSG_DIR`` can now
  22. be used as well to influence detection, instead of needing to specify
  23. an environment variable.
  24. #]=======================================================================]
  25. # Header files are presumed to be included like
  26. # #include <OpenThreads/Thread>
  27. # To make it easier for one-step automated configuration/builds,
  28. # we leverage environmental paths. This is preferable
  29. # to the -DVAR=value switches because it insulates the
  30. # users from changes we may make in this script.
  31. # It also offers a little more flexibility than setting
  32. # the CMAKE_*_PATH since we can target specific components.
  33. # However, the default CMake behavior will search system paths
  34. # before anything else. This is problematic in the cases
  35. # where you have an older (stable) version installed, but
  36. # are trying to build a newer version.
  37. # CMake doesn't offer a nice way to globally control this behavior
  38. # so we have to do a nasty "double FIND_" in this module.
  39. # The first FIND disables the CMAKE_ search paths and only checks
  40. # the environmental paths.
  41. # If nothing is found, then the second find will search the
  42. # standard install paths.
  43. # Explicit -DVAR=value arguments should still be able to override everything.
  44. include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
  45. find_path(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread
  46. HINTS
  47. ENV OPENTHREADS_INCLUDE_DIR
  48. ENV OPENTHREADS_DIR
  49. ENV OSG_INCLUDE_DIR
  50. ENV OSG_DIR
  51. ENV OSGDIR
  52. ENV OpenThreads_ROOT
  53. ENV OSG_ROOT
  54. ${OPENTHREADS_DIR}
  55. ${OSG_DIR}
  56. PATH_SUFFIXES include
  57. )
  58. find_library(OPENTHREADS_LIBRARY_RELEASE
  59. NAMES OpenThreads OpenThreadsWin32
  60. HINTS
  61. ENV OPENTHREADS_LIBRARY_DIR
  62. ENV OPENTHREADS_DIR
  63. ENV OSG_LIBRARY_DIR
  64. ENV OSG_DIR
  65. ENV OSGDIR
  66. ENV OpenThreads_ROOT
  67. ENV OSG_ROOT
  68. ${OPENTHREADS_DIR}
  69. ${OSG_DIR}
  70. PATH_SUFFIXES lib
  71. )
  72. find_library(OPENTHREADS_LIBRARY_DEBUG
  73. NAMES OpenThreadsd OpenThreadsWin32d
  74. HINTS
  75. ENV OPENTHREADS_DEBUG_LIBRARY_DIR
  76. ENV OPENTHREADS_LIBRARY_DIR
  77. ENV OPENTHREADS_DIR
  78. ENV OSG_LIBRARY_DIR
  79. ENV OSG_DIR
  80. ENV OSGDIR
  81. ENV OpenThreads_ROOT
  82. ENV OSG_ROOT
  83. ${OPENTHREADS_DIR}
  84. ${OSG_DIR}
  85. PATH_SUFFIXES lib
  86. )
  87. select_library_configurations(OPENTHREADS)
  88. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  89. find_package_handle_standard_args(OpenThreads DEFAULT_MSG
  90. OPENTHREADS_LIBRARY OPENTHREADS_INCLUDE_DIR)