Updating submodules
[hiphop-php.git] / hphp / hhvm / CMakeLists.txt
blob46bc48050038bdb9478bd6c2e92ce7b17e3cceee
1 include(HHVMExtensionConfig)
3 set(CXX_SOURCES)
4 auto_sources(files "*.cpp" "")
5 list(APPEND CXX_SOURCES ${files})
7 # Windows targets use a generated rc file for embedding libraries
8 if(MSVC)
9   list(APPEND CXX_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/embed.rc)
10 endif()
12 option(ENABLE_LD_GOLD "Enable Hot Linker script using ld-gold" On)
13 set(SECTION_ORDERING_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../tools/oss_hot_section_ordering CACHE FILEPATH "File used by ld-gold for the relocation of sections")
15 if (MAP_TEXT_HUGE_PAGES)
16     file(STRINGS "${SECTION_ORDERING_FILE}" SECTION_ORDERING_CONTENTS)
17     list(GET SECTION_ORDERING_CONTENTS 0 HOT_START)
18     list(GET SECTION_ORDERING_CONTENTS -1 HOT_END)
19     string(REGEX REPLACE "\\.text\\.(.*)\\*" "\\1" HOT_START ${HOT_START})
20     string(REGEX REPLACE "\\.text\\.(.*)\\*" "\\1" HOT_END ${HOT_END})
21     set(DEFSYM_HOT_START "--defsym=__hot_start=${HOT_START},")
22     set(DEFSYM_HOT_END "--defsym=__hot_end=${HOT_END},")
23 endif()
25 if (ENABLE_LD_GOLD)
26   find_package(Gold)
27 endif()
29 get_object_libraries_objects(additionalObjects ${HHVM_WHOLE_ARCHIVE_LIBRARIES})
30 add_executable(hhvm ${CXX_SOURCES} ${additionalObjects})
31 target_link_libraries(hhvm ${HHVM_LINK_LIBRARIES} ${EZC_LINK_LIBRARIES} ${HRE_LINK_LIBRARIES})
32 link_object_libraries(hhvm ${HHVM_WHOLE_ARCHIVE_LIBRARIES})
33 if (GOLD_FOUND AND ENABLE_LD_GOLD)
34   if (CMAKE_CONFIGURATION_TYPES)
35     SET(LINKER_SCRIPT -fuse-ld=gold;-Wl,--icf=all,--gc-sections;release;-Wl,${DEFSYM_HOT_START}${DEFSYM_HOT_END}--section-ordering-file,${SECTION_ORDERING_FILE};default)
36   elseif(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
37     SET(LINKER_SCRIPT -fuse-ld=gold -Wl,${DEFSYM_HOT_START}${DEFSYM_HOT_END}--section-ordering-file,${SECTION_ORDERING_FILE},--icf=all,--gc-sections)
38   else()
39     SET(LINKER_SCRIPT -fuse-ld=gold -Wl,--icf=all,--gc-sections)
40   endif()
41   target_link_libraries(hhvm ${LINKER_SCRIPT})
42 endif()
43 hphp_link(hhvm)
44 HHVM_CONFIGURE_TARGET_FOR_EXTENSION_DEPENDENCIES(hhvm)
46 # These mocks need to be added for the rust/ocaml FFI to work properly
47 target_sources(hhvm PUBLIC ../hack/src/utils/ocaml_ffi_mock/ocaml.c)
49 if (ENABLE_SPLIT_DWARF)
50   if (NOT GOLD_FOUND)
51     message(FATAL_ERROR "ENABLE_SPLIT_DWARF was specified but the gold linker was not found")
52   endif()
53   message(STATUS "Enabled split DWARF files")
54   target_link_libraries(hhvm debug "-Wl,--gdb-index")
55 endif()
57 embed_all_systemlibs(hhvm "${CMAKE_CURRENT_BINARY_DIR}/.." "${CMAKE_CURRENT_BINARY_DIR}/hhvm")
58 add_dependencies(hhvm systemlib)
60 if (CMAKE_HOST_UNIX)
61   add_custom_command(TARGET hhvm POST_BUILD
62     COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/symlinks.sh
63       ${CMAKE_CURRENT_BINARY_DIR}/hhvm ${CMAKE_CURRENT_BINARY_DIR}
64     COMMENT "Creating symlinks for hhvm")
65 endif()
67 if (ENABLE_COTIRE)
68   cotire(hhvm)
69 endif()
71 HHVM_INSTALL(hhvm bin)
73 auto_sources(files "*.h" "")
74 HHVM_PUBLIC_HEADERS(hhvm ${files})