This is cleaner than the previous impl, which used separate build targets to copy libspark to "net7.0", and "net7.0-windows" (dirs). Note: I decided to clean this up now because I'm about to upgrade the new DataStream WebApp to net8.0, and did not want to add yet another build target to copy libspark to "net8.0".
75 lines
2.6 KiB
CMake
75 lines
2.6 KiB
CMake
cmake_minimum_required(VERSION 3.5)
|
|
project(libspark)
|
|
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
|
include(${CMAKE_SOURCE_DIR}/cmake/safe_dep_glob.cmake)
|
|
include(${CMAKE_SOURCE_DIR}/cmake/Protobuf.cmake)
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GenerateDefaultConfig.cmake)
|
|
include(${CMAKE_SOURCE_DIR}/cmake/PrintList.cmake)
|
|
|
|
if (DEFINED DOTNET_BINARY_DIR OR DEFINED DOTNET_WINDOWS_BINARY_DIR)
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/AddCopyBinariesTarget.cmake)
|
|
endif()
|
|
|
|
if(WIN32)
|
|
if(BUILD_SPARKD)
|
|
message(FATAL_ERROR "Cannot build sparkd on Windows (Please set BUILD_SPARKD to False)")
|
|
endif()
|
|
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetWindowsClientSources.cmake)
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetWindowsClientLinkLibraries.cmake)
|
|
elseif(${BUILD_SPARKD})
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetLinuxServerSources.cmake)
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetLinuxServerLinkLibraries.cmake)
|
|
else()
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetLinuxClientSources.cmake)
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetLinuxClientLinkLibraries.cmake)
|
|
endif()
|
|
|
|
# Cpp sources
|
|
set(${PROJECT_NAME}_Sources)
|
|
get_cpp_sources(${PROJECT_NAME}_Sources)
|
|
print_list(${PROJECT_NAME}_Sources VERBOSE)
|
|
|
|
# Proto sources
|
|
get_proto_sources(_cfg_protos _non_cfg_protos _service_protos _cfg_defaults)
|
|
print_list(_cfg_protos VERBOSE)
|
|
print_list(_non_cfg_protos VERBOSE)
|
|
print_list(_service_protos VERBOSE)
|
|
print_list(_cfg_defaults VERBOSE)
|
|
|
|
update_deps_file("${${PROJECT_NAME}_Sources};${_cfg_protos};${_service_protos};${_non_cfg_protos};${_cfg_defaults}")
|
|
|
|
# Generate proto cpp
|
|
message(STATUS "Generating proto cpp")
|
|
protobuf_generate_cpp(_proto_srcs _proto_hdrs ${_non_cfg_protos} ${_cfg_protos})
|
|
service_compiler_generate_cpp(SERVICE_COMPILER_SRCS SERVICE_COMPILER_HDRS ${_service_protos})
|
|
message(STATUS "Generating default config")
|
|
generate_default_config(_cfg_protos _cfg_defaults)
|
|
|
|
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_Sources} ${_proto_srcs} ${SERVICE_COMPILER_SRCS})
|
|
|
|
target_include_directories(
|
|
${PROJECT_NAME} PUBLIC
|
|
${CMAKE_SOURCE_DIR}/src
|
|
${CMAKE_BINARY_DIR}/src)
|
|
|
|
get_link_libraries(_link_libs)
|
|
print_list(_link_libs VERBOSE)
|
|
target_link_libraries(${PROJECT_NAME} ${_link_libs})
|
|
|
|
# Copy binaries to Dotnet build dirs (for csprojs that depend on libspark)
|
|
if (DEFINED DOTNET_BINARY_DIR)
|
|
add_copy_binaries_target(
|
|
copy_to_dotnet_binary_dir
|
|
${DOTNET_BINARY_DIR}
|
|
"Copy ${PROJECT_NAME} bins to Dotnet build dir")
|
|
endif()
|
|
|
|
if(BUILD_SPARKD)
|
|
install(TARGETS ${PROJECT_NAME} DESTINATION "${SPARK_INSTALL_PREFIX}/bin")
|
|
endif()
|
|
|
|
if(WIN32)
|
|
include(${CMAKE_SOURCE_DIR}/cmake/vs_filters.cmake)
|
|
endif()
|