Avoid special-casing enum to not have cast in const init
[hiphop-php.git] / CMakeLists.txt
blob45cf43f10c898ee4364de7baf0267fcab2c3d98e
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")
12 # includes
13 SET(
14   CMAKE_MODULE_PATH
15   "${CMAKE_CURRENT_SOURCE_DIR}/CMake"
16   "${CMAKE_CURRENT_SOURCE_DIR}/build/fbcode_builder/CMake"
17   ${CMAKE_MODULE_PATH}
19 include_directories(${CMAKE_CURRENT_BINARY_DIR})
21 PROJECT(hhvm C CXX ASM)
23 include(HHVMProject)
25 if (MSVC)
26   enable_language(ASM_MASM)
27 endif()
29 MARK_AS_ADVANCED(CLEAR CMAKE_INSTALL_PREFIX)
30 IF(APPLE)
31   # CMake really likes finding libraries inside OS X frameworks. This can
32   # create super unexpected results, such as the LDAP framework, where the
33   # ldap.h header there just consists of "#include <ldap.h>" -- obviously
34   # assuming /usr/include appears on the include path before that framework
35   # (which wasn't really supposed to be on the include path at all). This
36   # leads to a hilarious recursive include and general fireworks. Instead,
37   # tell CMake to search frameworks *last*, if it doesn't find something in
38   # /usr (or MacPorts/Homebrew).
39   SET(CMAKE_FIND_FRAMEWORK "LAST")
40   MARK_AS_ADVANCED(CMAKE_OSX_ARCHITECTURES
41     CMAKE_OSX_DEPLOYMENT_TARGET
42     CMAKE_OSX_SYSROOT)
43   SET(CMAKE_OSX_DEPLOYMENT_TARGET 10.15)
44 ENDIF()
46 # Check architecture OS
47 IF(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
48   MESSAGE(FATAL_ERROR "HHVM requires a 64bit OS")
49 ENDIF()
51 # Enable ccache if present and not already enabled system wide.
52 option(SKIP_CCACHE "Skip detecting/enabling ccache - no effect if ccache enabled system wide" FALSE)
53 if(NOT SKIP_CCACHE)
54   find_program(CCACHE_FOUND ccache)
55   if(CCACHE_FOUND)
56     if (NOT ("${CMAKE_CXX_COMPILER} ${CMAKE_C_COMPILER}" MATCHES ".*ccache.*"))
57       set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_FOUND})
58       message(STATUS "Found ccache: ${CCACHE_FOUND} - enabling ccache as compiler wrapper")
59     else()
60       message(STATUS "Found ccache - ccache already in use as C and/or CXX compiler wrapper")
61    endif()
62   endif(CCACHE_FOUND)
63 endif(NOT SKIP_CCACHE)
65 # 3rd party library
66 IF(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third-party/CMakeLists.txt")
67   MESSAGE(FATAL_ERROR "third-party/CMakeLists.txt missing. "
68                       "Try updating your submodule with:
69 rm -r third-party
70 git submodule update --init --recursive
72 ENDIF()
74 INCLUDE(HPHPFunctions)
75 INCLUDE(CheckFunctionExists)
77 SET(HPHP_HOME ${CMAKE_CURRENT_SOURCE_DIR})
78 SET(TP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third-party")
79 SET(TP_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/third-party")
81 include(MSVCDefaults)
82 include(Options)
83 include(HPHPCompiler)
84 include(HPHPFindLibs)
86 ADD_SUBDIRECTORY(third-party EXCLUDE_FROM_ALL)
87 ADD_SUBDIRECTORY(hphp)
89 # use GNU install dirs (e.g. lib64 instead of lib)
90 INCLUDE(GNUInstallDirs)
92 # modules / depends
93 FILE(GLOB HHVM_CMAKE_FILES "CMake/*.cmake")
94 INSTALL(
95   FILES ${HHVM_CMAKE_FILES}
96   DESTINATION "${CMAKE_INSTALL_LIBDIR}/hhvm/CMake"
97   COMPONENT dev)