Virtualise values in truthy positions
[hiphop-php.git] / third-party / CMakeLists.txt
blob1a6a5a379b948f2bb856721d9fbdfd84da8753c6
1 #   +----------------------------------------------------------------------+
2 #   | HipHop for PHP                                                       |
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 # oniguruma/ is special: it is set up from HPHPFindLibs as it must be included
18 # *first* to take precedence over libc regexp functions
19 add_subdirectory(oniguruma)
21 ##### --- header --- #####
22 set(EXTRA_INCLUDE_PATHS)
23 set(THIRD_PARTY_MODULES)
24 set(THIRD_PARTY_HEADERS)
26 function(TP_INSTALL_HEADERS TARGET SRCDIR DEST)
27   file(GLOB_RECURSE files "${SRCDIR}/*.h")
28   install(
29     CODE "INCLUDE(\"${HPHP_HOME}/CMake/HPHPFunctions.cmake\")
30       HHVM_INSTALL_HEADERS(${TARGET}
31         \"${CMAKE_CURRENT_BINARY_DIR}/${SRCDIR}\"
32       \"\${CMAKE_INSTALL_PREFIX}/include/hphp/third-party/${DEST}\"
33       ${files})"
34     COMPONENT dev)
35 endfunction()
38 ##### easy stuff #####
40 if(JEMALLOC_ENABLED)
41   list(APPEND THIRD_PARTY_MODULES jemalloc)
42 endif()
44 list(APPEND THIRD_PARTY_MODULES forks/libmbfl)
45 list(APPEND EXTRA_INCLUDE_PATHS
46   "${TP_DIR}/forks/libmbfl"
47   "${TP_DIR}/forks/libmbfl/mbfl"
48   "${TP_DIR}/forks/libmbfl/filters"
51 list(APPEND THIRD_PARTY_MODULES forks/timelib)
52 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/forks/timelib")
54 add_subdirectory(zstd) # Required by folly
56 list(APPEND THIRD_PARTY_MODULES folly)
57 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/forks/folly/src")
59 # Fatal is a header-only library, so there's nothing to build.
60 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/fatal")
62 add_subdirectory(brotli) # Required by fizz
64 list(APPEND THIRD_PARTY_MODULES fizz)
65 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/fizz/src")
67 list(APPEND THIRD_PARTY_MODULES wangle)
68 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/wangle/src")
70 list(APPEND THIRD_PARTY_MODULES proxygen)
71 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/proxygen/src")
73 list(APPEND THIRD_PARTY_MODULES fmt)
74 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/fmt/fmt/include")
76 list(APPEND THIRD_PARTY_MODULES thrift)
77 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/thrift/src")
78 list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/thrift/gen")
80 if (NOT MSVC)
81   list(APPEND THIRD_PARTY_MODULES libafdt)
82   list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/libafdt/src/src")
83 endif()
85 add_subdirectory(lz4)
87 # fb-mysql must go after lz4 and zstd because it needs to know its <INSTALL_DIR>
88 add_subdirectory(fb-mysql)
89 find_package(RE2)
90 if(NOT RE2_LIBRARY)
91   message(STATUS "Building RE2 from third-party")
92   add_subdirectory(re2)
93 endif()
94 add_subdirectory(squangle)
96 if (ENABLE_MCROUTER)
97   # Ragel is only used at build time to generate some files for MCRouter.
98   list(APPEND THIRD_PARTY_MODULES forks/ragel)
100   list(APPEND THIRD_PARTY_MODULES mcrouter)
101   list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/mcrouter/src")
102   list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/mcrouter/gen")
103 endif()
105 # Add bundled fastlz if the system one will not be used
106 if(NOT FASTLZ_LIBRARY)
107   list(APPEND THIRD_PARTY_MODULES fastlz)
108   list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/fastlz/src")
109 endif()
111 # Add bundled libsqlite3 if the system one will not be used
112 if(NOT LIBSQLITE3_LIBRARY)
113   list(APPEND THIRD_PARTY_MODULES forks/libsqlite3)
114   list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/forks/libsqlite3")
115 endif()
117 # Add bundled double-conversion if the system one will not be used
118 if(NOT DOUBLE_CONVERSION_FOUND)
119   list(APPEND THIRD_PARTY_MODULES double-conversion)
120   list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/double-conversion")
121 endif()
123 # Add bundled PCRE if the system one will not be used
124 find_package(PCRE)
125 if(NOT PCRE_LIBRARY)
126   list(APPEND THIRD_PARTY_MODULES forks/pcre)
127   # Disable building a few parts of PCRE by default that we don't
128   # actually use.
129   set(PCRE_BUILD_PCRECPP OFF CACHE BOOL "Build the PCRE C++ library (pcrecpp).")
130   set(PCRE_BUILD_PCREGREP OFF CACHE BOOL "Build pcregrep")
131   set(PCRE_BUILD_TESTS OFF CACHE BOOL "Build the tests")
132 endif()
134 # Add bundled libzip if the system one will not be used
135 add_subdirectory(libzip)
137 list(APPEND THIRD_PARTY_MODULES opam)
139 # Add bundled XED library if XED is enabled and the specified XED library
140 # is either not found or incompatible.
141 if(ENABLE_XED AND NOT LibXed_FOUND)
142   list(APPEND THIRD_PARTY_MODULES xed)
143   list(APPEND EXTRA_INCLUDE_PATHS "${TP_DIR}/xed/xed/build/include/xed")
144 endif()
146 ##### boost #####
148 add_subdirectory(boost)
150 ##### libsodium #####
152 add_library(libsodium INTERFACE)
153 add_custom_target(libsodiumMaybeBuild)
154 find_package(LibSodium 1.0.9)
155 if (LIBSODIUM_INCLUDE_DIRS AND LIBSODIUM_LIBRARIES)
156   message(STATUS "Using system libsodium ${LIBSODIUM_VERSION}")
157 else()
158   message(STATUS "Using third-party bundled libsodium")
159   add_dependencies(libsodiumMaybeBuild libsodiumBuild)
160   add_subdirectory(libsodium EXCLUDE_FROM_ALL)
161 endif()
162 target_include_directories(libsodium INTERFACE ${LIBSODIUM_INCLUDE_DIRS})
163 target_link_libraries(libsodium INTERFACE ${LIBSODIUM_LIBRARIES})
164 add_definitions("-DHAVE_LIBSODIUM")
165 list(APPEND EXTRA_INCLUDE_PATHS "${LIBSODIUM_INCLUDE_DIRS}")
166 list(APPEND THIRD_PARTY_DEFINITIONS "-DHAVE_LIBSODIUM")
168 ##### rustc #####
170 add_subdirectory("rustc")
172 ##### --- footer --- #####
174 foreach(MODULE ${THIRD_PARTY_MODULES})
175   add_subdirectory(${MODULE})
176   # Install headers here, rather than in the individual submodules, so that we
177   # can easily control the destination. Put them in include/hphp/third-party.
178   if(MODULE STREQUAL folly)
179     TP_INSTALL_HEADERS(folly folly/src/folly folly)
180   else()
181     TP_INSTALL_HEADERS(${MODULE} ${MODULE} ${MODULE})
182   endif()
183 endforeach()
184 set(THIRD_PARTY_INCLUDE_PATHS ${EXTRA_INCLUDE_PATHS} CACHE INTERNAL "" FORCE)
186 if(NOT PCRE_LIBRARY)
187   target_include_directories(pcre PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/forks/pcre")
188   target_compile_definitions(pcre PUBLIC "PCRE_STATIC=1")
189 endif()