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 set(EXTRA_INCLUDE_PATHS)
18 set(THIRD_PARTY_MODULES)
19 set(THIRD_PARTY_HEADERS)
22 list(APPEND THIRD_PARTY_MODULES forks/libmbfl)
23 list(APPEND EXTRA_INCLUDE_PATHS
24 "${TP_DIR}/forks/libmbfl"
25 "${TP_DIR}/forks/libmbfl/mbfl"
26 "${TP_DIR}/forks/libmbfl/filters"
29 list(APPEND THIRD_PARTY_MODULES forks/timelib)
30 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/forks/timelib")
32 list(APPEND THIRD_PARTY_MODULES folly)
33 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/forks/folly/src")
35 # Fatal is a header-only library, so there's nothing to build.
36 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/fatal")
38 list(APPEND THIRD_PARTY_MODULES fizz)
39 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/fizz/src")
41 list(APPEND THIRD_PARTY_MODULES wangle)
42 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/wangle/src")
44 list(APPEND THIRD_PARTY_MODULES brotli)
45 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/brotli/src")
47 list(APPEND THIRD_PARTY_MODULES proxygen)
48 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/proxygen/src")
50 list(APPEND THIRD_PARTY_MODULES fmt)
51 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/fmt/fmt/include")
53 list(APPEND THIRD_PARTY_MODULES rsocket-cpp)
54 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/rsocket-cpp/src")
56 list(APPEND THIRD_PARTY_MODULES thrift)
57 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/thrift/src")
58 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/thrift/gen")
60 list(APPEND THIRD_PARTY_MODULES zstd)
61 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/zstd/src/lib")
62 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/zstd/src/lib/dictBuilder")
65 list(APPEND THIRD_PARTY_MODULES libafdt)
66 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/libafdt/src/src")
69 if(ENABLE_ASYNC_MYSQL)
72 message(STATUS "Building RE2 from third-party")
73 list(APPEND THIRD_PARTY_MODULES re2)
75 list(APPEND THIRD_PARTY_MODULES squangle)
76 list(APPEND THIRD_PARTY_MODULES fb-mysql)
80 # Ragel is only used at build time to generate some files for MCRouter.
81 list(APPEND THIRD_PARTY_MODULES forks/ragel)
83 list(APPEND THIRD_PARTY_MODULES mcrouter)
84 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/mcrouter/src")
85 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/mcrouter/gen")
88 # Add bundled fastlz if the system one will not be used
89 if(NOT FASTLZ_LIBRARY)
90 list(APPEND THIRD_PARTY_MODULES fastlz)
91 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/fastlz/src")
94 # Add bundled libsqlite3 if the system one will not be used
95 if(NOT LIBSQLITE3_LIBRARY)
96 list(APPEND THIRD_PARTY_MODULES forks/libsqlite3)
97 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/forks/libsqlite3")
100 # Add bundled lz4 if the system one will not be used
102 list(APPEND THIRD_PARTY_MODULES lz4)
103 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/lz4/src/lib")
106 # Add bundled double-conversion if the system one will not be used
107 if(NOT DOUBLE_CONVERSION_FOUND)
108 list(APPEND THIRD_PARTY_MODULES double-conversion)
109 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/double-conversion")
112 # Add bundled PCRE if the system one will not be used
115 list(APPEND THIRD_PARTY_MODULES forks/pcre)
116 # Disable building a few parts of PCRE by default that we don't
118 set(PCRE_BUILD_PCRECPP OFF CACHE BOOL "Build the PCRE C++ library (pcrecpp).")
119 set(PCRE_BUILD_PCREGREP OFF CACHE BOOL "Build pcregrep")
120 set(PCRE_BUILD_TESTS OFF CACHE BOOL "Build the tests")
123 # Add bundled libzip if the system one will not be used
124 if(NOT LIBZIP_LIBRARY)
125 list(APPEND THIRD_PARTY_MODULES libzip)
126 list(APPEND EXTRA_INCLUDE_PATHS
127 "${CMAKE_CURRENT_BINARY_DIR}/libzip/src/lib"
128 "${TP_DIR}/libzip/src/lib"
132 list(APPEND THIRD_PARTY_MODULES ocaml)
134 # Add bundled XED library if XED is enabled and the specified XED library
135 # is either not found or incompatible.
136 if(ENABLE_XED AND NOT LibXed_FOUND)
137 list(APPEND THIRD_PARTY_MODULES xed)
138 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/xed/xed/build/include/xed")
141 function(TP_INSTALL_HEADERS TARGET SRCDIR DEST)
142 file(GLOB_RECURSE files "${SRCDIR}/*.h")
144 CODE "INCLUDE(\"${HPHP_HOME}/CMake/HPHPFunctions.cmake\")
145 HHVM_INSTALL_HEADERS(${TARGET}
146 \"${CMAKE_CURRENT_SOURCE_DIR}/${SRCDIR}\"
147 \"\${CMAKE_INSTALL_PREFIX}/include/hphp/third-party/${DEST}\"
152 foreach(MODULE ${THIRD_PARTY_MODULES})
153 add_subdirectory(${MODULE})
154 # Install headers here, rather than in the individual submodules, so that we
155 # can easily control the destination. Put them in include/hphp/third-party.
156 if(MODULE STREQUAL folly)
157 TP_INSTALL_HEADERS(folly folly/src/folly folly)
159 TP_INSTALL_HEADERS(${MODULE} ${MODULE} ${MODULE})
164 target_include_directories(pcre PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/forks/pcre")
165 target_compile_definitions(pcre PUBLIC "PCRE_STATIC=1")
169 find_package(Boost 1.62.0 COMPONENTS context fiber filesystem iostreams program_options regex system thread)
170 if ("${Boost_VERSION}" EQUAL "107000")
171 # https://github.com/boostorg/variant/issues/69
172 message(WARNING "System boost is blacklisted version")
174 set(Boost_FOUND false)
177 add_library(boost INTERFACE)
178 add_custom_target(boostMaybeBuild)
180 # The boost library can't have a dependency on boostBuild because of:
181 # https://public.kitware.com/Bug/view.php?id=15414
182 # Instead we add the dependency to the target being linked with hphp_link
183 add_dependencies(boostMaybeBuild boostBuild)
184 message(STATUS "Using third-party bundled boost")
185 add_subdirectory(boost)
186 # These are the archive names prefixed with lib so that cmake does not
187 # find these to be system archive instead of these third party ones.
191 "libboost_filesystem"
193 "libboost_program_options"
197 CACHE STRING "" FORCE
199 foreach(lib ${Boost_LIBRARIES})
200 add_library(${lib} STATIC IMPORTED)
201 set_property(TARGET ${lib} PROPERTY IMPORTED_LOCATION
202 "${CMAKE_CURRENT_SOURCE_DIR}/boost/build/lib/${lib}.a")
204 set(Boost_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/boost/build/include" CACHE STRING "" FORCE)
205 set(Boost_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/boost/build/lib" CACHE STRING "" FORCE)
206 TP_INSTALL_HEADERS(boost boost/build/include/boost boost)
207 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/boost/build/include")
209 target_include_directories(boost BEFORE INTERFACE ${Boost_INCLUDE_DIRS})
210 target_link_libraries(boost INTERFACE ${Boost_LIBRARIES})
212 add_library(libsodium INTERFACE)
213 add_custom_target(libsodiumMaybeBuild)
214 find_package(LibSodium 1.0.9)
215 if (LIBSODIUM_INCLUDE_DIRS AND LIBSODIUM_LIBRARIES)
216 message(STATUS "Using system libsodium ${LIBSODIUM_VERSION}")
218 message(STATUS "Using third-party bundled libsodium")
219 add_dependencies(libsodiumMaybeBuild libsodiumBuild)
220 add_subdirectory(libsodium EXCLUDE_FROM_ALL)
222 target_include_directories(libsodium INTERFACE ${LIBSODIUM_INCLUDE_DIRS})
223 target_link_libraries(libsodium INTERFACE ${LIBSODIUM_LIBRARIES})
224 add_definitions("-DHAVE_LIBSODIUM")
225 list(APPEND EXTRA_INCLUDE_PATHS "${LIBSODIUM_INCLUDE_DIRS}")
226 list(APPEND THIRD_PARTY_DEFINITIONS "-DHAVE_LIBSODIUM")
228 set(THIRD_PARTY_INCLUDE_PATHS ${EXTRA_INCLUDE_PATHS} CACHE INTERNAL "" FORCE)
230 add_subdirectory("rustc")