GraphEngine/CMakeLists.txt

254 строки
9.6 KiB
CMake
Исходник Обычный вид История

2018-07-20 11:14:25 +03:00
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)
2018-08-02 14:50:34 +03:00
PROJECT(GraphEngine VERSION 2.0.9328 LANGUAGES CXX)
SET(TRINITY_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
SET(CMAKE_CXX_STANDARD 14)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_EXTENSIONS OFF)
SET(TRINITY_REPO_ROOT ${CMAKE_CURRENT_LIST_DIR})
2018-07-19 10:16:47 +03:00
SET(TRINITY_INSTALL_DIR ".")
SET(TRINITY_OUTPUT_DIR ${TRINITY_REPO_ROOT}/bin)
SET(TRINITY_TEST_DIR ${TRINITY_REPO_ROOT}/tests)
2018-07-18 19:26:44 +03:00
SET(TRINITY_TOOLS_DIR ${TRINITY_REPO_ROOT}/tools)
SET(TRINITY_LIB_DIR ${TRINITY_REPO_ROOT}/lib)
2018-07-18 13:29:44 +03:00
SET(TRINITY_SRC_DIR ${TRINITY_REPO_ROOT}/src)
SET(TRINITY_C_DIR ${TRINITY_SRC_DIR}/Trinity.C)
2018-07-18 19:26:44 +03:00
SET(TRINITY_NUGET_EXE ${TRINITY_TOOLS_DIR}/NuGet.exe)
2018-08-02 14:50:34 +03:00
SET(NUGET_CACHE_PATH "~/.nuget/packages")
2018-07-18 13:29:44 +03:00
2018-07-21 14:10:18 +03:00
SET(RXCPP_DIR ${TRINITY_SRC_DIR}/RxCpp)
SET(RX_INCLUDE_DIR ${RXCPP_DIR}/RxCpp/Rx/v2/src/rxcpp)
SET(IX_INCLUDE_DIR ${RXCPP_DIR}/Ix/CPP/src/cpplinq)
2018-07-18 19:26:44 +03:00
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${TRINITY_OUTPUT_DIR})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${TRINITY_OUTPUT_DIR})
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${TRINITY_OUTPUT_DIR})
2018-07-19 10:16:47 +03:00
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${TRINITY_OUTPUT_DIR})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${TRINITY_OUTPUT_DIR})
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${TRINITY_OUTPUT_DIR})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${TRINITY_OUTPUT_DIR})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${TRINITY_OUTPUT_DIR})
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${TRINITY_OUTPUT_DIR})
2018-08-02 12:33:11 +03:00
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${TRINITY_OUTPUT_DIR})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${TRINITY_OUTPUT_DIR})
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${TRINITY_OUTPUT_DIR})
2018-08-02 08:16:32 +03:00
FIND_PROGRAM(DOTNET_EXE dotnet)
MESSAGE("-- Dotnet toolchain: ${DOTNET_EXE}")
2018-07-21 14:10:18 +03:00
IF(WIN32 AND NOT EXISTS ${TRINITY_NUGET_EXE})
FILE(DOWNLOAD https://dist.nuget.org/win-x86-commandline/latest/nuget.exe ${TRINITY_NUGET_EXE})
ENDIF()
IF(WIN32)
SET(CMAKE_CXX_FLAGS "/volatile:iso /EHa /fp:except- /Zi /Gy /MP /W3 /DEBUG")
SET(CMAKE_CXX_FLAGS_RELEASE "/Oi /Ot /Ob2 /Oy /O2 /MT /GS- /GL")
SET(CMAKE_CXX_FLAGS_DEBUG "/Od /MTd /GS")
SET(CMAKE_SHARED_LINKER_FLAGS "/LTCG /OPT:REF /OPT:ICF /SUBSYSTEM:WINDOWS /INCREMENTAL")
ELSEIF(UNIX)
2018-07-20 11:14:25 +03:00
ADD_COMPILE_OPTIONS(-fpermissive -Wall -Wno-write-strings -Wno-unknown-pragmas -pthread)
ELSE()
MESSAGE(FATAL_ERROR "Unsupported platform")
ENDIF()
2018-08-02 12:33:11 +03:00
FUNCTION(POSTBUILD_COPY_OUTPUT target file)
2018-08-03 10:10:45 +03:00
GET_FILENAME_COMPONENT(filename ${file} NAME)
2018-07-19 10:16:47 +03:00
ADD_CUSTOM_COMMAND(
TARGET ${target}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${TRINITY_OUTPUT_DIR}"
2018-08-03 10:10:45 +03:00
COMMAND ${CMAKE_COMMAND} -E copy ${file} "${TRINITY_OUTPUT_DIR}/"
BYPRODUCTS "${TRINITY_OUTPUT_DIR}/${filename}"
)
2018-08-02 12:33:11 +03:00
ENDFUNCTION()
FUNCTION(POSTBUILD_XPLAT_OUTPUT target)
INSTALL(TARGETS ${target} DESTINATION ${TRINITY_INSTALL_DIR})
IF(UNIX)
POSTBUILD_COPY_OUTPUT(${target} "${TRINITY_LIB_DIR}/${target}.dll")
POSTBUILD_COPY_OUTPUT(${target} "${TRINITY_LIB_DIR}/${target}.lib")
INSTALL(FILES ${TRINITY_LIB_DIR}/${target}.dll DESTINATION ${TRINITY_INSTALL_DIR})
ELSEIF(WIN32)
POSTBUILD_COPY_OUTPUT(${target} "${TRINITY_LIB_DIR}/lib${target}.so")
INSTALL(FILES ${TRINITY_LIB_DIR}/lib${target}.so DESTINATION ${TRINITY_INSTALL_DIR})
# TODO debug symbol
# POSTBUILD_COPY_OUTPUT(GraphEngine.Jit.Native "${PROJECT_BINARY_DIR}/GraphEngine.Jit.Native.pdb")
ENDIF()
ENDFUNCTION()
2018-08-02 12:33:11 +03:00
FUNCTION(DOTNET_GET_DEPS _DN_PROJECT arguments)
FILE(GLOB_RECURSE DOTNET_deps "*.cs;*.fs;*.xaml;*.csproj;*.fsproj")
CMAKE_PARSE_ARGUMENTS(
# prefix
_DN
# options (flags)
2018-08-06 19:57:21 +03:00
"RELEASE;DEBUG;X86;X64;ANYCPU;NETCOREAPP"
2018-08-02 12:33:11 +03:00
# oneValueArgs
"CONFIG;PLATFORM;ARGUMENTS"
# multiValueArgs
"PACKAGE;DEPENDS"
# the input arguments
${arguments})
GET_FILENAME_COMPONENT(_DN_abs_proj "${CMAKE_CURRENT_SOURCE_DIR}/${_DN_PROJECT}" ABSOLUTE)
GET_FILENAME_COMPONENT(_DN_proj_dir "${CMAKE_CURRENT_SOURCE_DIR}/${_DN_PROJECT}" DIRECTORY)
GET_FILENAME_COMPONENT(_DN_projname "${DOTNET_PROJECT}" NAME)
STRING(REGEX REPLACE "\\.[^.]*$" "" _DN_projname_noext ${_DN_projname})
IF(_DN_RELEASE)
2018-08-07 15:08:11 +03:00
SET(_DN_CONFIG Release)
2018-08-02 12:33:11 +03:00
ELSEIF(_DN_DEBUG)
2018-08-07 15:08:11 +03:00
SET(_DN_CONFIG Debug)
2018-08-02 12:33:11 +03:00
ENDIF()
2018-08-07 15:08:11 +03:00
IF(NOT _DN_CONFIG)
SET(_DN_CONFIG Release)
2018-08-02 12:33:11 +03:00
ENDIF()
2018-08-07 18:49:02 +03:00
# If platform is not specified, do not pass the Platform property.
# dotnet will pick the default Platform.
2018-08-02 12:33:11 +03:00
IF(_DN_X86)
2018-08-07 15:08:11 +03:00
SET(_DN_PLATFORM x86)
2018-08-02 12:33:11 +03:00
ELSEIF(_DN_X64)
2018-08-07 15:08:11 +03:00
SET(_DN_PLATFORM x64)
2018-08-02 12:33:11 +03:00
ELSEIF(_DN_ANYCPU)
SET(_DN_PLATFORM "Any CPU")
ENDIF()
SET(DOTNET_PACKAGES ${_DN_PACKAGE} PARENT_SCOPE)
SET(DOTNET_CONFIG ${_DN_CONFIG} PARENT_SCOPE)
SET(DOTNET_PLATFORM ${_DN_PLATFORM} PARENT_SCOPE)
SET(DOTNET_DEPENDS ${_DN_DEPENDS} PARENT_SCOPE)
SET(DOTNET_PROJNAME ${_DN_projname_noext} PARENT_SCOPE)
SET(DOTNET_PROJPATH ${_DN_abs_proj} PARENT_SCOPE)
SET(DOTNET_PROJDIR ${_DN_proj_dir} PARENT_SCOPE)
SET(DOTNET_ARGUMENTS ${_DN_ARGUMENTS} PARENT_SCOPE)
2018-08-07 18:49:02 +03:00
IF(_DN_PLATFORM)
SET(_DN_PLATFORM_PROP /p:Platform=${_DN_PLATFORM})
ENDIF()
IF(_DN_NETCOREAPP)
SET(_DN_TFMS_PROP /p:TargetFrameworks=netcoreapp2.0)
ELSEIF(UNIX)
# Unix builds default to netstandard2.0
SET(_DN_TFMS_PROP /p:TargetFrameworks=netstandard2.0)
ENDIF()
2018-08-07 18:49:02 +03:00
SET(DOTNET_BUILD_PROPERTIES ${_DN_PLATFORM_PROP} ${_DN_TFMS_PROP} PARENT_SCOPE)
2018-08-02 12:33:11 +03:00
ENDFUNCTION()
2018-08-03 10:10:45 +03:00
MACRO(ADD_DOTNET_DEPENDENCY_TARGETS)
2018-08-02 12:33:11 +03:00
FOREACH(pkg_dep ${DOTNET_DEPENDS})
ADD_DEPENDENCIES(BUILD_${DOTNET_PROJNAME} PKG_${pkg_dep})
MESSAGE("==== ${DOTNET_PROJNAME} <- ${pkg_dep}")
ENDFOREACH()
FOREACH(pkg ${DOTNET_PACKAGES})
2018-08-24 12:16:16 +03:00
STRING(TOLOWER ${pkg} pkg_lowercase)
SET(cache_path ${NUGET_CACHE_PATH}/${pkg_lowercase})
IF(WIN32)
SET(rm_command powershell -NoLogo -NoProfile -NonInteractive -Command "Remove-Item -Recurse -Force -ErrorAction Ignore '${cache_path}'\; exit 0")
ELSE()
2018-08-24 12:16:16 +03:00
SET(rm_command rm -rf ${cache_path})
ENDIF()
2018-08-02 12:33:11 +03:00
ADD_CUSTOM_TARGET(
DOTNET_PURGE_CACHE_${pkg}
2018-08-07 15:08:11 +03:00
COMMAND ${CMAKE_COMMAND} -E echo "======= [x] Purging nuget package cache for ${pkg}"
COMMAND ${rm_command}
2018-08-02 12:33:11 +03:00
SOURCES ${DOTNET_deps}
)
ADD_DEPENDENCIES(BUILD_${DOTNET_PROJNAME} DOTNET_PURGE_CACHE_${pkg})
# Add a target for the built package -- this can be referenced in
# another project.
ADD_CUSTOM_TARGET(PKG_${pkg})
ADD_DEPENDENCIES(PKG_${pkg} BUILD_${DOTNET_PROJNAME})
MESSAGE("==== ${DOTNET_PROJNAME} -> ${pkg}")
ENDFOREACH()
2018-08-03 10:10:45 +03:00
ENDMACRO()
FUNCTION(ADD_DOTNET DOTNET_PROJECT)
DOTNET_GET_DEPS(${DOTNET_PROJECT} "${ARGN}")
2018-08-07 15:08:11 +03:00
2018-08-03 10:10:45 +03:00
MESSAGE("-- Adding dotnet project ${DOTNET_PROJPATH}")
ADD_CUSTOM_TARGET(
BUILD_${DOTNET_PROJNAME} ALL
2018-08-07 18:49:02 +03:00
${CMAKE_COMMAND} -E echo "=======> Building .NET project ${DOTNET_PROJNAME} [${DOTNET_CONFIG} ${DOTNET_PLATFORM}]"
2018-08-06 19:57:21 +03:00
COMMAND ${DOTNET_EXE} restore ${DOTNET_PROJPATH}
2018-08-07 15:08:11 +03:00
COMMAND ${DOTNET_EXE} clean ${DOTNET_PROJPATH} ${DOTNET_BUILD_PROPERTIES}
COMMAND ${DOTNET_EXE} build --no-restore ${DOTNET_PROJPATH} -c ${DOTNET_CONFIG} ${DOTNET_BUILD_PROPERTIES}
COMMAND ${DOTNET_EXE} pack --no-build --no-restore ${DOTNET_PROJPATH} -c ${DOTNET_CONFIG} ${DOTNET_BUILD_PROPERTIES}
2018-08-03 10:10:45 +03:00
SOURCES ${DOTNET_deps}
)
ADD_DOTNET_DEPENDENCY_TARGETS()
2018-08-02 12:33:11 +03:00
ENDFUNCTION()
FUNCTION(RUN_DOTNET DOTNET_PROJECT)
DOTNET_GET_DEPS(${DOTNET_PROJECT} "${ARGN}")
2018-08-02 08:16:32 +03:00
ADD_CUSTOM_TARGET(
2018-08-02 12:33:11 +03:00
RUN_${DOTNET_PROJNAME}
${DOTNET_EXE} run ${DOTNET_ARGUMENTS}
SOURCES ${DOTNET_deps}
WORKING_DIRECTORY ${DOTNET_PROJDIR}
)
2018-08-02 12:33:11 +03:00
ADD_DEPENDENCIES(RUN_${DOTNET_PROJNAME} BUILD_${DOTNET_PROJNAME})
ENDFUNCTION()
FUNCTION(ADD_MSBUILD DOTNET_PROJECT)
2018-08-03 10:10:45 +03:00
IF(NOT WIN32)
MESSAGE("-- Building non-Win32, skipping ${DOTNET_PROJECT}")
RETURN()
2018-08-03 10:10:45 +03:00
ENDIF()
2018-08-02 12:33:11 +03:00
DOTNET_GET_DEPS(${DOTNET_PROJECT} "${ARGN}")
MESSAGE("-- Adding MSBuild project ${DOTNET_PROJPATH}")
ADD_CUSTOM_TARGET(
2018-08-07 19:32:41 +03:00
BUILD_${DOTNET_PROJNAME} ALL
2018-08-02 14:50:34 +03:00
COMMAND ${TRINITY_NUGET_EXE} restore ${DOTNET_PROJPATH}
2018-08-07 19:32:41 +03:00
COMMAND ${DOTNET_EXE} msbuild ${DOTNET_PROJPATH} /t:Clean /p:Configuration="${DOTNET_CONFIG}"
2018-08-07 18:49:02 +03:00
COMMAND ${DOTNET_EXE} msbuild ${DOTNET_PROJPATH} /t:Build ${DOTNET_BUILD_PROPERTIES} /p:Configuration="${DOTNET_CONFIG}"
COMMAND ${DOTNET_EXE} pack --no-build --no-restore ${DOTNET_PROJPATH} -c ${DOTNET_CONFIG} ${DOTNET_BUILD_PROPERTIES}
2018-08-02 12:33:11 +03:00
SOURCES ${DOTNET_deps}
)
2018-08-03 10:10:45 +03:00
ADD_DOTNET_DEPENDENCY_TARGETS()
2018-08-02 12:33:11 +03:00
ENDFUNCTION()
2018-07-23 09:12:23 +03:00
2018-08-07 18:49:02 +03:00
ADD_SUBDIRECTORY(src/GraphEngine)
2018-07-17 14:00:01 +03:00
ADD_SUBDIRECTORY(src/Trinity.TSL)
ADD_SUBDIRECTORY(src/Trinity.C)
2018-08-02 12:33:11 +03:00
ADD_SUBDIRECTORY(src/Trinity.Core)
2018-07-18 13:29:44 +03:00
ADD_SUBDIRECTORY(src/Modules/GraphEngine.Jit)
2018-08-02 12:33:11 +03:00
ADD_SUBDIRECTORY(src/Modules/Trinity.FFI)
2018-08-07 18:49:02 +03:00
ADD_SUBDIRECTORY(src/Modules/LIKQ)
ADD_SUBDIRECTORY(src/Modules/GraphEngine.Storage.Composite)
ADD_SUBDIRECTORY(src/Modules/GraphEngine.Client)
ADD_SUBDIRECTORY(src/Modules/GraphEngine.DynamicCluster)
2018-08-02 12:33:11 +03:00
2018-08-03 10:10:45 +03:00
ADD_MSBUILD(
src/Modules/GraphEngine.ServiceFabric/GraphEngine.ServiceFabric.sln
PACKAGE
GraphEngine.ServiceFabric.Infrastructure
GraphEngine.ServiceFabric.ListenerRuntime
GraphEngine.ServiceFabric.Remoting
DEPENDS
GraphEngine.Core
GraphEngine.Client
GraphEngine.Storage.Composite
GraphEngine.DynamicCluster
2018-08-07 18:49:02 +03:00
GraphEngine.Azure.BlobStorage
2018-08-03 10:10:45 +03:00
X64
CONFIG RelSkipSFApp
)
2018-08-02 12:33:11 +03:00
2018-08-02 14:50:34 +03:00
# ADD_DOTNET(
# src/GraphEngine.DataImporter/GraphEngine.DataImporter.sln
# PACKAGE GraphEngine.DataImporter
# DEPENDS GraphEngine.Core)