3 # Do this until cmake has a define for ARMv8
4 INCLUDE(CheckCXXSourceCompiles)
5 CHECK_CXX_SOURCE_COMPILES("
9 int main() { return 0; }" IS_AARCH64)
11 set(HHVM_WHOLE_ARCHIVE_LIBRARIES
16 if (ENABLE_ZEND_COMPAT)
17 add_definitions("-DENABLE_ZEND_COMPAT=1")
18 list(APPEND HHVM_WHOLE_ARCHIVE_LIBRARIES hphp_ext_zend_compat)
24 -Wl,-u,_register_fastcgi_server
26 -Wl,-all_load ${HHVM_WHOLE_ARCHIVE_LIBRARIES})
29 -Wl,--whole-archive ${HHVM_WHOLE_ARCHIVE_LIBRARIES} -Wl,--no-whole-archive)
33 -Wl,--whole-archive ${HHVM_WHOLE_ARCHIVE_LIBRARIES} -Wl,--no-whole-archive)
37 -Wl,-uregister_libevent_server,-uregister_fastcgi_server
38 -Wl,--whole-archive ${HHVM_WHOLE_ARCHIVE_LIBRARIES} -Wl,--no-whole-archive)
42 set(HHVM_WRAP_SYMS -Wl,--wrap=pthread_create -Wl,--wrap=pthread_exit -Wl,--wrap=pthread_join)
47 set(HHVM_LINK_LIBRARIES
60 LIST(APPEND HHVM_LINK_LIBRARIES hphp_thrift)
61 LIST(APPEND HHVM_LINK_LIBRARIES hphp_proxygen)
64 if(NOT CMAKE_BUILD_TYPE)
65 set(CMAKE_BUILD_TYPE "Release")
66 message(STATUS "Build type not specified: cmake build type Release.")
69 if(HHVM_DYNAMIC_EXTENSION_DIR)
70 add_definitions(-DHHVM_DYNAMIC_EXTENSION_DIR="${HHVM_DYNAMIC_EXTENSION_DIR}")
73 add_definitions(-DHHVM_DYNAMIC_EXTENSION_DIR="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/hhvm/extensions")
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")
84 ENDIF(UNIX AND NOT APPLE)
86 LIST(APPEND CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
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")
96 include(HPHPFunctions)
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".
105 set(FOLLY_HAVE_WEAK_SYMBOLS 1)
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;
114 FOLLY_HAVE_WEAK_SYMBOLS
118 if(FOLLY_HAVE_WEAK_SYMBOLS)
119 add_definitions(-DFOLLY_HAVE_WEAK_SYMBOLS=1)
121 add_definitions(-DFOLLY_HAVE_WEAK_SYMBOLS=0)
124 add_definitions(-D_REENTRANT=1 -D_PTHREADS=1 -D__STDC_FORMAT_MACROS)
127 add_definitions(-D_GNU_SOURCE)
130 # cygwin headers are easily confused
132 add_definitions(-D_GLIBCXX_USE_C99=1)
135 if(MSVC OR CYGWIN OR MINGW)
136 add_definitions(-DNOUSER=1 -DGLOG_NO_ABBREVIATED_SEVERITIES)
137 add_definitions(-DWIN32_LEAN_AND_MEAN)
140 if(${CMAKE_BUILD_TYPE} MATCHES "Release")
141 add_definitions(-DRELEASE=1)
142 add_definitions(-DNDEBUG)
143 message("Generating Release build")
145 add_definitions(-DDEBUG)
146 message("Generating DEBUG build")
149 if(DEBUG_MEMORY_LEAK)
150 add_definitions(-DDEBUG_MEMORY_LEAK=1)
154 add_definitions(-DDEBUG_APC_LEAK=1)
158 add_definitions(-DALWAYS_ASSERT=1)
161 if(EXECUTION_PROFILER)
162 add_definitions(-DEXECUTION_PROFILER=1)
165 if(ENABLE_FULL_SETLINE)
166 add_definitions(-DENABLE_FULL_SETLINE=1)
169 if(APPLE OR FREEBSD OR CYGWIN OR MSVC OR MINGW)
170 add_definitions(-DSKIP_USER_CHANGE=1)
174 add_definitions(-DUSE_TRACE=1)
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)
192 add_definitions(-DENABLE_FASTCGI=1)
195 if(DISABLE_HARDWARE_COUNTERS)
196 add_definitions(-DNO_HARDWARE_COUNTERS=1)
200 # Allows a packed tv build
201 add_definitions(-DPACKED_TV=1)
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")
214 if (NOT DOUBLE_CONVERSION_LIBRARY)
215 include_directories("${TP_DIR}/double-conversion/src")
219 include_directories("${TP_DIR}/lz4")
222 if (NOT LIBZIP_INCLUDE_DIR_ZIP)
223 include_directories("${TP_DIR}/libzip")
226 if (NOT PCRE_LIBRARY)
227 include_directories("${TP_DIR}/pcre")
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})