From f5fcb666c5afb929c3eb7a7469f3a89937a1a471 Mon Sep 17 00:00:00 2001 From: mpilman Date: Wed, 2 May 2018 09:55:29 -0700 Subject: [PATCH] flow compiling with cmake on OS X --- CMakeLists.txt | 492 ++++++++++++++++++++++++++++++++++++ cmake/CompileBoost.cmake | 41 +++ cmake/CompileFMT.cmake | 16 ++ cmake/FindEditline.cmake | 16 ++ cmake/FindGperftools.cmake | 51 ++++ cmake/user-config.jam.cmake | 2 + fdb.cluster.cmake | 1 + flow/CMakeLists.txt | 82 ++++++ 8 files changed, 701 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 cmake/CompileBoost.cmake create mode 100644 cmake/CompileFMT.cmake create mode 100644 cmake/FindEditline.cmake create mode 100644 cmake/FindGperftools.cmake create mode 100644 cmake/user-config.jam.cmake create mode 100644 fdb.cluster.cmake create mode 100644 flow/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..224379523b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,492 @@ +# +# flow.h +# +# This source file is part of the FoundationDB open source project +# +# Copyright 2013-2018 Apple Inc. and the FoundationDB project authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +cmake_minimum_required(VERSION 3.5) +project(fdb) + +set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake") +message (STATUS "${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR}") +if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") + message(FATAL_ERROR "In-source builds are forbidden, unsupported, and stupid!!") +endif() + +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to 'Release' as none was specified") + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" + "MinSizeRel" "RelWithDebInfo") +endif() + +SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) +SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) + +################################################################################ +# GnuTLS Plugin +################################################################################ +#set(WITH_GNUTLS ON CACHE BOOL "Install GnuTLS plugin") +#if (WITH_GNUTLS) +# set(GnuTLS_PLUGIN "${CMAKE_CURRENT_SOURCE_DIR}/../gnutls-plugin/FDBGnuTLS.so") +# if (NOT EXISTS ${GnuTLS_PLUGIN}) +# message(FATAL_ERROR "could not find the GnuTLS plugin - please build that one first") +# endif() +# install(FILES ${GnuTLS_PLUGIN} DESTINATION lib/foundationdb/plugins COMPONENT server) +#endif() + +################################################################################ +# FDB-VERSION +################################################################################ + +set(FDB_RELEASE OFF CACHE BOOL "Whether the current build will be a delivered release") +set(DEBUG_TASKS OFF CACHE BOOL "Debug task metrics") +set(NDEBUG OFF CACHE BOOL "Not Debug mode (smaller code)") +set(FDB_MAJOR 5) +set(FDB_MINOR 1) +set(FDB_REVISION 7) +set(REL_SUFFIX "-PRERELEASE") + +if (FDB_RELEASE) + set(REL_SUFFIX "") +endif() + +set(FDBVERSION "${FDB_MAJOR}.${FDB_MINOR}.${FDB_REVISION}${REL_SUFFIX}" CACHE STRING "FDB version string") +set(FDBPACKAGE_NAME "${FDB_MAJOR}.${FDB_MINOR}" CACHE STRING "FDB version string") + +################################################################################ +# Packages used for bindings +################################################################################ + +include(UseJava) +find_package(JNI 1.8 REQUIRED) +find_package(Java 1.8 COMPONENTS Development REQUIRED) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") + +find_package(PythonInterp 3.4 REQUIRED) +set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.5) +find_package(PythonLibs 3.4 REQUIRED) + + +################################################################################ +# Compiler configuration +################################################################################ + +set(USE_GPERFTOOLS OFF CACHE BOOL "Use gperfools for profiling") +set(PORTABLE_BINARY OFF CACHE BOOL "Create a binary that runs on older OS versions") +set(USE_VALGRIND OFF CACHE BOOL "Compile for valgrind usage") +set(USE_GOLD_LINKER OFF CACHE BOOL "Use gold linker") +set(ALLOC_INSTRUMENTATION OFF CACHE BOOL "Instrument alloc") +set(WITH_UNDODB OFF CACHE BOOL "Use rr or undodb") +set(OPEN_FOR_IDE OFF CACHE BOOL "Open this in an IDE (won't compile/link)") + +if(USE_GOLD_LINKER) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags") +endif() + +set(GCC NO) +set(CLANG NO) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") + set(CLANG YES) +else() + # This is not a very good test. However, as we do not really support many architectures + # this is good enough for now + set(GCC YES) +endif() + +if(ALLOC_INSTRUMENTATION) + add_compile_options(-DALLOC_INSTRUMENTATION) +endif() +if(WITH_UNDODB) + add_compile_options(-DWITH_UNDODB) +endif() +if(DEBUG_TASKS) + add_compile_options(-DDEBUG_TASKS) +endif() + +if(NDEBUG) + add_compile_options(-DNDEBUG) +endif() + +if(FDB_RELEASE) + add_compile_options(-DFDB_RELEASE) +endif() + +# we always compile with debug symbols. CPack will strip them out +# and create a debuginfo rpm +add_compile_options(-ggdb) +set(USE_ASAN OFF CACHE BOOL "Compile with address sanitizer") +if(USE_ASAN) + find_package(Threads REQUIRED) + add_compile_options( + -fno-omit-frame-pointer -fsanitize=address + -DUSE_ASAN) + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address ${CMAKE_THREAD_LIBS_INIT}") +endif() + +if(PORTABLE_BINARY) + message(STATUS "Create a more portable binary") + set(CMAKE_MODULE_LINKER_FLAGS "-static-libstdc++ -static-libgcc ${CMAKE_MODULE_LINKER_FLAGS}") + set(CMAKE_SHARED_LINKER_FLAGS "-static-libstdc++ -static-libgcc ${CMAKE_SHARED_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++ -static-libgcc ${CMAKE_EXE_LINKER_FLAGS}") +endif() +# Instruction sets we require to be supported by the CPU +add_compile_options( + -maes + -mmmx + -mavx + -msse4.2) +add_compile_options($<$:-std=c++14>) +if (USE_VALGRIND) + add_compile_options(-DVALGRIND -DUSE_VALGRIND) +endif() +if (CLANG) + if (APPLE) + add_compile_options(-stdlib=libc++) + endif() + add_compile_options( + -Wno-unknown-warning-option + -Wno-dangling-else + -Wno-sign-compare + -Wno-comment + -Wno-unknown-pragmas + -Wno-delete-non-virtual-dtor + -Wno-format) +endif() +if (CMAKE_GENERATOR STREQUAL Xcode) +else() + add_compile_options(-Werror) +endif() +add_compile_options($<$:-Wno-pragmas>) +add_compile_options(-Wno-error=format + -Wno-deprecated + -fvisibility=hidden + -Wreturn-type + -fdiagnostics-color=always + -fPIC) + +if(CMAKE_COMPILER_IS_GNUCXX) + set(USE_LTO OFF CACHE BOOL "Do link time optimization") + if (USE_LTO) + add_compile_options($<$:-flto>) + set(CMAKE_AR "gcc-ar") + set(CMAKE_C_ARCHIVE_CREATE " qcs ") + set(CMAKE_C_ARCHIVE_FINISH true) + set(CMAKE_CXX_ARCHIVE_CREATE " qcs ") + set(CMAKE_CXX_ARCHIVE_FINISH true) + endif() +endif() + +include_directories(${CMAKE_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) +if (NOT OPEN_FOR_IDE) + add_definitions(-DNO_INTELLISENSE) +endif() +add_definitions(-DUSE_UCONTEXT) +enable_language(ASM) + +include(CheckFunctionExists) +set(CMAKE_REQUIRED_INCLUDES stdlib.h malloc.h) +set(CMAKE_REQUIRED_LIBRARIES c) + +################################################################################ +# Get repository information +################################################################################ + +add_custom_target(branch_file ALL DEPENDS ${CURR_BRANCH_FILE}) +execute_process( + COMMAND git rev-parse HEAD + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE CURRENT_GIT_VERSION_WNL) +string(STRIP "${CURRENT_GIT_VERSION_WNL}" CURRENT_GIT_VERSION) +message(STATUS "Current git version ${CURRENT_GIT_VERSION}") + +################################################################################ +# ACTOR COMPILER +################################################################################ + +if (NOT OPEN_FOR_IDE) + # First thing we need is the actor compiler - and to compile and run the + # actor compiler, we need mono + find_program(MONO_EXECUTABLE mono) + find_program(MCS_EXECUTABLE dmcs) + + if (NOT MCS_EXECUTABLE) + find_program(MCS_EXECUTABLE mcs) + endif() + + set(MONO_FOUND FALSE CACHE INTERNAL "") + + if (NOT MCS_EXECUTABLE) + find_program(MCS_EXECUTABLE mcs) + endif() + + if (MONO_EXECUTABLE AND MCS_EXECUTABLE) + set(MONO_FOUND True CACHE INTERNAL "") + endif() + + if (NOT MONO_FOUND) + message(FATAL_ERROR "Could not find mono") + endif() + + set(ACTORCOMPILER_SRCS + ${CMAKE_CURRENT_SOURCE_DIR}/flow/actorcompiler/ActorCompiler.cs + ${CMAKE_CURRENT_SOURCE_DIR}/flow/actorcompiler/ActorParser.cs + ${CMAKE_CURRENT_SOURCE_DIR}/flow/actorcompiler/ParseTree.cs + ${CMAKE_CURRENT_SOURCE_DIR}/flow/actorcompiler/Program.cs + ${CMAKE_CURRENT_SOURCE_DIR}/flow/actorcompiler/Properties/AssemblyInfo.cs) + set(ACTOR_COMPILER_REFERENCES + "-r:System,System.Core,System.Xml.Linq,System.Data.DataSetExtensions,Microsoft.CSharp,System.Data,System.Xml") + + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/actorcompiler.exe + COMMAND ${MCS_EXECUTABLE} ARGS ${ACTOR_COMPILER_REFERENCES} ${ACTORCOMPILER_SRCS} "-target:exe" "-out:actorcompiler.exe" + DEPENDS ${ACTORCOMPILER_SRCS} + COMMENT "Compile actor compiler" VERBATIM) + add_custom_target(actorcompiler DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/actorcompiler.exe) + set(actor_exe "${CMAKE_CURRENT_BINARY_DIR}/actorcompiler.exe") +endif() + +################################################################################ +# Vexilographer +################################################################################ + +set(VEXILLOGRAPHER_SRCS + ${CMAKE_CURRENT_SOURCE_DIR}/fdbclient/vexillographer/c.cs + ${CMAKE_CURRENT_SOURCE_DIR}/fdbclient/vexillographer/cpp.cs + ${CMAKE_CURRENT_SOURCE_DIR}/fdbclient/vexillographer/java.cs + ${CMAKE_CURRENT_SOURCE_DIR}/fdbclient/vexillographer/nodejs.cs + ${CMAKE_CURRENT_SOURCE_DIR}/fdbclient/vexillographer/php.cs + ${CMAKE_CURRENT_SOURCE_DIR}/fdbclient/vexillographer/python.cs + ${CMAKE_CURRENT_SOURCE_DIR}/fdbclient/vexillographer/ruby.cs + ${CMAKE_CURRENT_SOURCE_DIR}/fdbclient/vexillographer/vexillographer.cs) + +set(VEXILLOGRAPHER_REFERENCES "-r:System,System.Core,System.Data,System.Xml,System.Xml.Linq") +set(VEXILLOGRAPHER_EXE "${CMAKE_CURRENT_BINARY_DIR}/vexillographer.exe") +add_custom_command(OUTPUT ${VEXILLOGRAPHER_EXE} + COMMAND ${MCS_EXECUTABLE} ARGS ${VEXILLOGRAPHER_REFERENCES} ${VEXILLOGRAPHER_SRCS} -target:exe -out:${VEXILLOGRAPHER_EXE} + DEPENDS ${VEXILLOGRAPHER_SRCS} + COMMENT "Compile Vexillographer") +add_custom_target(vexillographer DEPENDS ${VEXILLOGRAPHER_EXE}) + +set(ERROR_GEN_SRCS + ${CMAKE_CURRENT_SOURCE_DIR}/flow/error_gen.cs) +set(ERROR_GEN_REFERENCES "-r:System,System.Core,System.Data,System.Xml,System.Xml.Linq") +set(ERROR_GEN_EXE "${CMAKE_CURRENT_BINARY_DIR}/error_gen.exe") +add_custom_command (OUTPUT ${ERROR_GEN_EXE} + COMMAND ${MCS_EXECUTABLE} ARGS ${ERROR_GEN_REFERENCES} ${ERROR_GEN_SRCS} -target:exe -out:${ERROR_GEN_EXE} + DEPENDS ${ERROR_GEN_SRCS} + COMMENT "Compile error_gen") +add_custom_target(error_gen DEPENDS ${ERROR_GEN_EXE}) + +################################################################################ +# Helper functions +################################################################################ + +if (OPEN_FOR_IDE) + macro(actor_set varname srcs) + set(${varname}) + foreach(src ${srcs}) + set(tmp "${src}") + set(${varname} "${${varname}};${tmp}") + endforeach() + endmacro() + + macro(actor_compile target srcs) + endmacro() +else() + macro(actor_set varname srcs) + set(${varname}) + foreach(src ${srcs}) + set(tmp "${src}") + if(${src} MATCHES ".*\\.h") + continue() + elseif(${src} MATCHES ".*\\.actor\\.cpp") + string(REPLACE ".actor.cpp" ".actor.g.cpp" tmp ${src}) + set(tmp "${CMAKE_CURRENT_BINARY_DIR}/${tmp}") + endif() + set(${varname} "${${varname}};${tmp}") + endforeach() + endmacro() + + set(ACTOR_TARGET_COUNTER "0") + macro(actor_compile target srcs) + set(options DISABLE_ACTOR_WITHOUT_WAIT) + set(oneValueArg) + set(multiValueArgs) + cmake_parse_arguments(ACTOR_COMPILE "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}") + set(_tmp_out "") + foreach(src ${srcs}) + set(tmp "") + if(${src} MATCHES ".*\\.actor\\.h") + string(REPLACE ".actor.h" ".actor.g.h" tmp ${src}) + elseif(${src} MATCHES ".*\\.actor\\.cpp") + string(REPLACE ".actor.cpp" ".actor.g.cpp" tmp ${src}) + endif() + set(actor_compiler_flags "") + if(ACTOR_COMPILE_DISABLE_ACTOR_WITHOUT_WAIT) + set(actor_compiler_flags "--disable-actor-without-wait-error") + endif() + if(tmp) + add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${tmp}" + COMMAND ${MONO_EXECUTABLE} ${actor_exe} "${CMAKE_CURRENT_SOURCE_DIR}/${src}" "${CMAKE_CURRENT_BINARY_DIR}/${tmp}" ${actor_compiler_flags} > /dev/null + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${src}" actorcompiler ${actor_exe} + COMMENT "Compile actor: ${src}") + set(_tmp_out "${_tmp_out};${CMAKE_CURRENT_BINARY_DIR}/${tmp}") + endif() + endforeach() + MATH(EXPR ACTOR_TARGET_COUNTER "${ACTOR_TARGET_COUNTER}+1") + add_custom_target(${target}_actors_${ACTOR_TARGET_COUNTER} DEPENDS ${_tmp_out}) + add_dependencies(${target} ${target}_actors_${ACTOR_TARGET_COUNTER}) + target_include_directories(${target} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + target_include_directories(${target} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) + endmacro() +endif() + +# This macro can be used to install symlinks, which turns out to be +# non-trivial due to CMake version differences and limitations on how +# files can be installed when building binary packages. +# +# The rule for binary packaging is that files (including symlinks) must +# be installed with the standard CMake install() macro. +# +# The rule for non-binary packaging is that CMake 2.6 cannot install() +# symlinks, but can create the symlink at install-time via scripting. +# Though, we assume that CMake 2.6 isn't going to be used to generate +# packages because versions later than 2.8.3 are superior for that purpose. +# +# _filepath: the absolute path to the file to symlink +# _sympath: absolute path of the installed symlink + +macro(InstallSymlink _filepath _sympath) + get_filename_component(_symname ${_sympath} NAME) + get_filename_component(_installdir ${_sympath} PATH) + + if (BINARY_PACKAGING_MODE) + execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink + ${_filepath} + ${CMAKE_CURRENT_BINARY_DIR}/${_symname}) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_symname} + DESTINATION ${_installdir} + COMPONENT clients) + else () + # scripting the symlink installation at install time should work + # for CMake 2.6.x and 2.8.x + install(CODE " + if (\"\$ENV{DESTDIR}\" STREQUAL \"\") + execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink + ${_filepath} + ${_installdir}/${_symname}) + else () + execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink + ${_filepath} + \$ENV{DESTDIR}/${_installdir}/${_symname}) + endif () + " + COMPONENT clients) + endif () +endmacro(InstallSymlink) + +################################################################################ +# Generate config file +################################################################################ + +string(RANDOM LENGTH 8 description1) +string(RANDOM LENGTH 8 description2) +set(CLUSTER_DESCRIPTION1 ${description1} CACHE STRING "Cluster description") +set(CLUSTER_DESCRIPTION2 ${description2} CACHE STRING "Cluster description") + +configure_file(fdb.cluster.cmake ${CMAKE_CURRENT_BINARY_DIR}/fdb.cluster) + + +################################################################################ +# testing +################################################################################ +enable_testing() + +################################################################################ +# components +################################################################################ + +include(CompileBoost) +include(CompileFMT) +add_subdirectory(flow) +#add_subdirectory(fdbclient) +#add_subdirectory(fdbserver) +#add_subdirectory(fdbcli) +#add_subdirectory(bindings) +#add_subdirectory(fdbbackup) +#add_subdirectory(fdbmonitor) + +################################################################################ +# process compile commands for rtags +################################################################################ + +if (CMAKE_EXPORT_COMPILE_COMMANDS) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/gen_compile_db.py + ARGS -b ${CMAKE_CURRENT_BINARY_DIR} -s ${CMAKE_CURRENT_SOURCE_DIR} -o ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen_compile_db.py ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json + COMMENT "Build compile commands for rtags" + ) + add_custom_target(procossed_compile_commands ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json) +endif() + +################################################################################ +# Install scripts +################################################################################ + +#install(FILES scripts/log_writer.py DESTINATION lib/foundationdb COMPONENT server) +install(FILES packaging/rpm/init_script/foundationdb + DESTINATION /etc/rc.d/init.d + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ + COMPONENT server) + +install(FILES packaging/foundationdb.conf + DESTINATION /etc/foundationdb + COMPONENT server) + + +################################################################################ +# Build RPM +################################################################################ + +#configure_file(${CMAKE_CURRENT_SOURCE_DIR}/DESCRIPTION ${CMAKE_CURRENT_BINARY_DIR}/DESCRIPTION) +# +#include (InstallRequiredSystemLibraries) +#set(CPACK_GENERATOR RPM) +#set(CPACK_RPM_server_USER_FILELIST "%config(noreplace) /etc/foundationdb/foundationdb.conf") +#set(CPACK_RPM_DEBUGINFO_PACKAGE ON) +#set(CPACK_RPM_PACKAGE_RELOCATABLE NO) +#set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX /usr/src) +#set(CPACK_RPM_COMPONENT_INSTALL ON) +#set(CPACK_PACKAGE_NAME "foundationdb") +#set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "FoundationDB - A distributed key-value store with ACID transactions") +#set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_BINARY_DIR}/DESCRIPTION) +#set(CPACK_RESOURCE_FILE_LICENSE +# "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") +#set(CPACK_PACKAGE_VERSION_MAJOR "${FDB_MAJOR}") +#set(CPACK_PACKAGE_VERSION_MINOR "${FDB_MINOR}") +#set(CPACK_PACKAGE_VERSION_PATCH "${FDB_REVISION}") +#set(CPACK_RPM_clients_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/packaging/rpm/preinstall-client.sh) +#set(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/packaging/rpm/preinstall-server.sh) +#set(CPACK_RPM_server_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/packaging/rpm/postinstall-server.sh) +# +#set(CPACK_RPM_server_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/packaging/rpm/preuninstall-server.sh) +#include (CPack) diff --git a/cmake/CompileBoost.cmake b/cmake/CompileBoost.cmake new file mode 100644 index 0000000000..02fae77ff6 --- /dev/null +++ b/cmake/CompileBoost.cmake @@ -0,0 +1,41 @@ +include(ExternalProject) +ExternalProject_add(boostProject + URL "https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.bz2" + URL_HASH SHA256=2684c972994ee57fc5632e03bf044746f6eb45d4920c343937a465fd67a5adba + CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} ./bootstrap.sh --with-libraries=system,python --with-python=${PYTHON_EXECUTABLE} + BUILD_COMMAND ${CMAKE_COMMAND} -E env CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} ./b2 link=static --user-config=${CMAKE_BINARY_DIR}/user-config.jam + BUILD_IN_SOURCE ON + INSTALL_COMMAND "" + UPDATE_COMMAND "" + BUILD_BYPRODUCTS /stage/lib/libboost_system.a /stage/lib/libboost_python.a + ) + +if(APPLE) + set(BOOST_TOOLSET "darwin") +else() + set(BOOST_TOOLSET "gcc") +endif() + +set(BOOST_COMPILER_FLAGS -fvisibility=hidden -fPIC -std=c++14 -w) +set(BOOST_ADDITIONAL_COMPILE_OPTIOINS "") +foreach(flag IN LISTS BOOST_COMPILER_FLAGS) + string(APPEND BOOST_ADDITIONAL_COMPILE_OPTIOINS "${flag} ") +endforeach() +ExternalProject_Get_property(boostProject SOURCE_DIR) +configure_file(${CMAKE_SOURCE_DIR}/cmake/user-config.jam.cmake ${CMAKE_BINARY_DIR}/user-config.jam) + +set(BOOST_INCLUDE_DIR ${SOURCE_DIR}) +set(BOOST_LIBDIR ${SOURCE_DIR}/stage/lib) +set(BOOST_SYSTEM_LIBRARY ${BOOST_LIBDIR}/libboost_system.a) +set(BOOST_PYTHON_LIBRARY ${BOOST_LIBDIR}/libboost_python.a) +message(STATUS "Boost include dir ${BOOST_INCLUDE_DIR}") + +add_library(boost_system INTERFACE) +add_dependencies(boost_system boostProject) +target_link_libraries(boost_system INTERFACE ${BOOST_SYSTEM_LIBRARY}) +target_include_directories(boost_system INTERFACE ${BOOST_INCLUDE_DIR}) + +add_library(boost_python INTERFACE) +add_dependencies(boost_python boostProject) +target_link_libraries(boost_python INTERFACE ${BOOST_PYTHON_LIBRARY}) +target_include_directories(boost_python INTERFACE ${BOOST_INCLUDE_DIR}) diff --git a/cmake/CompileFMT.cmake b/cmake/CompileFMT.cmake new file mode 100644 index 0000000000..9a808268e9 --- /dev/null +++ b/cmake/CompileFMT.cmake @@ -0,0 +1,16 @@ +include(ExternalProject) +ExternalProject_add(fmtProject + GIT_REPOSITORY https://github.com/fmtlib/fmt.git + GIT_TAG 4.1.0 + CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX= -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DFMT_USE_CPP14=ON + BUILD_BYPRODUCTS /lib/libfmt.a) + +ExternalProject_Get_property(fmtProject INSTALL_DIR) +set(FMT_INCLUDE_DIR ${INSTALL_DIR}/include) +set(FMT_LIBRARY ${INSTALL_DIR}/lib/libfmt.a) + +add_library(fmt INTERFACE) +add_dependencies(fmt fmtProject) +target_link_libraries(fmt INTERFACE ${FMT_LIBRARY}) +target_include_directories(fmt INTERFACE ${FMT_INCLUDE_DIR}) + diff --git a/cmake/FindEditline.cmake b/cmake/FindEditline.cmake new file mode 100644 index 0000000000..09a0c9f39a --- /dev/null +++ b/cmake/FindEditline.cmake @@ -0,0 +1,16 @@ +find_package(Curses) +include(FindPackageHandleStandardArgs) + +if(CURSES_FOUND) + find_path(Editline_INCLUDE_DIR editline/readline.h) + find_library(Editline_LIBRARY edit) + find_package_handle_standard_args( + Editline DEFAULT_MSG Editline_LIBRARY Editline_INCLUDE_DIR) + if(Editline_FOUND) + set(Editline_LIBRARIES ${Editline_LIBRARY} ${CURSES_LIBRARIES}) + set(Editline_INCLUDE_DIRS ${Editline_INCLUDE_DIR} ${CURSES_INCLUDE_DIRS}) + mark_as_advanced(Editline_INCLUDE_DIR Editline_LIBRARY) + endif() +else() + set(Editline_FOUND False) +endif() diff --git a/cmake/FindGperftools.cmake b/cmake/FindGperftools.cmake new file mode 100644 index 0000000000..cd990662cf --- /dev/null +++ b/cmake/FindGperftools.cmake @@ -0,0 +1,51 @@ +# Tries to find Gperftools. +# +# Usage of this module as follows: +# +# find_package(Gperftools) +# +# Variables used by this module, they can change the default behaviour and need +# to be set before calling find_package: +# +# Gperftools_ROOT_DIR Set this variable to the root installation of +# Gperftools if the module has problems finding +# the proper installation path. +# +# Variables defined by this module: +# +# GPERFTOOLS_FOUND System has Gperftools libs/headers +# GPERFTOOLS_LIBRARIES The Gperftools libraries (tcmalloc & profiler) +# GPERFTOOLS_INCLUDE_DIR The location of Gperftools headers + +find_library(GPERFTOOLS_TCMALLOC + NAMES tcmalloc + HINTS ${Gperftools_ROOT_DIR}/lib) + +find_library(GPERFTOOLS_PROFILER + NAMES profiler + HINTS ${Gperftools_ROOT_DIR}/lib) + +find_library(GPERFTOOLS_TCMALLOC_AND_PROFILER + NAMES tcmalloc_and_profiler + HINTS ${Gperftools_ROOT_DIR}/lib) + +find_path(GPERFTOOLS_INCLUDE_DIR + NAMES gperftools/heap-profiler.h + HINTS ${Gperftools_ROOT_DIR}/include) + +set(GPERFTOOLS_LIBRARIES ${GPERFTOOLS_TCMALLOC_AND_PROFILER}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + Gperftools + DEFAULT_MSG + GPERFTOOLS_LIBRARIES + GPERFTOOLS_INCLUDE_DIR) + +mark_as_advanced( + Gperftools_ROOT_DIR + GPERFTOOLS_TCMALLOC + GPERFTOOLS_PROFILER + GPERFTOOLS_TCMALLOC_AND_PROFILER + GPERFTOOLS_LIBRARIES + GPERFTOOLS_INCLUDE_DIR) diff --git a/cmake/user-config.jam.cmake b/cmake/user-config.jam.cmake new file mode 100644 index 0000000000..d719b5020d --- /dev/null +++ b/cmake/user-config.jam.cmake @@ -0,0 +1,2 @@ +using @BOOST_TOOLSET@ : : @CMAKE_CXX_COMPILER@ : @BOOST_ADDITIONAL_COMPILE_OPTIOINS@ ; +using python : @PYTHON_VERSION_MAJOR@.@PYTHON_VERSION_MINOR@ : @PYTHON_EXECUTABLE@ : @PYTHON_INCLUDE_DIRS@ ; diff --git a/fdb.cluster.cmake b/fdb.cluster.cmake new file mode 100644 index 0000000000..632fa1a4d3 --- /dev/null +++ b/fdb.cluster.cmake @@ -0,0 +1 @@ +${CLUSTER_DESCRIPTION1}:${CLUSTER_DESCRIPTION1}@127.0.0.1:4500 diff --git a/flow/CMakeLists.txt b/flow/CMakeLists.txt new file mode 100644 index 0000000000..b36e7c3d89 --- /dev/null +++ b/flow/CMakeLists.txt @@ -0,0 +1,82 @@ +find_package(Threads REQUIRED) + +set(FLOW_SRCS + ActorCollection.actor.cpp + ActorCollection.h + Arena.h + AsioReactor.h + CompressedInt.actor.cpp + CompressedInt.h + Deque.cpp + Deque.h + DeterministicRandom.h + Error.cpp + Error.h + EventTypes.actor.h + FastAlloc.cpp + FastAlloc.h + FastRef.h + FaultInjection.cpp + FaultInjection.h + Hash3.c + Hash3.h + IDispatched.h + IRandom.h + IThreadPool.cpp + IThreadPool.h + IndexedSet.actor.h + IndexedSet.cpp + IndexedSet.h + Knobs.cpp + Knobs.h + MetricSample.h + Net2.actor.cpp + Net2Packet.cpp + Net2Packet.h + Platform.cpp + Platform.h + Profiler.actor.cpp + Profiler.h + SignalSafeUnwind.cpp + SignalSafeUnwind.h + SimpleOpt.h + Stats.actor.cpp + Stats.h + SystemMonitor.cpp + SystemMonitor.h + TDMetric.actor.h + TDMetric.cpp + ThreadHelper.actor.h + ThreadHelper.cpp + ThreadPrimitives.cpp + ThreadPrimitives.h + ThreadSafeQueue.h + Trace.cpp + Trace.h + UnitTest.cpp + UnitTest.h + actorcompiler.h + boost.cpp + error_definitions.h + flow.cpp + flow.h + genericactors.actor.cpp + genericactors.actor.h + network.cpp + network.h + serialize.h + stacktrace.amalgamation.cpp + stacktrace.h) + +actor_set(FLOW_BUILD "${FLOW_SRCS};${FLOW_SRCS_ALLOW_ACTOR_WITHOUT_WAIT}") +add_library(flow STATIC ${FLOW_BUILD}) +actor_compile(flow "${FLOW_SRCS}") +actor_compile(flow "${FLOW_SRCS_ALLOW_ACTOR_WITHOUT_WAIT}" DISABLE_ACTOR_WITHOUT_WAIT) +#target_include_directories(flow PRIVATE libeio) +target_include_directories(flow SYSTEM PUBLIC ${Boost_INCLUDE_DIRS} ${CMAKE_THREAD_LIBS_INIT}) +#set(FLOW_LIBS eio ${CMAKE_DL_LIBS}) +if (NOT APPLE) + set (FLOW_LIBS ${FLOW_LIBS} rt) +endif() +target_link_libraries(flow PRIVATE ${FLOW_LIBS}) +target_link_libraries(flow PUBLIC boost_system fmt)