Prefix native systemlibs with /:systemlib
[hiphop-php.git] / CMake / HPHPSetup.cmake
blobad135f226b4447d17687b73143ccd7cd1e850521
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     hphp_ext_zend_compat
15    )
17 if (APPLE)
18         set(HHVM_ANCHOR_SYMS
19             -Wl,-u,_register_libevent_server
20             -Wl,-all_load ${HHVM_WHOLE_ARCHIVE_LIBRARIES})
21 elseif (IS_AARCH64)
22         set(HHVM_ANCHOR_SYMS
23             -Wl,-uregister_libevent_server
24             -Wl,--whole-archive ${HHVM_WHOLE_ARCHIVE_LIBRARIES} -Wl,--no-whole-archive)
25 else()
26         set(ENABLE_FASTCGI 1)
27         set(HHVM_ANCHOR_SYMS
28             -Wl,-uregister_libevent_server,-uregister_fastcgi_server
29             -Wl,--whole-archive ${HHVM_WHOLE_ARCHIVE_LIBRARIES} -Wl,--no-whole-archive)
30 endif()
32 set(HHVM_LINK_LIBRARIES
33     ${HHVM_ANCHOR_SYMS}
34     hphp_analysis
35     ext_hhvm_static
36     hphp_system
37     hphp_parser
38     hphp_zend
39     hphp_util
40     hphp_hhbbc
41     vixl neo)
43 if(ENABLE_FASTCGI)
44         LIST(APPEND HHVM_LINK_LIBRARIES hphp_thrift)
45         LIST(APPEND HHVM_LINK_LIBRARIES hphp_proxygen)
46 endif()
48 if(NOT CMAKE_BUILD_TYPE)
49         set(CMAKE_BUILD_TYPE "Release")
50 endif()
52 IF(NOT DEFINED CMAKE_PREFIX_PATH)
53   message(STATUS "CMAKE_PREFIX_PATH was missing, proceeding anyway")
54 endif()
56 # Look for the chrpath tool so we can warn if it's not there
57 find_program(CHRPATH chrpath)
58 IF (CHRPATH STREQUAL "CHRPATH-NOTFOUND")
59     SET(FOUND_CHRPATH OFF)
60     message(WARNING "chrpath not found, rpath will not be stripped from installed binaries")
61 else()
62     SET(FOUND_CHRPATH ON)
63 endif()
65 LIST(APPEND CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
67 if(APPLE)
68         if(EXISTS "/opt/local/var/macports/")
69                 LIST (APPEND CMAKE_PREFIX_PATH "/opt/local")
70                 LIST (APPEND CMAKE_LIBRARY_PATH "/opt/local/lib/x86_64")
71         endif()
72 endif()
74 include(HPHPCompiler)
75 include(HPHPFunctions)
76 include(HPHPFindLibs)
78 add_definitions(-D_REENTRANT=1 -D_PTHREADS=1 -D__STDC_FORMAT_MACROS -DFOLLY_HAVE_WEAK_SYMBOLS=1)
80 if (LINUX)
81         add_definitions(-D_GNU_SOURCE)
82 endif()
84 if(${CMAKE_BUILD_TYPE} MATCHES "Release")
85         add_definitions(-DRELEASE=1)
86         add_definitions(-DNDEBUG)
87         message("Generating Release build")
88 else()
89         add_definitions(-DDEBUG)
90         message("Generating DEBUG build")
91 endif()
93 if(DEBUG_MEMORY_LEAK)
94         add_definitions(-DDEBUG_MEMORY_LEAK=1)
95 endif()
97 if(DEBUG_APC_LEAK)
98         add_definitions(-DDEBUG_APC_LEAK=1)
99 endif()
101 if(ALWAYS_ASSERT)
102         add_definitions(-DALWAYS_ASSERT=1)
103 endif()
105 if(HOTPROFILER)
106         add_definitions(-DHOTPROFILER=1)
107 endif()
109 if(EXECUTION_PROFILER)
110         add_definitions(-DEXECUTION_PROFILER=1)
111 endif()
113 if(ENABLE_FULL_SETLINE)
114         add_definitions(-DENABLE_FULL_SETLINE=1)
115 endif()
117 if(APPLE OR FREEBSD)
118         add_definitions(-DSKIP_USER_CHANGE=1)
119 endif()
121 if(APPLE)
122         # We have to be a little more permissive in some cases.
123         add_definitions(-fpermissive)
125         # Skip deprecation warnings in OpenSSL.
126         add_definitions(-DMAC_OS_X_VERSION_MIN_REQUIRED=MAC_OS_X_VERSION_10_6)
128         # Just assume we have sched.h
129         add_definitions(-DFOLLY_HAVE_SCHED_H=1)
131         # Enable weak linking
132         add_definitions(-DMACOSX_DEPLOYMENT_TARGET=10.6)
133 endif()
135 if(ENABLE_FASTCGI)
136         add_definitions(-DENABLE_FASTCGI=1)
137 endif ()
139 if(DISABLE_HARDWARE_COUNTERS)
140         add_definitions(-DNO_HARDWARE_COUNTERS=1)
141 endif ()
143 # enable the OSS options if we have any
144 add_definitions(-DHPHP_OSS=1)
146 # later versions of binutils don't play well without automake
147 add_definitions(-DPACKAGE=hhvm -DPACKAGE_VERSION=Release)
149 include_directories(${HPHP_HOME}/hphp)
150 include_directories(${HPHP_HOME})