FindBOOST_REGEX.cmake 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ################################################################################
  2. # Copyright (C) 2011 HPCC Systems.
  3. #
  4. # All rights reserved. This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ################################################################################
  17. # - Try to find the Boost regex library
  18. # Once done this will define
  19. #
  20. # BOOST_REGEX_FOUND - system has the Boost regex library
  21. # BOOST_REGEX_INCLUDE_DIR - the Boost regex include directory
  22. # BOOST_REGEX_LIBRARIES - The libraries needed to use Boost regex
  23. # BOOST_REGEX_LIBRARY_DIR - The directory containing libraries needed to use Boost regex
  24. IF (NOT BOOST_REGEX_FOUND)
  25. IF (UNIX)
  26. SET (boost_regex_lib "boost_regex-mt")
  27. IF(Boost_USE_STATIC_LIBS)
  28. SET (boost_regex_lib "libboost_regex-mt.a")
  29. ENDIF()
  30. ELSEIF(WIN32)
  31. 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...
  32. ENDIF()
  33. IF (NOT ${EXTERNALS_DIRECTORY} STREQUAL "")
  34. IF (UNIX)
  35. IF (${ARCH64BIT} EQUAL 1)
  36. SET (osdir "linux-x86_64-gcc4")
  37. ELSE()
  38. SET (osdir "linux-i686-gcc4")
  39. ENDIF()
  40. ELSEIF(WIN32)
  41. SET (osdir "windows-i386-vc90")
  42. ELSE()
  43. SET (osdir "unknown")
  44. ENDIF()
  45. IF (NOT ("${osdir}" STREQUAL "unknown"))
  46. FIND_PATH (BOOST_REGEX_INCLUDE_DIR NAMES boost/regex.h PATHS "${EXTERNALS_DIRECTORY}/boost/include" NO_DEFAULT_PATH)
  47. FIND_LIBRARY (BOOST_REGEX_LIBRARIES NAMES ${boost_regex_lib} PATHS "${EXTERNALS_DIRECTORY}/boost/${osdir}/lib" NO_DEFAULT_PATH)
  48. ENDIF()
  49. ENDIF()
  50. # if we didn't find in externals, look in system include path
  51. if (USE_NATIVE_LIBRARIES)
  52. set(Boost_ADDITIONAL_VERSIONS "1.41" "1.41.0" "1.44.0")
  53. set(Boost_USE_MULTITHREADED ON)
  54. set (Boost_DETAILED_FAILURE_MSG ON)
  55. # On centos we may have both boost-devel and boost141-devel installed. We need to look for the former first.
  56. set(BOOST_ROOT "/usr/include/boost141")
  57. set(BOOST_INCLUDEDIR "/usr/include/boost141")
  58. if (${ARCH64BIT} EQUAL 1)
  59. set(BOOST_LIBRARYDIR "/usr/lib64/boost141")
  60. else()
  61. set(BOOST_LIBRARYDIR "/usr/lib/boost141")
  62. endif()
  63. find_package( Boost 1.34.0 COMPONENTS regex )
  64. if(Boost_FOUND)
  65. set(BOOST_REGEX_LIBRARIES ${Boost_LIBRARIES})
  66. set(BOOST_REGEX_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
  67. endif()
  68. endif()
  69. include(FindPackageHandleStandardArgs)
  70. find_package_handle_standard_args(BOOST_REGEX DEFAULT_MSG
  71. BOOST_REGEX_LIBRARIES
  72. BOOST_REGEX_INCLUDE_DIR
  73. )
  74. IF (BOOST_REGEX_FOUND)
  75. IF (WIN32)
  76. STRING(REPLACE "/${boost_regex_lib}" "" BOOST_REGEX_LIBRARY_DIR "${BOOST_REGEX_LIBRARIES}")
  77. link_directories(${BOOST_REGEX_LIBRARY_DIR})
  78. set (BOOST_REGEX_LIBRARIES "") # the actual library to use is controlled by boost header files
  79. ENDIF()
  80. ENDIF()
  81. MARK_AS_ADVANCED(BOOST_REGEX_INCLUDE_DIR BOOST_REGEX_LIBRARIES)
  82. ENDIF()