Ban instance properties on abstract final classes
[hiphop-php.git] / CMakeLists.txt
blobe68e210c6e964bbc280381f5fd4f80b4cc3ff7ec
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7 FATAL_ERROR)
3 # This needs to be done before any languages are enabled or
4 # projects are created.
5 INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/CMake/VisualStudioToolset.cmake")
7 # includes
8 SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
9 include_directories(${CMAKE_CURRENT_BINARY_DIR})
11 PROJECT(hhvm C CXX ASM)
13 include(HHVMProject)
15 if (MSVC)
16   enable_language(ASM_MASM)
17 endif()
19 # Look for and apply patches to the third-party (and sub) repo.
20 file(GLOB PATCHES "${CMAKE_SOURCE_DIR}/patches/*.patch")
21 if (PATCHES)
22   message(STATUS "Patches: ${PATCHES}")
23   foreach(PATCH ${PATCHES})
24     message(STATUS "Applying ${PATCH}")
25     execute_process(
26       COMMAND patch -p1 --forward --ignore-whitespace
27       WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
28       INPUT_FILE "${PATCH}"
29       OUTPUT_VARIABLE OUTPUT
30       RESULT_VARIABLE RESULT)
31     if (RESULT EQUAL 0)
32       message(STATUS "Patch applied: ${PATCH}")
33     else()
34       # Unfortunately although patch will recognise that a patch is already
35       # applied it will still return an error.
36       execute_process(
37         COMMAND patch -p1 -R --dry-run
38         WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
39         INPUT_FILE "${PATCH}"
40         OUTPUT_VARIABLE OUTPUT
41         RESULT_VARIABLE RESULT2)
42       if (RESULT2 EQUAL 0)
43         message(STATUS "Patch was already applied: ${PATCH}")
44       else()
45         message(FATAL_ERROR "Error applying patch ${PATCH}")
46       endif()
47     endif()
48   endforeach(PATCH)
49 endif()
52 MARK_AS_ADVANCED(CLEAR CMAKE_INSTALL_PREFIX)
53 IF(APPLE)
54   # CMake really likes finding libraries inside OS X frameworks. This can
55   # create super unexpected results, such as the LDAP framework, where the
56   # ldap.h header there just consists of "#include <ldap.h>" -- obviously
57   # assuming /usr/include appears on the include path before that framework
58   # (which wasn't really supposed to be on the include path at all). This
59   # leads to a hilarious recursive include and general fireworks. Instead,
60   # tell CMake to search frameworks *last*, if it doesn't find something in
61   # /usr (or MacPorts/Homebrew).
62   SET(CMAKE_FIND_FRAMEWORK "LAST")
63   MARK_AS_ADVANCED(CMAKE_OSX_ARCHITECTURES
64     CMAKE_OSX_DEPLOYMENT_TARGET
65     CMAKE_OSX_SYSROOT)
66 ENDIF()
68 # Check architecture OS
69 IF(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
70   MESSAGE(FATAL_ERROR "HHVM requires a 64bit OS")
71 ENDIF()
73 # Enable ccache if present and not already enabled system wide.
74 option(SKIP_CCACHE "Skip detecting/enabling ccache - no effect if ccache enabled system wide" FALSE)
75 if(NOT SKIP_CCACHE)
76   find_program(CCACHE_FOUND ccache)
77   if(CCACHE_FOUND)
78     if (NOT ("${CMAKE_CXX_COMPILER} ${CMAKE_C_COMPILER}" MATCHES ".*ccache.*"))
79       set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_FOUND})
80       message(STATUS "Found ccache: ${CCACHE_FOUND} - enabling ccache as compiler wrapper")
81     else()
82       message(STATUS "Found ccache - ccache already in use as C and/or CXX compiler wrapper")
83    endif()
84   endif(CCACHE_FOUND)
85 endif(NOT SKIP_CCACHE)
87 # 3rd party library
88 IF(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third-party/CMakeLists.txt")
89   MESSAGE(FATAL_ERROR "third-party/CMakeLists.txt missing. "
90                       "Try updating your submodule with:
91 rm -r third-party
92 git submodule update --init --recursive
94 ENDIF()
96 INCLUDE(HPHPFunctions)
97 INCLUDE(CheckFunctionExists)
99 SET(HPHP_HOME ${CMAKE_CURRENT_SOURCE_DIR})
100 SET(TP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third-party")
101 SET(TP_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/third-party")
103 include(MSVCDefaults)
104 include(Options)
105 include(HPHPCompiler)
106 include(HPHPFindLibs)
108 ADD_SUBDIRECTORY(third-party EXCLUDE_FROM_ALL)
109 ADD_SUBDIRECTORY(hphp)
111 # use GNU install dirs (e.g. lib64 instead of lib)
112 INCLUDE(GNUInstallDirs)
114 # modules / depends
115 FILE(GLOB HHVM_CMAKE_FILES "CMake/*.cmake")
116 INSTALL(
117   FILES ${HHVM_CMAKE_FILES}
118   DESTINATION "${CMAKE_INSTALL_LIBDIR}/hhvm/CMake"
119   COMPONENT dev)