Ensure flow control commands don't remove internal breakpoints set by real breakpoints
[hiphop-php.git] / CMake / HPHPSetup.cmake
blobce65844294b9e7b80ce26d7caea7fabd6376ddf4
1 include(Options)
3 if(NOT CMAKE_BUILD_TYPE)
4         set(CMAKE_BUILD_TYPE "Release")
5 endif()
7 IF(NOT DEFINED CMAKE_PREFIX_PATH)
8   message(STATUS "CMAKE_PREFIX_PATH was missing, proceeding anyway")
9 endif()
11 if(CMAKE_COMPILER_IS_GNUCC)
12         INCLUDE(CheckCSourceCompiles)
13         CHECK_C_SOURCE_COMPILES("#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
14 #if GCC_VERSION < 40600
15 #error Need GCC 4.6.0+
16 #endif
17 int main() { return 0; }" HAVE_GCC_46)
19         if(NOT HAVE_GCC_46)
20                 message(FATAL_ERROR "Need at least GCC 4.6")
21         endif()
23 endif()
25 set(FREEBSD FALSE)
26 set(LINUX FALSE)
28 if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
29         set(FREEBSD TRUE)
30 endif()
32 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
33         set(LINUX TRUE)
34 endif()
36 LIST(APPEND CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
38 if(APPLE)
39         if(EXISTS "/opt/local/var/macports/")
40                 LIST (APPEND CMAKE_PREFIX_PATH "/opt/local")
41                 LIST (APPEND CMAKE_LIBRARY_PATH "/opt/local/lib/x86_64")
42         endif()
43 endif()
45 include(HPHPFunctions)
46 include(HPHPFindLibs)
48 add_definitions(-D_REENTRANT=1 -D_PTHREADS=1 -D__STDC_FORMAT_MACROS)
49 add_definitions(-DHHVM_LIB_PATH_DEFAULT="${HPHP_HOME}/bin")
51 if (LINUX)
52         add_definitions(-D_GNU_SOURCE)
53 endif()
55 if(${CMAKE_BUILD_TYPE} MATCHES "Release")
56         add_definitions(-DRELEASE=1)
57         add_definitions(-DNDEBUG)
58         message("Generating Release build")
59 else()
60         add_definitions(-DDEBUG)
61         message("Generating DEBUG build")
62 endif()
64 if(INFINITE_LOOP_DETECTION)
65         add_definitions(-DINFINITE_LOOP_DETECTION=1)
66 endif()
68 if(INFINITE_RECURSION_DETECTION)
69         add_definitions(-DINFINITE_RECURSION_DETECTION=1)
70 endif()
72 if(REQUEST_TIMEOUT_DETECTION)
73         add_definitions(-DREQUEST_TIMEOUT_DETECTION=1)
74 endif()
76 if(ENABLE_LATE_STATIC_BINDING)
77         add_definitions(-DENABLE_LATE_STATIC_BINDING=1)
78 endif()
80 if(DEBUG_MEMORY_LEAK)
81         add_definitions(-DDEBUG_MEMORY_LEAK=1)
82 endif()
84 if(DEBUG_APC_LEAK)
85         add_definitions(-DDEBUG_APC_LEAK=1)
86 endif()
88 if(ALWAYS_ASSERT)
89         add_definitions(-DALWAYS_ASSERT=1)
90 endif()
92 if(HOTPROFILER)
93         add_definitions(-DHOTPROFILER=1)
94 endif()
96 if(HOTPROFILER_NO_BUILTIN)
97         add_definitions(-DHOTPROFILER_NO_BUILTIN=1)
98 endif()
100 if(EXECUTION_PROFILER)
101         add_definitions(-DEXECUTION_PROFILER=1)
102 endif()
104 if(ENABLE_FULL_SETLINE)
105         add_definitions(-DENABLE_FULL_SETLINE=1)
106 endif()
108 if(APPLE OR FREEBSD)
109         add_definitions(-DSKIP_USER_CHANGE=1)
110 endif()
112 if(APPLE)
113         # We have to be a little more permissive in some cases.
114         add_definitions(-fpermissive)
116         # Skip deprecation warnings in OpenSSL. 
117         add_definitions(-DMAC_OS_X_VERSION_MIN_REQUIRED=MAC_OS_X_VERSION_10_6)
119         # Just assume we have sched.h
120         add_definitions(-DFOLLY_HAVE_SCHED_H=1)
122         # Enable weak linking
123         add_definitions(-DMACOSX_DEPLOYMENT_TARGET=10.6)
124 endif()
126 # enable the OSS options if we have any
127 add_definitions(-DHPHP_OSS=1)
129 # later versions of binutils don't play well without automake
130 add_definitions(-DPACKAGE=hhvm -DPACKAGE_VERSION=Release)
132 IF($ENV{CXX} MATCHES "icpc")
133         set(CMAKE_C_FLAGS "-no-ipo -fp-model precise -wd584 -wd1418 -wd1918 -wd383 -wd869 -wd981 -wd424 -wd1419 -wd444 -wd271 -wd2259 -wd1572 -wd1599 -wd82 -wd177 -wd593 -w")
134         set(CMAKE_CXX_FLAGS "-no-ipo -fp-model precise -wd584 -wd1418 -wd1918 -wd383 -wd869 -wd981 -wd424 -wd1419 -wd444 -wd271 -wd2259 -wd1572 -wd1599 -wd82 -wd177 -wd593 -fno-omit-frame-pointer -ftemplate-depth-120 -Wall -Woverloaded-virtual -Wno-deprecated -w1 -Wno-strict-aliasing -Wno-write-strings -Wno-invalid-offsetof -fno-operator-names")
135 else()
136         set(CMAKE_C_FLAGS "-w")
137         set(CMAKE_CXX_FLAGS "-fno-gcse -fno-omit-frame-pointer -ftemplate-depth-120 -Wall -Woverloaded-virtual -Wno-deprecated -Wno-strict-aliasing -Wno-write-strings -Wno-invalid-offsetof -fno-operator-names -Wno-error=array-bounds -Wno-error=switch -std=gnu++0x -Werror=format-security -Wno-unused-result -Wno-sign-compare")
138 endif()
140 IF(CMAKE_COMPILER_IS_GNUCC)
141         SET (CMAKE_C_FLAGS_RELEASE "-O3")
142 ENDIF()
144 IF(CMAKE_COMPILER_IS_GNUCXX)
145         SET (CMAKE_CXX_FLAGS_RELEASE "-O3")
146 ENDIF()
148 include_directories(${HPHP_HOME}/hphp)
149 include_directories(${HPHP_HOME}/hphp/lib/system/gen)
150 include_directories(${HPHP_HOME})