FindBOOST_REGEX.cmake 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. IF (MSVC14)
  44. SET (boost_regex_lib "boost_regex-vc140-mt-1_60.lib")
  45. ELSEIF (MSVC12)
  46. SET (boost_regex_lib "boost_regex-vc120-mt-1_57.lib")
  47. ELSEIF (MSVC10)
  48. SET (boost_regex_lib "boost_regex-vc100-mt-1_57.lib")
  49. ELSEIF (MSVC90)
  50. SET (boost_regex_lib "boost_regex-vc90-mt-1_57.lib")
  51. ELSE ()
  52. SET (boost_regex_lib "boost_regex-mt.lib")
  53. ENDIF()
  54. ENDIF()
  55. IF (NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
  56. IF (UNIX)
  57. IF (${ARCH64BIT} EQUAL 1)
  58. SET (osdir "linux-x86_64-gcc4")
  59. ELSE()
  60. SET (osdir "linux-i686-gcc4")
  61. ENDIF()
  62. ELSEIF(WIN32)
  63. IF (${ARCH64BIT} EQUAL 1)
  64. SET (osdir "windows-x86_64")
  65. ELSE()
  66. SET (osdir "windows-i386")
  67. ENDIF()
  68. ELSE()
  69. SET (osdir "unknown")
  70. ENDIF()
  71. IF (NOT ("${osdir}" STREQUAL "unknown"))
  72. FIND_PATH (BOOST_REGEX_INCLUDE_DIR NAMES boost/regex.h PATHS "${EXTERNALS_DIRECTORY}/boost/include" NO_DEFAULT_PATH)
  73. FIND_LIBRARY (BOOST_REGEX_LIBRARIES NAMES ${boost_regex_lib} PATHS "${EXTERNALS_DIRECTORY}/boost/${osdir}/lib" NO_DEFAULT_PATH)
  74. ENDIF()
  75. ENDIF()
  76. # if we didn't find in externals, look in system include path
  77. if (USE_NATIVE_LIBRARIES)
  78. set(Boost_ADDITIONAL_VERSIONS "1.41" "1.41.0" "1.44.0")
  79. set(Boost_USE_MULTITHREADED ON)
  80. set (Boost_DETAILED_FAILURE_MSG ON)
  81. # On centos we may have both boost-devel and boost141-devel installed. We need to look for the former first.
  82. set(BOOST_ROOT "/usr/include/boost141")
  83. set(BOOST_INCLUDEDIR "/usr/include/boost141")
  84. if (${ARCH64BIT} EQUAL 1)
  85. set(BOOST_LIBRARYDIR "/usr/lib64/boost141")
  86. else()
  87. set(BOOST_LIBRARYDIR "/usr/lib/boost141")
  88. endif()
  89. find_package( Boost 1.34.0 COMPONENTS regex )
  90. if(Boost_FOUND)
  91. set(BOOST_REGEX_LIBRARIES ${Boost_LIBRARIES})
  92. set(BOOST_REGEX_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
  93. endif()
  94. endif()
  95. include(FindPackageHandleStandardArgs)
  96. find_package_handle_standard_args(BOOST_REGEX DEFAULT_MSG
  97. BOOST_REGEX_LIBRARIES
  98. BOOST_REGEX_INCLUDE_DIR
  99. )
  100. IF (BOOST_REGEX_FOUND)
  101. IF (WIN32)
  102. STRING(REPLACE "/${boost_regex_lib}" "" BOOST_REGEX_LIBRARY_DIR "${BOOST_REGEX_LIBRARIES}")
  103. link_directories(${BOOST_REGEX_LIBRARY_DIR})
  104. set (BOOST_REGEX_LIBRARIES "") # the actual library to use is controlled by boost header files
  105. ENDIF()
  106. ENDIF()
  107. MARK_AS_ADVANCED(BOOST_REGEX_INCLUDE_DIR BOOST_REGEX_LIBRARIES)
  108. ENDIF (WIN32 AND USE_NATIVE_LIBRARIES)
  109. ENDIF()