FindBOOST_REGEX.cmake 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. ################################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ################################################################################
  16. # - Try to find the Boost regex library
  17. # Once done this will define
  18. #
  19. # BOOST_REGEX_FOUND - system has the Boost regex library
  20. # BOOST_REGEX_INCLUDE_DIR - the Boost regex include directory
  21. # BOOST_REGEX_LIBRARIES - The libraries needed to use Boost regex
  22. # BOOST_REGEX_LIBRARY_DIR - The directory containing libraries needed to use Boost regex
  23. IF (NOT BOOST_REGEX_FOUND)
  24. IF (WIN32 AND USE_NATIVE_LIBRARIES)
  25. set ( Boost_USE_STATIC_LIBS ON )
  26. set ( Boost_USE_MULTITHREADED ON )
  27. set ( Boost_USE_STATIC_RUNTIME OFF )
  28. find_package( Boost COMPONENTS regex )
  29. IF (Boost_FOUND)
  30. set(BOOST_REGEX_FOUND TRUE)
  31. set(BOOST_REGEX_LIBRARIES ${Boost_LIBRARIES})
  32. set(BOOST_REGEX_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
  33. set(BOOST_REGEX_LIBRARY_DIR ${Boost_LIBRARY_DIRS})
  34. link_directories(${BOOST_REGEX_LIBRARY_DIR})
  35. ENDIF (Boost_FOUND)
  36. ELSE (WIN32 AND USE_NATIVE_LIBRARIES)
  37. IF (UNIX)
  38. SET (boost_regex_lib "boost_regex-mt")
  39. IF(Boost_USE_STATIC_LIBS)
  40. SET (boost_regex_lib "libboost_regex-mt.a")
  41. ENDIF()
  42. ELSEIF(WIN32)
  43. SET (boost_regex_lib "libboost_regex-vc90-mt.lib") # note - this may not be the lib we need, but should be in same place as it...
  44. ENDIF()
  45. IF (NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
  46. IF (UNIX)
  47. IF (${ARCH64BIT} EQUAL 1)
  48. SET (osdir "linux-x86_64-gcc4")
  49. ELSE()
  50. SET (osdir "linux-i686-gcc4")
  51. ENDIF()
  52. ELSEIF(WIN32)
  53. SET (osdir "windows-i386-vc90")
  54. ELSE()
  55. SET (osdir "unknown")
  56. ENDIF()
  57. IF (NOT ("${osdir}" STREQUAL "unknown"))
  58. FIND_PATH (BOOST_REGEX_INCLUDE_DIR NAMES boost/regex.h PATHS "${EXTERNALS_DIRECTORY}/boost/include" NO_DEFAULT_PATH)
  59. FIND_LIBRARY (BOOST_REGEX_LIBRARIES NAMES ${boost_regex_lib} PATHS "${EXTERNALS_DIRECTORY}/boost/${osdir}/lib" NO_DEFAULT_PATH)
  60. ENDIF()
  61. ENDIF()
  62. # if we didn't find in externals, look in system include path
  63. if (USE_NATIVE_LIBRARIES)
  64. set(Boost_ADDITIONAL_VERSIONS "1.41" "1.41.0" "1.44.0")
  65. set(Boost_USE_MULTITHREADED ON)
  66. set (Boost_DETAILED_FAILURE_MSG ON)
  67. # On centos we may have both boost-devel and boost141-devel installed. We need to look for the former first.
  68. set(BOOST_ROOT "/usr/include/boost141")
  69. set(BOOST_INCLUDEDIR "/usr/include/boost141")
  70. if (${ARCH64BIT} EQUAL 1)
  71. set(BOOST_LIBRARYDIR "/usr/lib64/boost141")
  72. else()
  73. set(BOOST_LIBRARYDIR "/usr/lib/boost141")
  74. endif()
  75. find_package( Boost 1.34.0 COMPONENTS regex )
  76. if(Boost_FOUND)
  77. set(BOOST_REGEX_LIBRARIES ${Boost_LIBRARIES})
  78. set(BOOST_REGEX_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
  79. endif()
  80. endif()
  81. include(FindPackageHandleStandardArgs)
  82. find_package_handle_standard_args(BOOST_REGEX DEFAULT_MSG
  83. BOOST_REGEX_LIBRARIES
  84. BOOST_REGEX_INCLUDE_DIR
  85. )
  86. IF (BOOST_REGEX_FOUND)
  87. IF (WIN32)
  88. STRING(REPLACE "/${boost_regex_lib}" "" BOOST_REGEX_LIBRARY_DIR "${BOOST_REGEX_LIBRARIES}")
  89. link_directories(${BOOST_REGEX_LIBRARY_DIR})
  90. set (BOOST_REGEX_LIBRARIES "") # the actual library to use is controlled by boost header files
  91. ENDIF()
  92. ENDIF()
  93. MARK_AS_ADVANCED(BOOST_REGEX_INCLUDE_DIR BOOST_REGEX_LIBRARIES)
  94. ENDIF (WIN32 AND USE_NATIVE_LIBRARIES)
  95. ENDIF()