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 add_subdirectory(libzip)
144 list(APPEND THIRD_PARTY_MODULES ocaml)
146 # Add bundled XED library if XED is enabled and the specified XED library
147 # is either not found or incompatible.
148 if(ENABLE_XED AND NOT LibXed_FOUND)
149 list(APPEND THIRD_PARTY_MODULES xed)
150 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/xed/xed/build/include/xed")
156 find_package(Boost 1.62.0 COMPONENTS context fiber filesystem iostreams program_options regex system thread)
157 if ("${Boost_VERSION}" EQUAL "107000")
158 # https://github.com/boostorg/variant/issues/69
159 message(WARNING "System boost is blacklisted version")
161 set(Boost_FOUND false)
164 add_library(boost INTERFACE)
165 add_custom_target(boostMaybeBuild)
167 # The boost library can't have a dependency on boostBuild because of:
168 # https://public.kitware.com/Bug/view.php?id=15414
169 # Instead we add the dependency to the target being linked with hphp_link
170 add_dependencies(boostMaybeBuild boostBuild)
171 message(STATUS "Using third-party bundled boost")
172 add_subdirectory(boost)
173 # These are the archive names prefixed with lib so that cmake does not
174 # find these to be system archive instead of these third party ones.
178 "libboost_filesystem"
180 "libboost_program_options"
184 CACHE STRING "" FORCE
186 foreach(lib ${Boost_LIBRARIES})
187 add_library(${lib} STATIC IMPORTED)
188 set_property(TARGET ${lib} PROPERTY IMPORTED_LOCATION
189 "${CMAKE_CURRENT_SOURCE_DIR}/boost/build/lib/${lib}.a")
191 set(Boost_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/boost/build/include" CACHE STRING "" FORCE)
192 set(Boost_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/boost/build/lib" CACHE STRING "" FORCE)
193 TP_INSTALL_HEADERS(boost boost/build/include/boost boost)
194 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/boost/build/include")
196 target_include_directories(boost BEFORE INTERFACE ${Boost_INCLUDE_DIRS})
197 target_link_libraries(boost INTERFACE ${Boost_LIBRARIES})
199 ##### libsodium #####
201 add_library(libsodium INTERFACE)
202 add_custom_target(libsodiumMaybeBuild)
203 find_package(LibSodium 1.0.9)
204 if (LIBSODIUM_INCLUDE_DIRS AND LIBSODIUM_LIBRARIES)
205 message(STATUS "Using system libsodium ${LIBSODIUM_VERSION}")
207 message(STATUS "Using third-party bundled libsodium")
208 add_dependencies(libsodiumMaybeBuild libsodiumBuild)
209 add_subdirectory(libsodium EXCLUDE_FROM_ALL)
211 target_include_directories(libsodium INTERFACE ${LIBSODIUM_INCLUDE_DIRS})
212 target_link_libraries(libsodium INTERFACE ${LIBSODIUM_LIBRARIES})
213 add_definitions("-DHAVE_LIBSODIUM")
214 list(APPEND EXTRA_INCLUDE_PATHS "${LIBSODIUM_INCLUDE_DIRS}")
215 list(APPEND THIRD_PARTY_DEFINITIONS "-DHAVE_LIBSODIUM")
219 add_subdirectory("rustc")
221 ##### --- footer --- #####
223 foreach(MODULE ${THIRD_PARTY_MODULES})
224 add_subdirectory(${MODULE})
225 # Install headers here, rather than in the individual submodules, so that we
226 # can easily control the destination. Put them in include/hphp/third-party.
227 if(MODULE STREQUAL folly)
228 TP_INSTALL_HEADERS(folly folly/src/folly folly)
230 TP_INSTALL_HEADERS(${MODULE} ${MODULE} ${MODULE})
233 set(THIRD_PARTY_INCLUDE_PATHS ${EXTRA_INCLUDE_PATHS} CACHE INTERNAL "" FORCE)
236 target_include_directories(pcre PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/forks/pcre")
237 target_compile_definitions(pcre PUBLIC "PCRE_STATIC=1")