Remove QuickLZ from OSS builds
[hiphop-php.git] / CMake / HPHPSetup.cmake
blobebc51229a7abd53aed2ac832fe833056ebb124e5
1 include(Options)
3 # Do this until cmake has a define for ARMv8
4 INCLUDE(CheckCXXSourceCompiles)
5 CHECK_CXX_SOURCE_COMPILES("
6 #ifndef __AARCH64EL__
7 #error Not ARMv8
8 #endif
9 int main() { return 0; }" IS_AARCH64)
11 set(HHVM_WHOLE_ARCHIVE_LIBRARIES
12     hphp_runtime_static
13     hphp_runtime_ext
14    )
16 if (ENABLE_ZEND_COMPAT)
17   add_definitions("-DENABLE_ZEND_COMPAT=1")
18   list(APPEND HHVM_WHOLE_ARCHIVE_LIBRARIES hphp_ext_zend_compat)
19 endif()
21 if (APPLE)
22   set(ENABLE_FASTCGI 1)
23   set(HHVM_ANCHOR_SYMS
24     -Wl,-u,_register_fastcgi_server
25     -Wl,-segaddr __text 0
26     -Wl,-all_load ${HHVM_WHOLE_ARCHIVE_LIBRARIES})
27 elseif (IS_AARCH64)
28   set(HHVM_ANCHOR_SYMS
29     -Wl,--whole-archive ${HHVM_WHOLE_ARCHIVE_LIBRARIES} -Wl,--no-whole-archive)
30 elseif(CYGWIN)
31   set(ENABLE_FASTCGI 0)
32   set(HHVM_ANCHOR_SYMS
33   -Wl,--whole-archive ${HHVM_WHOLE_ARCHIVE_LIBRARIES} -Wl,--no-whole-archive)
34 else()
35   set(ENABLE_FASTCGI 1)
36   set(HHVM_ANCHOR_SYMS
37     -Wl,-uregister_libevent_server,-uregister_fastcgi_server
38     -Wl,--whole-archive ${HHVM_WHOLE_ARCHIVE_LIBRARIES} -Wl,--no-whole-archive)
39 endif()
41 if (LINUX)
42   set(HHVM_WRAP_SYMS -Wl,--wrap=pthread_create -Wl,--wrap=pthread_exit -Wl,--wrap=pthread_join)
43 else ()
44   set(HHVM_WRAP_SYMS)
45 endif ()
47 set(HHVM_LINK_LIBRARIES
48   ${HHVM_ANCHOR_SYMS}
49   ${HHVM_WRAP_SYMS}
50   hphp_analysis
51   ext_hhvm_static
52   hphp_system
53   hphp_parser
54   hphp_zend
55   hphp_util
56   hphp_hhbbc
57   vixl neo)
59 if(ENABLE_FASTCGI)
60   LIST(APPEND HHVM_LINK_LIBRARIES hphp_thrift)
61   LIST(APPEND HHVM_LINK_LIBRARIES hphp_proxygen)
62 endif()
64 if(NOT CMAKE_BUILD_TYPE)
65   set(CMAKE_BUILD_TYPE "Release")
66   message(STATUS "Build type not specified: cmake build type Release.")
67 endif()
69 if(HHVM_DYNAMIC_EXTENSION_DIR)
70   add_definitions(-DHHVM_DYNAMIC_EXTENSION_DIR="${HHVM_DYNAMIC_EXTENSION_DIR}")
71 else()
72   if(UNIX)
73     add_definitions(-DHHVM_DYNAMIC_EXTENSION_DIR="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/hhvm/extensions")
74   endif()
75 endif()
77 # Look for the chrpath tool so we can warn if it's not there
78 SET(FOUND_CHRPATH OFF)
79 IF(UNIX AND NOT APPLE)
80     find_program(CHRPATH chrpath)
81     IF (NOT CHRPATH STREQUAL "CHRPATH-NOTFOUND")
82         SET(FOUND_CHRPATH ON)
83     endif()
84 ENDIF(UNIX AND NOT APPLE)
86 LIST(APPEND CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
88 if(APPLE)
89   if(EXISTS "/opt/local/var/macports/")
90     LIST (APPEND CMAKE_PREFIX_PATH "/opt/local")
91     LIST (APPEND CMAKE_LIBRARY_PATH "/opt/local/lib/x86_64")
92   endif()
93 endif()
95 include(HPHPCompiler)
96 include(HPHPFunctions)
97 include(HPHPFindLibs)
99 # Weak linking on Linux, Windows, and OS X all work somewhat differently. The following test
100 # works well on Linux and Windows, but fails for annoying reasons on OS X, and even works
101 # differently on different releases of OS X, cf. http://glandium.org/blog/?p=2764. Getting
102 # the test to work properly on OS X would require an APPLE check anyways, so just hardcode
103 # OS X as "we know weak linking works".
104 if(APPLE)
105   set(FOLLY_HAVE_WEAK_SYMBOLS 1)
106 else()
107   # check for weak symbols
108   CHECK_CXX_SOURCE_COMPILES("
109       extern \"C\" void configure_link_extern_weak_test() __attribute__((weak));
110       int main(int argc, char** argv) {
111           return configure_link_extern_weak_test == nullptr;
112       }
113   "
114       FOLLY_HAVE_WEAK_SYMBOLS
115   )
116 endif()
118 if(FOLLY_HAVE_WEAK_SYMBOLS)
119   add_definitions(-DFOLLY_HAVE_WEAK_SYMBOLS=1)
120 else()
121   add_definitions(-DFOLLY_HAVE_WEAK_SYMBOLS=0)
122 endif()
124 add_definitions(-D_REENTRANT=1 -D_PTHREADS=1 -D__STDC_FORMAT_MACROS)
126 if (LINUX)
127   add_definitions(-D_GNU_SOURCE)
128 endif()
130 # cygwin headers are easily confused
131 if(CYGWIN)
132   add_definitions(-D_GLIBCXX_USE_C99=1)
133 endif()
135 if(MSVC OR CYGWIN OR MINGW)
136   add_definitions(-DNOUSER=1 -DGLOG_NO_ABBREVIATED_SEVERITIES)
137   add_definitions(-DWIN32_LEAN_AND_MEAN)
138 endif()
140 if(${CMAKE_BUILD_TYPE} MATCHES "Release")
141   add_definitions(-DRELEASE=1)
142   add_definitions(-DNDEBUG)
143   message("Generating Release build")
144 else()
145   add_definitions(-DDEBUG)
146   message("Generating DEBUG build")
147 endif()
149 if(DEBUG_MEMORY_LEAK)
150   add_definitions(-DDEBUG_MEMORY_LEAK=1)
151 endif()
153 if(DEBUG_APC_LEAK)
154   add_definitions(-DDEBUG_APC_LEAK=1)
155 endif()
157 if(ALWAYS_ASSERT)
158   add_definitions(-DALWAYS_ASSERT=1)
159 endif()
161 if(EXECUTION_PROFILER)
162   add_definitions(-DEXECUTION_PROFILER=1)
163 endif()
165 if(ENABLE_FULL_SETLINE)
166   add_definitions(-DENABLE_FULL_SETLINE=1)
167 endif()
169 if(APPLE OR FREEBSD OR CYGWIN OR MSVC OR MINGW)
170   add_definitions(-DSKIP_USER_CHANGE=1)
171 endif()
173 if(ENABLE_TRACE)
174     add_definitions(-DUSE_TRACE=1)
175 endif()
177 if(APPLE)
178   # We have to be a little more permissive in some cases.
179   add_definitions(-fpermissive)
181   # Skip deprecation warnings in OpenSSL.
182   add_definitions(-DMAC_OS_X_VERSION_MIN_REQUIRED=MAC_OS_X_VERSION_10_6)
184   # Just assume we have sched.h
185   add_definitions(-DFOLLY_HAVE_SCHED_H=1)
187   # Enable weak linking
188   add_definitions(-DMACOSX_DEPLOYMENT_TARGET=10.6)
189 endif()
191 if(ENABLE_FASTCGI)
192   add_definitions(-DENABLE_FASTCGI=1)
193 endif ()
195 if(DISABLE_HARDWARE_COUNTERS)
196   add_definitions(-DNO_HARDWARE_COUNTERS=1)
197 endif ()
199 if(PACKED_TV)
200   # Allows a packed tv build
201   add_definitions(-DPACKED_TV=1)
202 endif()
204 # enable the OSS options if we have any
205 add_definitions(-DHPHP_OSS=1)
207 # later versions of binutils don't play well without automake
208 add_definitions(-DPACKAGE=hhvm -DPACKAGE_VERSION=Release)
210 if (NOT LIBSQLITE3_INCLUDE_DIR)
211   include_directories("${TP_DIR}/libsqlite3")
212 endif()
214 if (NOT DOUBLE_CONVERSION_LIBRARY)
215   include_directories("${TP_DIR}/double-conversion/src")
216 endif()
218 if (NOT LZ4_LIBRARY)
219   include_directories("${TP_DIR}/lz4")
220 endif()
222 if (NOT LIBZIP_INCLUDE_DIR_ZIP)
223   include_directories("${TP_DIR}/libzip")
224 endif()
226 if (NOT PCRE_LIBRARY)
227   include_directories("${TP_DIR}/pcre")
228 endif()
230 include_directories("${TP_DIR}/fastlz")
231 include_directories("${TP_DIR}/timelib")
232 include_directories("${TP_DIR}/libafdt/src")
233 include_directories("${TP_DIR}/libmbfl")
234 include_directories("${TP_DIR}/libmbfl/mbfl")
235 include_directories("${TP_DIR}/libmbfl/filter")
236 add_definitions(-DNO_LIB_GFLAGS)
237 include_directories("${TP_DIR}/folly")
238 include_directories("${TP_DIR}/thrift")
239 include_directories(${TP_DIR})
241 include_directories(${HPHP_HOME}/hphp)
242 include_directories(${HPHP_HOME})