1 # +----------------------------------------------------------------------+
3 # +----------------------------------------------------------------------+
4 # | Copyright (c) 2010 Facebook, Inc. (http://www.facebook.com) |
5 # | Copyright (c) 1997-2010 The PHP Group |
6 # +----------------------------------------------------------------------+
7 # | This source file is subject to version 3.01 of the PHP license, |
8 # | that is bundled with this package in the file LICENSE, and is |
9 # | available through the world-wide-web at the following url: |
10 # | http://www.php.net/license/3_01.txt |
11 # | If you did not receive a copy of the PHP license and are unable to |
12 # | obtain it through the world-wide-web, please send a note to |
13 # | license@php.net so we can mail you a copy immediately. |
14 # +----------------------------------------------------------------------+
17 ##### --- header --- #####
18 set(EXTRA_INCLUDE_PATHS)
19 set(THIRD_PARTY_MODULES)
20 set(THIRD_PARTY_HEADERS)
22 function(TP_INSTALL_HEADERS TARGET SRCDIR DEST)
23 file(GLOB_RECURSE files "${SRCDIR}/*.h")
25 CODE "INCLUDE(\"${HPHP_HOME}/CMake/HPHPFunctions.cmake\")
26 HHVM_INSTALL_HEADERS(${TARGET}
27 \"${CMAKE_CURRENT_BINARY_DIR}/${SRCDIR}\"
28 \"\${CMAKE_INSTALL_PREFIX}/include/hphp/third-party/${DEST}\"
34 ##### easy stuff #####
37 list(APPEND THIRD_PARTY_MODULES jemalloc)
40 list(APPEND THIRD_PARTY_MODULES forks/libmbfl)
41 list(APPEND EXTRA_INCLUDE_PATHS
42 "${TP_DIR}/forks/libmbfl"
43 "${TP_DIR}/forks/libmbfl/mbfl"
44 "${TP_DIR}/forks/libmbfl/filters"
47 list(APPEND THIRD_PARTY_MODULES forks/timelib)
48 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/forks/timelib")
50 list(APPEND THIRD_PARTY_MODULES folly)
51 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/forks/folly/src")
53 # Fatal is a header-only library, so there's nothing to build.
54 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/fatal")
56 list(APPEND THIRD_PARTY_MODULES fizz)
57 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/fizz/src")
59 list(APPEND THIRD_PARTY_MODULES wangle)
60 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/wangle/src")
62 list(APPEND THIRD_PARTY_MODULES brotli)
63 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/brotli/src")
65 list(APPEND THIRD_PARTY_MODULES proxygen)
66 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/proxygen/src")
68 list(APPEND THIRD_PARTY_MODULES fmt)
69 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/fmt/fmt/include")
71 list(APPEND THIRD_PARTY_MODULES rsocket-cpp)
72 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/rsocket-cpp/src")
74 list(APPEND THIRD_PARTY_MODULES thrift)
75 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/thrift/src")
76 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/thrift/gen")
78 list(APPEND THIRD_PARTY_MODULES zstd)
79 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/zstd/src/lib")
80 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/zstd/src/lib/dictBuilder")
83 list(APPEND THIRD_PARTY_MODULES libafdt)
84 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/libafdt/src/src")
87 if(ENABLE_ASYNC_MYSQL)
90 message(STATUS "Building RE2 from third-party")
91 list(APPEND THIRD_PARTY_MODULES re2)
93 list(APPEND THIRD_PARTY_MODULES squangle)
94 list(APPEND THIRD_PARTY_MODULES fb-mysql)
98 # Ragel is only used at build time to generate some files for MCRouter.
99 list(APPEND THIRD_PARTY_MODULES forks/ragel)
101 list(APPEND THIRD_PARTY_MODULES mcrouter)
102 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/mcrouter/src")
103 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/mcrouter/gen")
106 # Add bundled fastlz if the system one will not be used
107 if(NOT FASTLZ_LIBRARY)
108 list(APPEND THIRD_PARTY_MODULES fastlz)
109 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/fastlz/src")
112 # Add bundled libsqlite3 if the system one will not be used
113 if(NOT LIBSQLITE3_LIBRARY)
114 list(APPEND THIRD_PARTY_MODULES forks/libsqlite3)
115 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/forks/libsqlite3")
118 # Add bundled lz4 if the system one will not be used
120 list(APPEND THIRD_PARTY_MODULES lz4)
121 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/lz4/src/lib")
124 # Add bundled double-conversion if the system one will not be used
125 if(NOT DOUBLE_CONVERSION_FOUND)
126 list(APPEND THIRD_PARTY_MODULES double-conversion)
127 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/double-conversion")
130 # Add bundled PCRE if the system one will not be used
133 list(APPEND THIRD_PARTY_MODULES forks/pcre)
134 # Disable building a few parts of PCRE by default that we don't
136 set(PCRE_BUILD_PCRECPP OFF CACHE BOOL "Build the PCRE C++ library (pcrecpp).")
137 set(PCRE_BUILD_PCREGREP OFF CACHE BOOL "Build pcregrep")
138 set(PCRE_BUILD_TESTS OFF CACHE BOOL "Build the tests")
141 # Add bundled libzip if the system one will not be used
142 if(NOT LIBZIP_LIBRARY)
143 list(APPEND THIRD_PARTY_MODULES libzip)
144 list(APPEND EXTRA_INCLUDE_PATHS
145 "${CMAKE_CURRENT_BINARY_DIR}/libzip/src/lib"
146 "${TP_DIR}/libzip/src/lib"
150 list(APPEND THIRD_PARTY_MODULES ocaml)
152 # Add bundled XED library if XED is enabled and the specified XED library
153 # is either not found or incompatible.
154 if(ENABLE_XED AND NOT LibXed_FOUND)
155 list(APPEND THIRD_PARTY_MODULES xed)
156 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/xed/xed/build/include/xed")
162 find_package(Boost 1.62.0 COMPONENTS context fiber filesystem iostreams program_options regex system thread)
163 if ("${Boost_VERSION}" EQUAL "107000")
164 # https://github.com/boostorg/variant/issues/69
165 message(WARNING "System boost is blacklisted version")
167 set(Boost_FOUND false)
170 add_library(boost INTERFACE)
171 add_custom_target(boostMaybeBuild)
173 # The boost library can't have a dependency on boostBuild because of:
174 # https://public.kitware.com/Bug/view.php?id=15414
175 # Instead we add the dependency to the target being linked with hphp_link
176 add_dependencies(boostMaybeBuild boostBuild)
177 message(STATUS "Using third-party bundled boost")
178 add_subdirectory(boost)
179 # These are the archive names prefixed with lib so that cmake does not
180 # find these to be system archive instead of these third party ones.
184 "libboost_filesystem"
186 "libboost_program_options"
190 CACHE STRING "" FORCE
192 foreach(lib ${Boost_LIBRARIES})
193 add_library(${lib} STATIC IMPORTED)
194 set_property(TARGET ${lib} PROPERTY IMPORTED_LOCATION
195 "${CMAKE_CURRENT_SOURCE_DIR}/boost/build/lib/${lib}.a")
197 set(Boost_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/boost/build/include" CACHE STRING "" FORCE)
198 set(Boost_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/boost/build/lib" CACHE STRING "" FORCE)
199 TP_INSTALL_HEADERS(boost boost/build/include/boost boost)
200 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/boost/build/include")
202 target_include_directories(boost BEFORE INTERFACE ${Boost_INCLUDE_DIRS})
203 target_link_libraries(boost INTERFACE ${Boost_LIBRARIES})
205 ##### libsodium #####
207 add_library(libsodium INTERFACE)
208 add_custom_target(libsodiumMaybeBuild)
209 find_package(LibSodium 1.0.9)
210 if (LIBSODIUM_INCLUDE_DIRS AND LIBSODIUM_LIBRARIES)
211 message(STATUS "Using system libsodium ${LIBSODIUM_VERSION}")
213 message(STATUS "Using third-party bundled libsodium")
214 add_dependencies(libsodiumMaybeBuild libsodiumBuild)
215 add_subdirectory(libsodium EXCLUDE_FROM_ALL)
217 target_include_directories(libsodium INTERFACE ${LIBSODIUM_INCLUDE_DIRS})
218 target_link_libraries(libsodium INTERFACE ${LIBSODIUM_LIBRARIES})
219 add_definitions("-DHAVE_LIBSODIUM")
220 list(APPEND EXTRA_INCLUDE_PATHS "${LIBSODIUM_INCLUDE_DIRS}")
221 list(APPEND THIRD_PARTY_DEFINITIONS "-DHAVE_LIBSODIUM")
225 add_subdirectory("rustc")
227 ##### --- footer --- #####
229 foreach(MODULE ${THIRD_PARTY_MODULES})
230 add_subdirectory(${MODULE})
231 # Install headers here, rather than in the individual submodules, so that we
232 # can easily control the destination. Put them in include/hphp/third-party.
233 if(MODULE STREQUAL folly)
234 TP_INSTALL_HEADERS(folly folly/src/folly folly)
236 TP_INSTALL_HEADERS(${MODULE} ${MODULE} ${MODULE})
239 set(THIRD_PARTY_INCLUDE_PATHS ${EXTRA_INCLUDE_PATHS} CACHE INTERNAL "" FORCE)
242 target_include_directories(pcre PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/forks/pcre")
243 target_compile_definitions(pcre PUBLIC "PCRE_STATIC=1")