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")
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)
16 enable_language(ASM_MASM)
19 # Look for and apply patches to the third-party (and sub) repo.
20 file(GLOB PATCHES "${CMAKE_SOURCE_DIR}/patches/*.patch")
22 message(STATUS "Patches: ${PATCHES}")
23 foreach(PATCH ${PATCHES})
24 message(STATUS "Applying ${PATCH}")
26 COMMAND patch -p1 --forward --ignore-whitespace
27 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
29 OUTPUT_VARIABLE OUTPUT
30 RESULT_VARIABLE RESULT)
32 message(STATUS "Patch applied: ${PATCH}")
34 # Unfortunately although patch will recognise that a patch is already
35 # applied it will still return an error.
37 COMMAND patch -p1 -R --dry-run
38 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
40 OUTPUT_VARIABLE OUTPUT
41 RESULT_VARIABLE RESULT2)
43 message(STATUS "Patch was already applied: ${PATCH}")
45 message(FATAL_ERROR "Error applying patch ${PATCH}")
52 MARK_AS_ADVANCED(CLEAR CMAKE_INSTALL_PREFIX)
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
68 # Check architecture OS
69 IF(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
70 MESSAGE(FATAL_ERROR "HHVM requires a 64bit OS")
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)
76 find_program(CCACHE_FOUND ccache)
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")
82 message(STATUS "Found ccache - ccache already in use as C and/or CXX compiler wrapper")
85 endif(NOT SKIP_CCACHE)
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:
92 git submodule update --init --recursive
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)
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)
115 FILE(GLOB HHVM_CMAKE_FILES "CMake/*.cmake")
117 FILES ${HHVM_CMAKE_FILES}
118 DESTINATION "${CMAKE_INSTALL_LIBDIR}/hhvm/CMake"