2019-06-20 02:58:25 +03:00
|
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
2019-06-01 02:11:50 +03:00
|
|
|
#
|
2019-06-20 02:58:25 +03:00
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2.
|
2019-06-01 02:11:50 +03:00
|
|
|
|
2019-09-21 04:20:17 +03:00
|
|
|
# The add_fbthrift_library() calls require CMake 3.8+
|
|
|
|
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
|
2018-05-01 00:28:44 +03:00
|
|
|
# We use the GoogleTest module if it is available (only in CMake 3.9+)
|
|
|
|
# It requires CMP0054 and CMP0057 to be enabled.
|
|
|
|
if (POLICY CMP0054)
|
|
|
|
cmake_policy(SET CMP0054 NEW)
|
|
|
|
endif()
|
|
|
|
if (POLICY CMP0057)
|
|
|
|
cmake_policy(SET CMP0057 NEW)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Project information
|
|
|
|
project("eden" LANGUAGES CXX C)
|
|
|
|
|
2020-04-22 22:45:33 +03:00
|
|
|
set(EDEN_BUILD_REVISION "")
|
|
|
|
if(DEFINED ENV{FBSOURCE_DATE})
|
|
|
|
# If set, we expect FBSOURCE_DATE to have the form "20200324.113140"
|
|
|
|
set(PACKAGE_VERSION "$ENV{FBSOURCE_DATE}.0")
|
|
|
|
set(EDEN_BUILD_REVISION "$ENV{FBSOURCE_HASH}")
|
|
|
|
else()
|
|
|
|
find_program(GIT git)
|
|
|
|
if(GIT)
|
|
|
|
execute_process(
|
|
|
|
COMMAND
|
|
|
|
"${GIT}" "log" "-1" "--format=%H;%cd" "--date=format:%Y%m%d.%H%M%S.0"
|
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
RESULT_VARIABLE git_result
|
|
|
|
OUTPUT_VARIABLE git_data
|
|
|
|
ERROR_VARIABLE git_err
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
if(git_result EQUAL 0)
|
|
|
|
list(GET git_data 0 EDEN_BUILD_REVISION)
|
|
|
|
list(GET git_data 1 PACKAGE_VERSION)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(
|
|
|
|
EDEN_VERSION_OVERRIDE "" CACHE STRING
|
|
|
|
"Use this version number instead of the default that would be selected"
|
|
|
|
)
|
|
|
|
if(EDEN_VERSION_OVERRIDE)
|
|
|
|
set(PACKAGE_VERSION "${EDEN_VERSION_OVERRIDE}")
|
|
|
|
elseif(DEFINED ENV{EDEN_VERSION_OVERRIDE})
|
|
|
|
set(PACKAGE_VERSION "$ENV{EDEN_VERSION_OVERRIDE}")
|
|
|
|
endif()
|
|
|
|
if(PACKAGE_VERSION)
|
|
|
|
string(REPLACE "." ";" VERSION_FIELDS "${PACKAGE_VERSION}")
|
|
|
|
list(LENGTH VERSION_FIELDS NUM_VERSION_FIELDS)
|
|
|
|
if(NOT "${NUM_VERSION_FIELDS}" EQUAL 3)
|
|
|
|
message(
|
|
|
|
FATAL_ERROR
|
|
|
|
"Bad version string \"${PACKAGE_VERSION}\": must be in X.Y.Z format"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
list(GET VERSION_FIELDS 0 EDEN_VERSION)
|
|
|
|
list(GET VERSION_FIELDS 1 EDEN_RELEASE)
|
|
|
|
message(STATUS "Eden Version: ${EDEN_VERSION}-${EDEN_RELEASE}")
|
|
|
|
else()
|
|
|
|
set(EDEN_VERSION "")
|
|
|
|
set(EDEN_RELEASE "")
|
|
|
|
set(PACKAGE_VERSION "0.0.0")
|
|
|
|
message(STATUS "Eden Version: (dev build)")
|
|
|
|
endif()
|
|
|
|
string(TIMESTAMP EDEN_BUILD_TIME_UNIX "%s")
|
|
|
|
|
2018-05-01 00:28:44 +03:00
|
|
|
# Tell CMake to also look in the directories where getdeps.py installs
|
|
|
|
# our third-party dependencies.
|
|
|
|
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/external/install")
|
|
|
|
|
|
|
|
# CMake include directories
|
2019-05-04 01:52:39 +03:00
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake"
|
|
|
|
# For shipit-transformed builds
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/build/fbcode_builder/CMake"
|
|
|
|
${CMAKE_MODULE_PATH})
|
|
|
|
|
2018-05-01 00:28:44 +03:00
|
|
|
include_directories(
|
|
|
|
${CMAKE_SOURCE_DIR}
|
|
|
|
${CMAKE_BINARY_DIR}
|
|
|
|
)
|
|
|
|
|
2018-12-18 07:11:10 +03:00
|
|
|
if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/external/osxfuse")
|
|
|
|
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/external/osxfuse/common")
|
2019-03-30 00:57:58 +03:00
|
|
|
else()
|
|
|
|
find_path(OSXFUSE_INCLUDE_DIR NAMES "fuse_ioctl.h")
|
|
|
|
if (OSXFUSE_INCLUDE_DIR)
|
|
|
|
include_directories(${OSXFUSE_INCLUDE_DIR})
|
|
|
|
endif()
|
2018-12-18 07:11:10 +03:00
|
|
|
endif()
|
|
|
|
|
2018-10-23 23:39:58 +03:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2019-06-01 02:11:50 +03:00
|
|
|
|
2019-09-21 04:20:17 +03:00
|
|
|
# Configuration options
|
2019-09-27 06:25:17 +03:00
|
|
|
set(ENABLE_EDENSCM AUTO CACHE STRING "Enable support for Eden SCM repositories")
|
|
|
|
set_property(CACHE ENABLE_EDENSCM PROPERTY STRINGS AUTO ON OFF)
|
2019-09-21 04:20:17 +03:00
|
|
|
set(ENABLE_GIT AUTO CACHE STRING "Enable support for Git repositories")
|
|
|
|
set_property(CACHE ENABLE_GIT PROPERTY STRINGS AUTO ON OFF)
|
|
|
|
|
2020-05-09 07:44:33 +03:00
|
|
|
include(FBCompilerSettings)
|
2018-05-01 00:28:44 +03:00
|
|
|
include(EdenConfigChecks)
|
2019-09-11 23:19:03 +03:00
|
|
|
include(FBPythonBinary)
|
|
|
|
include(FBThriftLibrary)
|
2019-11-22 23:53:41 +03:00
|
|
|
include(RustStaticLibrary)
|
2019-01-18 05:46:04 +03:00
|
|
|
|
|
|
|
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
2019-02-22 23:04:34 +03:00
|
|
|
set_property(
|
|
|
|
DIRECTORY
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
APPEND
|
|
|
|
PROPERTY
|
|
|
|
COMPILE_DEFINITIONS
|
|
|
|
"FOLLY_XLOG_STRIP_PREFIXES=\"${CMAKE_SOURCE_DIR}:${CMAKE_BINARY_DIR}\""
|
|
|
|
)
|
2019-01-18 05:46:04 +03:00
|
|
|
add_subdirectory(eden/fs)
|
2019-10-04 18:55:14 +03:00
|
|
|
add_subdirectory(eden/integration)
|
2019-11-22 23:53:41 +03:00
|
|
|
add_subdirectory(eden/scm/edenscm/hgext/extlib)
|
|
|
|
add_subdirectory(eden/scm/edenscm/mercurial)
|
2019-11-22 23:53:41 +03:00
|
|
|
add_subdirectory(eden/scm/lib)
|
2019-10-04 18:55:14 +03:00
|
|
|
add_subdirectory(eden/test_support)
|
2020-02-04 03:57:11 +03:00
|
|
|
add_subdirectory(eden/scm/exec/eden_apfs_mount_helper)
|
2018-05-01 00:28:44 +03:00
|
|
|
|
2020-01-14 03:08:25 +03:00
|
|
|
if(WIN32)
|
|
|
|
# On Windows our Python binaries are compiled into executables which depend
|
|
|
|
# on Python. They need to be able to find the correct Python DLL at runtime.
|
|
|
|
# If INSTALL_PYTHON_LIB is enabled we will copy the correct Python DLL into
|
|
|
|
# Eden's installation directory so that our programs can easily find the
|
|
|
|
# right Python library.
|
|
|
|
#
|
|
|
|
# It might be nice if we could link against Python statically. The
|
|
|
|
# FindPython3.cmake module does support a Python3_USE_STATIC_LIBS variable,
|
|
|
|
# but unfortunately it is ignored on Windows.
|
|
|
|
set(
|
|
|
|
INSTALL_PYTHON_LIB FALSE CACHE BOOL
|
|
|
|
"Install the Python DLL in Eden's bin/ directory."
|
|
|
|
)
|
|
|
|
if(INSTALL_PYTHON_LIB)
|
|
|
|
get_target_property(python_dll Python3::Python LOCATION)
|
|
|
|
install(FILES "${python_dll}" DESTINATION bin)
|
|
|
|
endif()
|
2020-03-31 21:33:28 +03:00
|
|
|
|
|
|
|
# Also a emit a file listing additional directories containing runtime
|
|
|
|
# library dependencies. On Windows this is needed to help figure out runtime
|
|
|
|
# dependencies needed to run the generated build artifacts. This file can be
|
|
|
|
# processed by getdeps.py
|
|
|
|
get_filename_component(python_dll_dir "${python_dll}" DIRECTORY)
|
|
|
|
file(TO_NATIVE_PATH "${python_dll_dir}" python_dll_dir)
|
|
|
|
file(WRITE "${CMAKE_BINARY_DIR}/LIBRARY_DEP_DIRS.txt" "${python_dll_dir}\n")
|
2020-01-14 03:08:25 +03:00
|
|
|
endif()
|
|
|
|
|
2018-05-01 00:28:44 +03:00
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/CMake/eden-config.h.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/eden/fs/eden-config.h
|
|
|
|
)
|
2020-04-22 22:45:33 +03:00
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/CMake/eden-config.cpp.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/eden/fs/eden-config.cpp
|
|
|
|
)
|
|
|
|
if(EDEN_HAVE_GIT)
|
|
|
|
set(EDEN_HAVE_GIT_PY "True")
|
|
|
|
else()
|
|
|
|
set(EDEN_HAVE_GIT_PY "False")
|
|
|
|
endif()
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/CMake/eden-config.py.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/eden/fs/py/eden/config.py
|
|
|
|
)
|