Deshim VirtualExecutor in folly
[hiphop-php.git] / hphp / CMakeLists.txt
blobb97f7baaf4d9650af174f62e56b19fc56eec4c24
2 #   +----------------------------------------------------------------------+
3 #   | HipHop for PHP                                                       |
4 #   +----------------------------------------------------------------------+
5 #   | Copyright (c) 2010 Facebook, Inc. (http://www.facebook.com)          |
6 #   | Copyright (c) 1997-2010 The PHP Group                                |
7 #   +----------------------------------------------------------------------+
8 #   | This source file is subject to version 3.01 of the PHP license,      |
9 #   | that is bundled with this package in the file LICENSE, and is        |
10 #   | available through the world-wide-web at the following url:           |
11 #   | http://www.php.net/license/3_01.txt                                  |
12 #   | If you did not receive a copy of the PHP license and are unable to   |
13 #   | obtain it through the world-wide-web, please send a note to          |
14 #   | license@php.net so we can mail you a copy immediately.               |
15 #   +----------------------------------------------------------------------+
18 add_definitions("-DHHVM")
20 if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/facebook")
21   # I'm sorry, but facebook's internal repo has the top level dir stored inside
22   # of hphp/, so we need to pull that one in first if it exists
23   CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7 FATAL_ERROR)
24   get_filename_component(HPHP_HOME "${CMAKE_CURRENT_SOURCE_DIR}/.." ABSOLUTE)
25   set(TP_DIR "${HPHP_HOME}/hphp/public_tld/third-party/")
26   set(TP_BUILD_DIR "${TP_DIR}")
27   set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/facebook/CMake"
28                         "${CMAKE_CURRENT_SOURCE_DIR}/public_tld/CMake"
29                         ${CMAKE_MODULE_PATH})
30   include(HPHPCompiler)
31 endif()
33 include(HHVMProject)
35 include(HHVMExtensionConfig)
36 add_custom_target(generated_systemlib)
37 # Before we do anything else, we'll configure the extensions,
38 # so that the defines take effect globally.
39 file(GLOB subdirs ${CMAKE_CURRENT_SOURCE_DIR}/runtime/ext/*)
40 foreach (dir ${subdirs})
41   if (IS_DIRECTORY ${dir})
42     if (EXISTS "${dir}/config.cmake")
43       set(HRE_CURRENT_EXT_PATH "${dir}")
44       include("${dir}/config.cmake")
45     endif()
46   endif()
47 endforeach()
48 HHVM_EXTENSION_RESOLVE_DEPENDENCIES()
50 if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/facebook")
51   include(FBTLD)
52 endif()
54 include(HPHPSetup)
55 include(HPHPFindLibs)
56 include(HHVMGenerateConfig)
57 HHVM_GENERATE_CONFIG("${CMAKE_CURRENT_BINARY_DIR}/util/hphp-config.h")
59 # Link against this target if you `#include "hphp/runtime/base/foo.h"`; it
60 # brings in all the transitive dependencies (e.g. rust FFI, folly, boost)
62 # It's currently really the wrong way around: we should declare all the
63 # dependencies directly against this target without using `hphp_link()`, then
64 # `hphp_link()` should be changed to link against this target. Done like this
65 # for now to minimize risk while unblocking adding new dependencies.
67 # Even that's wrong: given improvements in CMake over the years, we don't need
68 # and should remove many of the HPHP/hphp/HHVM CMake macros, including
69 # hphp_link, and just use target_link_libraries throughout.
70 add_library(hhvm_base_headers INTERFACE)
71 hphp_link(hhvm_base_headers INTERFACE)
72 target_include_directories(hhvm_base_headers INTERFACE ${CMAKE_SOURCE_DIR})
74 if (ENABLE_COTIRE)
75   include(cotire)
76   FIND_PATH(LIBC_INCLUDE_PATH stdlib.h)
78   # Detect the architecture-specific include directory
79   IF("${CMAKE_LIBRARY_ARCHITECTURE}" STREQUAL "")
80     # For CentOS/Red Hat where they store it directly in /usr/include
81     SET(ARCH_INCLUDE_PATH "${LIBC_INCLUDE_PATH}/bits")
82   ELSE()
83     FIND_PATH(ARCH_INCLUDE_PATH ${CMAKE_LIBRARY_ARCHITECTURE})
84     SET(ARCH_INCLUDE_PATH "${ARCH_INCLUDE_PATH}/${CMAKE_LIBRARY_ARCHITECTURE}")
85   ENDIF()
87   set_property(DIRECTORY
88     PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH
89       "${LIBC_INCLUDE_PATH}/stdlib.h"
90       "${LIBC_INCLUDE_PATH}/string.h"
91       "${LIBC_INCLUDE_PATH}/ansidecl.h"
92       "${LIBC_INCLUDE_PATH}/bfd.h"
93       "${LIBC_INCLUDE_PATH}/libelf.h"
94       "${LIBC_INCLUDE_PATH}/elf.h"
95       "${LIBC_INCLUDE_PATH}/gelf.h"
96       "${LIBC_INCLUDE_PATH}/resolv.h"
97       "${ARCH_INCLUDE_PATH}"
98       "${CCLIENT_INCLUDE_PATH}"
99       "${LIBPNG_INCLUDE_DIRS}/png.h"
100       "${LDAP_INCLUDE_DIR}/ldap.h"
101       "${LIBSQLITE3_INCLUDE_DIR}/sqlite3ext.h"
102       "${CMAKE_SOURCE_DIR}"
103       "${CMAKE_BINARY_DIR}")
105   # XED headers need to be wrapped in extern "C"
106   if (ENABLE_XED)
107     if (LibXed_INCLUDE_DIR)
108       set_property(DIRECTORY
109           APPEND PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH
110             "${LibXed_INCLUDE_DIR}")
111     else()
112       set_property(DIRECTORY
113           APPEND PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH
114             "${TP_DIR}/xed/xed/build/include/xed")
115     endif()
116   endif()
117 endif()
119 # Only thing to do directly in tools is install this one script. Tools also has
120 # its own Makefile, so just do it here instead of dealing with moving that all
121 # around.
122 install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/tools/oss-repo-mode
123   RENAME hhvm-repo-mode
124   DESTINATION bin
125   COMPONENT dev)
127 add_definitions("-DUSE_CMAKE")
129 enable_language(ASM)
131 if (NOT PCRE_LIBRARY)
132   link_libraries(pcre)
133 endif()
135 add_subdirectory(tools/hfsort)
136 add_subdirectory(tools/version)
137 add_subdirectory(tools/tc-print)
139 add_subdirectory(compiler)
140 add_subdirectory(hack)
141 add_subdirectory(hhbbc)
142 add_subdirectory(neo)
144 add_subdirectory(runtime)
145 add_subdirectory(runtime/ext)
147 # The runtime/test binary require GTest and GMock to be installed globally
148 option(RUNTIME_TEST_BIN "Create the HHVM runtime/test binary" OFF)
149 if (RUNTIME_TEST_BIN)
150   add_subdirectory(runtime/test)
151 endif ()
153 add_subdirectory(system)
154 add_subdirectory(util)
155 add_subdirectory(vixl)
156 add_subdirectory(zend)
158 add_subdirectory(hhvm)
160 option(TEST_BIN "Create the HHVM test binary" OFF)
161 if (TEST_BIN)
162   add_subdirectory(test)
163 endif ()
165 add_subdirectory(tools/gdb)
167 include(test/dso_test/dso_test.cmake)
169 # Keep this last
170 add_subdirectory(tools/hphpize)