1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7 FATAL_ERROR)
2 # Make `get_target_property()` on a target that does not exist a fatal error
3 # https://cmake.org/cmake/help/v3.0/policy/CMP0045.html
4 cmake_policy(SET CMP0045 NEW)
5 # ditto for add_dependencies(): https://cmake.org/cmake/help/v3.0/policy/CMP0046.html
6 cmake_policy(SET CMP0046 NEW)
8 # This needs to be done before any languages are enabled or
9 # projects are created.
10 INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/CMake/VisualStudioToolset.cmake")
13 SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
14 include_directories(${CMAKE_CURRENT_BINARY_DIR})
16 PROJECT(hhvm C CXX ASM)
21 enable_language(ASM_MASM)
24 MARK_AS_ADVANCED(CLEAR CMAKE_INSTALL_PREFIX)
26 # CMake really likes finding libraries inside OS X frameworks. This can
27 # create super unexpected results, such as the LDAP framework, where the
28 # ldap.h header there just consists of "#include <ldap.h>" -- obviously
29 # assuming /usr/include appears on the include path before that framework
30 # (which wasn't really supposed to be on the include path at all). This
31 # leads to a hilarious recursive include and general fireworks. Instead,
32 # tell CMake to search frameworks *last*, if it doesn't find something in
33 # /usr (or MacPorts/Homebrew).
34 SET(CMAKE_FIND_FRAMEWORK "LAST")
35 MARK_AS_ADVANCED(CMAKE_OSX_ARCHITECTURES
36 CMAKE_OSX_DEPLOYMENT_TARGET
38 SET(CMAKE_OSX_DEPLOYMENT_TARGET 10.15)
41 # Check architecture OS
42 IF(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
43 MESSAGE(FATAL_ERROR "HHVM requires a 64bit OS")
46 # Enable ccache if present and not already enabled system wide.
47 option(SKIP_CCACHE "Skip detecting/enabling ccache - no effect if ccache enabled system wide" FALSE)
49 find_program(CCACHE_FOUND ccache)
51 if (NOT ("${CMAKE_CXX_COMPILER} ${CMAKE_C_COMPILER}" MATCHES ".*ccache.*"))
52 set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_FOUND})
53 message(STATUS "Found ccache: ${CCACHE_FOUND} - enabling ccache as compiler wrapper")
55 message(STATUS "Found ccache - ccache already in use as C and/or CXX compiler wrapper")
58 endif(NOT SKIP_CCACHE)
61 IF(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third-party/CMakeLists.txt")
62 MESSAGE(FATAL_ERROR "third-party/CMakeLists.txt missing. "
63 "Try updating your submodule with:
65 git submodule update --init --recursive
69 INCLUDE(HPHPFunctions)
70 INCLUDE(CheckFunctionExists)
72 SET(HPHP_HOME ${CMAKE_CURRENT_SOURCE_DIR})
73 SET(TP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third-party")
74 SET(TP_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/third-party")
81 ADD_SUBDIRECTORY(third-party EXCLUDE_FROM_ALL)
82 ADD_SUBDIRECTORY(hphp)
84 # use GNU install dirs (e.g. lib64 instead of lib)
85 INCLUDE(GNUInstallDirs)
88 FILE(GLOB HHVM_CMAKE_FILES "CMake/*.cmake")
90 FILES ${HHVM_CMAKE_FILES}
91 DESTINATION "${CMAKE_INSTALL_LIBDIR}/hhvm/CMake"