Remove the need for anchor-syms.cpp
[hiphop-php.git] / CMake / HPHPSetup.cmake
blob0718128e21e41e11f96414fbd4b7273fa1d931a4
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 if (APPLE OR IS_AARCH64)
12         set(HHVM_ANCHOR_SYMS
13             -Wl,-u,_register_libevent_server
14             -Wl,-all_load hphp_runtime_static)
15 else()
16         set(ENABLE_FASTCGI 1)
17         set(HHVM_ANCHOR_SYMS
18             -Wl,-uregister_libevent_server,-uregister_fastcgi_server
19             -Wl,--whole-archive hphp_runtime_static -Wl,--no-whole-archive)
20 endif()
22 set(HHVM_LINK_LIBRARIES
23     ${HHVM_ANCHOR_SYMS}
24     hphp_analysis
25     ext_hhvm_static
26     hphp_system
27     hphp_parser
28     hphp_zend
29     hphp_util
30     hphp_hhbbc
31     vixl neo)
33 if(ENABLE_FASTCGI)
34         LIST(APPEND HHVM_LINK_LIBRARIES hphp_thrift)
35         LIST(APPEND HHVM_LINK_LIBRARIES hphp_proxygen)
36 endif()
38 if(NOT CMAKE_BUILD_TYPE)
39         set(CMAKE_BUILD_TYPE "Release")
40 endif()
42 IF(NOT DEFINED CMAKE_PREFIX_PATH)
43   message(STATUS "CMAKE_PREFIX_PATH was missing, proceeding anyway")
44 endif()
46 # Look for the chrpath tool so we can warn if it's not there
47 find_program(CHRPATH chrpath)
48 IF (CHRPATH STREQUAL "CHRPATH-NOTFOUND")
49     SET(FOUND_CHRPATH OFF)
50     message(WARNING "chrpath not found, rpath will not be stripped from installed binaries")
51 else()
52     SET(FOUND_CHRPATH ON)
53 endif()
55 LIST(APPEND CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
57 if(APPLE)
58         if(EXISTS "/opt/local/var/macports/")
59                 LIST (APPEND CMAKE_PREFIX_PATH "/opt/local")
60                 LIST (APPEND CMAKE_LIBRARY_PATH "/opt/local/lib/x86_64")
61         endif()
62 endif()
64 include(HPHPCompiler)
65 include(HPHPFunctions)
66 include(HPHPFindLibs)
68 add_definitions(-D_REENTRANT=1 -D_PTHREADS=1 -D__STDC_FORMAT_MACROS -DFOLLY_HAVE_WEAK_SYMBOLS=1)
70 if (LINUX)
71         add_definitions(-D_GNU_SOURCE)
72 endif()
74 if(${CMAKE_BUILD_TYPE} MATCHES "Release")
75         add_definitions(-DRELEASE=1)
76         add_definitions(-DNDEBUG)
77         message("Generating Release build")
78 else()
79         add_definitions(-DDEBUG)
80         message("Generating DEBUG build")
81 endif()
83 if(DEBUG_MEMORY_LEAK)
84         add_definitions(-DDEBUG_MEMORY_LEAK=1)
85 endif()
87 if(DEBUG_APC_LEAK)
88         add_definitions(-DDEBUG_APC_LEAK=1)
89 endif()
91 if(ALWAYS_ASSERT)
92         add_definitions(-DALWAYS_ASSERT=1)
93 endif()
95 if(HOTPROFILER)
96         add_definitions(-DHOTPROFILER=1)
97 endif()
99 if(EXECUTION_PROFILER)
100         add_definitions(-DEXECUTION_PROFILER=1)
101 endif()
103 if(ENABLE_FULL_SETLINE)
104         add_definitions(-DENABLE_FULL_SETLINE=1)
105 endif()
107 if(APPLE OR FREEBSD)
108         add_definitions(-DSKIP_USER_CHANGE=1)
109 endif()
111 if(APPLE)
112         # We have to be a little more permissive in some cases.
113         add_definitions(-fpermissive)
115         # Skip deprecation warnings in OpenSSL. 
116         add_definitions(-DMAC_OS_X_VERSION_MIN_REQUIRED=MAC_OS_X_VERSION_10_6)
118         # Just assume we have sched.h
119         add_definitions(-DFOLLY_HAVE_SCHED_H=1)
121         # Enable weak linking
122         add_definitions(-DMACOSX_DEPLOYMENT_TARGET=10.6)
123 endif()
125 if(ENABLE_FASTCGI)
126         add_definitions(-DENABLE_FASTCGI=1)
127 endif ()
129 if(DISABLE_HARDWARE_COUNTERS)
130         add_definitions(-DNO_HARDWARE_COUNTERS=1)
131 endif ()
133 # enable the OSS options if we have any
134 add_definitions(-DHPHP_OSS=1)
136 # later versions of binutils don't play well without automake
137 add_definitions(-DPACKAGE=hhvm -DPACKAGE_VERSION=Release)
139 include_directories(${HPHP_HOME}/hphp)
140 include_directories(${HPHP_HOME}/hphp/lib/system/gen)
141 include_directories(${HPHP_HOME})