Files
spark/src/lib/CMakeLists.txt
T
2018-07-06 16:25:37 +00:00

125 lines
3.3 KiB
CMake

cmake_minimum_required(VERSION 3.5)
project(libspark)
set(CMAKE_SHARED_LIBRARY_PREFIX "")
include(${CMAKE_SOURCE_DIR}/tools/safe_dep_glob.cmake)
include(${CMAKE_SOURCE_DIR}/tools/Protobuf.cmake)
# DEPENDENCIES
file(GLOB_RECURSE Config_Protos RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} config/protos/*.proto)
file (GLOB_RECURSE Service_Protos RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} api/services/*.proto)
file(GLOB_RECURSE NonConfig_Protos RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.proto)
list(REMOVE_ITEM NonConfig_Protos ${Service_Protos} ${Config_Protos})
file(GLOB_RECURSE Conf_Defaults RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} config/defaults/*.conf)
if (WIN32)
file(GLOB_RECURSE SparkLib_Sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
api/*.cpp
config/*.cpp
domain_model/*.cpp
expression/*.cpp
logging/*.cpp
md/*.cpp
os/*.cpp
quickbus/*.cpp
sparkproto/*.cpp
testing/*.cpp
utils/*.cpp)
else ()
file(GLOB_RECURSE SparkLib_Sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
endif()
update_deps_file("${SparkLib_Sources};${Config_Protos};${Service_Protos};${NonConfig_Protos};${Conf_Defaults}")
# END DEPENDENCIES
protobuf_generate_cpp( PROTO_SRCS PROTO_HDRS ${NonConfig_Protos} ${Config_Protos})
service_compiler_generate_cpp(SERVICE_COMPILER_SRCS SERVICE_COMPILER_HDRS ${Service_Protos})
# generate list of config protos
set(config_proto_file ${CMAKE_CURRENT_BINARY_DIR}/config_proto_files.h)
# generate a string with the current config files
set(config_proto_str "const char * config_proto_files[] = { // generated file\n")
foreach(protopath ${Config_Protos})
get_filename_component(protoname ${protopath} NAME)
string(APPEND config_proto_str "\"${protoname}\",\n")
endforeach(protopath)
string(APPEND config_proto_str "} ;\n")
# compare with file and if there is any difference update the file
set(old_config_proto_str "")
if(EXISTS "${config_proto_file}")
file(READ "${config_proto_file}" old_config_proto_str)
endif()
if(NOT old_config_proto_str STREQUAL config_proto_str)
file(WRITE "${config_proto_file}" "${config_proto_str}")
endif()
# copy defaults to output directory
foreach (cfg_file_path ${Conf_Defaults})
get_filename_component(cfg_file_name ${cfg_file_path} NAME)
configure_file(${cfg_file_path} ${CMAKE_BINARY_DIR}/src/server/sparkd/defaults/${cfg_file_name})
endforeach(cfg_file_path)
# lib
if (WIN32)
add_library(libspark SHARED
${SparkLib_Sources}
${PROTO_SRCS}
${SERVICE_COMPILER_SRCS}
)
else ()
add_library(libspark SHARED
${SparkLib_Sources}
${PROTO_SRCS}
${SERVICE_COMPILER_SRCS}
)
endif()
#include paths
target_include_directories( libspark PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src)
if (WIN32)
target_link_libraries( libspark
libcurl
libfmt
libtbb
libboost_system
libboost_thread
libboost_filesystem
libboost_regex
libboost_chrono
libboost_date_time
libboost_atomic
libprotobuf
)
else ()
target_link_libraries( libspark
protobuf
boost_system
boost_thread
boost_filesystem
boost_regex
boost_chrono
boost_date_time
boost_atomic
sqlite3
curl
uuid
ssl
crypto
fmt
tbb
cryptopp
-lrt
-ldl
-static-libgcc
-static-libstdc++
-pthread)
endif()
if (WIN32)
include(${CMAKE_SOURCE_DIR}/tools/vs_filters.cmake)
endif()