FindOpenThreads.cmake 3.3 KB

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