Suppress snprintf "output may be truncated" warnings
[hiphop-php.git] / hphp / CMakeLists.txt
blob4d4a8bd0214aeb71bb1433884403342ab5197694
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(ENABLE_EXTENSION_PGSQL OFF CACHE INTERNAL "" FORCE)
26   set(TP_DIR "${HPHP_HOME}/hphp/public_tld/third-party/")
27   set(TP_BUILD_DIR "${TP_DIR}")
28   set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/facebook/CMake"
29                         "${CMAKE_CURRENT_SOURCE_DIR}/public_tld/CMake"
30                         ${CMAKE_MODULE_PATH})
31   include(HPHPCompiler)
32 endif()
34 include(HHVMProject)
36 include(HHVMExtensionConfig)
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 if (ENABLE_COTIRE)
60   include(cotire)
61   FIND_PATH(LIBC_INCLUDE_PATH stdlib.h)
63   # Detect the architecture-specific include directory
64   IF("${CMAKE_LIBRARY_ARCHITECTURE}" STREQUAL "")
65     # For CentOS/Red Hat where they store it directly in /usr/include
66     SET(ARCH_INCLUDE_PATH "${LIBC_INCLUDE_PATH}/bits")
67   ELSE()
68     FIND_PATH(ARCH_INCLUDE_PATH ${CMAKE_LIBRARY_ARCHITECTURE})
69     SET(ARCH_INCLUDE_PATH "${ARCH_INCLUDE_PATH}/${CMAKE_LIBRARY_ARCHITECTURE}")
70   ENDIF()
72   set_property(DIRECTORY
73     PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH
74       "${LIBC_INCLUDE_PATH}/stdlib.h"
75       "${LIBC_INCLUDE_PATH}/string.h"
76       "${LIBC_INCLUDE_PATH}/ansidecl.h"
77       "${LIBC_INCLUDE_PATH}/bfd.h"
78       "${LIBC_INCLUDE_PATH}/libelf.h"
79       "${LIBC_INCLUDE_PATH}/elf.h"
80       "${LIBC_INCLUDE_PATH}/gelf.h"
81       "${LIBC_INCLUDE_PATH}/resolv.h"
82       "${ARCH_INCLUDE_PATH}"
83       "${CCLIENT_INCLUDE_PATH}"
84       "${JEMALLOC_INCLUDE_DIR}/jemalloc"
85       "${ONIGURUMA_INCLUDE_DIR}/onigposix.h"
86       "${ONIGURUMA_INCLUDE_DIR}/oniguruma.h"
87       "${LIBPNG_INCLUDE_DIRS}/png.h"
88       "${LDAP_INCLUDE_DIR}/ldap.h"
89       "${LIBSQLITE3_INCLUDE_DIR}/sqlite3ext.h"
90       "${CMAKE_SOURCE_DIR}"
91       "${CMAKE_BINARY_DIR}")
93   # XED headers need to be wrapped in extern "C"
94   if (LibXed_INCLUDE_DIR)
95     set_property(DIRECTORY
96       APPEND PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH
97         "${LibXed_INCLUDE_DIR}")
98   endif()
99 endif()
101 # Only thing to do directly in tools is install this one script. Tools also has
102 # its own Makefile, so just do it here instead of dealing with moving that all
103 # around.
104 install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/tools/oss-repo-mode
105   RENAME hhvm-repo-mode
106   DESTINATION bin
107   COMPONENT dev)
109 add_definitions("-DUSE_CMAKE")
111 enable_language(ASM)
113 link_libraries(folly)
114 if (NOT PCRE_LIBRARY)
115   link_libraries(pcre)
116 endif()
118 add_subdirectory(tools/hfsort)
119 add_subdirectory(tools/version)
120 add_subdirectory(tools/tc-print)
122 add_subdirectory(compiler)
123 add_subdirectory(hack)
124 add_subdirectory(hhbbc)
125 add_subdirectory(neo)
126 add_subdirectory(parser)
128 add_subdirectory(runtime)
129 add_subdirectory(runtime/ext)
131 # The runtime/test binary require GTest and GMock to be installed globally
132 option(RUNTIME_TEST_BIN "Create the HHVM runtime/test binary" OFF)
133 if (RUNTIME_TEST_BIN)
134   add_subdirectory(runtime/test)
135 endif ()
137 add_subdirectory(system)
138 add_subdirectory(util)
139 add_subdirectory(ppc64-asm)
140 add_subdirectory(vixl)
141 add_subdirectory(zend)
143 add_subdirectory(hhvm)
145 option(TEST_BIN "Create the HHVM test binary" OFF)
146 if (TEST_BIN)
147   add_subdirectory(test)
148 endif ()
150 add_subdirectory(tools/gdb)
152 include(test/dso_test/dso_test.cmake)
154 # Keep this last
155 add_subdirectory(tools/hphpize)