2020-07-06 19:04:32 -04:00
function ( build_dependencies )
2021-01-28 21:00:27 -05:00
# Set options for SQLiteCpp, disable all their lints and other features we don't need:
set ( SQLITE_ENABLE_COLUMN_METADATA OFF CACHE BOOL "Enable Column::getColumnOriginName(). Require support from sqlite3 library." )
set ( SQLITE_ENABLE_JSON1 OFF CACHE BOOL "Enable JSON1 extension when building internal sqlite3 library." )
set ( SQLITECPP_INCLUDE_SCRIPT OFF CACHE BOOL "Include config & script files." )
2020-09-28 18:38:42 -04:00
set ( SQLITECPP_RUN_CPPCHECK OFF CACHE BOOL "Run cppcheck C++ static analysis tool." )
set ( SQLITECPP_RUN_CPPLINT OFF CACHE BOOL "Run cpplint.py tool for Google C++ StyleGuide." )
set ( SQLITECPP_USE_STACK_PROTECTION OFF CACHE BOOL "USE Stack Protection hardening." )
2021-01-28 21:00:27 -05:00
set ( SQLITECPP_USE_STATIC_RUNTIME OFF CACHE BOOL "Use MSVC static runtime (default for internal googletest)." )
2020-05-21 18:52:19 -04:00
2020-05-27 18:48:49 -04:00
# Set options for LibEvent, disable all their tests and benchmarks:
set ( EVENT__DISABLE_OPENSSL YES CACHE BOOL "Disable OpenSSL in LibEvent" )
set ( EVENT__DISABLE_BENCHMARK YES CACHE BOOL "Disable LibEvent benchmarks" )
set ( EVENT__DISABLE_TESTS YES CACHE BOOL "Disable LibEvent tests" )
set ( EVENT__DISABLE_REGRESS YES CACHE BOOL "Disable LibEvent regression tests" )
set ( EVENT__DISABLE_SAMPLES YES CACHE BOOL "Disable LibEvent samples" )
set ( EVENT__LIBRARY_TYPE "STATIC" CACHE STRING "Use static LibEvent libraries" )
2020-05-21 18:52:19 -04:00
2020-05-27 18:48:49 -04:00
# Set options for JsonCPP, disabling all of their tests:
set ( JSONCPP_WITH_TESTS OFF CACHE BOOL "Compile and (for jsoncpp_check) run JsonCpp test executables" )
set ( JSONCPP_WITH_POST_BUILD_UNITTEST OFF CACHE BOOL "Automatically run unit-tests as a post build step" )
set ( JSONCPP_WITH_PKGCONFIG_SUPPORT OFF CACHE BOOL "Generate and install .pc files" )
2021-04-11 19:25:51 -04:00
set ( JSONCPP_WITH_CMAKE_PACKAGE OFF CACHE BOOL "Generate and install cmake package files" )
set ( BUILD_SHARED_LIBS OFF CACHE BOOL "Build jsoncpp_lib as a shared library." )
set ( BUILD_OBJECT_LIBS OFF CACHE BOOL "Build jsoncpp_lib as a object library." )
2020-05-21 18:52:19 -04:00
2020-05-27 18:48:49 -04:00
# Set options for mbedtls:
set ( ENABLE_PROGRAMS OFF CACHE BOOL "Build mbed TLS programs." )
set ( ENABLE_TESTING OFF CACHE BOOL "Build mbed TLS tests." )
2020-05-21 18:52:19 -04:00
2020-05-27 18:48:49 -04:00
# Enumerate all submodule libraries
# SQLiteCpp needs to be included before sqlite so the lsqlite target is available:
2021-01-11 11:39:43 -05:00
set ( DEPENDENCIES expat fmt jsoncpp libdeflate libevent lua luaexpat mbedtls SQLiteCpp sqlite tolua++ )
2020-05-27 18:48:49 -04:00
foreach ( DEPENDENCY ${ DEPENDENCIES } )
# Check that the libraries are present:
if ( NOT EXISTS "${PROJECT_SOURCE_DIR}/lib/${DEPENDENCY}/CMakeLists.txt" )
message ( FATAL_ERROR "${DEPENDENCY} is missing in folder lib/${DEPENDENCY}. Have you initialized and updated the submodules / downloaded the extra libraries?" )
endif ( )
2020-05-21 18:52:19 -04:00
2020-05-27 18:48:49 -04:00
# Include all the libraries
# We use EXCLUDE_FROM_ALL so that only the explicit dependencies are compiled
# (mbedTLS also has test and example programs in their CMakeLists.txt, we don't want those):
add_subdirectory ( "lib/${DEPENDENCY}" EXCLUDE_FROM_ALL )
endforeach ( )
2020-05-21 18:52:19 -04:00
2020-07-06 19:04:32 -04:00
if ( WIN32 )
add_subdirectory ( lib/luaproxy )
endif ( )
endfunction ( )
function ( link_dependencies TARGET )
2020-05-27 18:48:49 -04:00
# Add required includes:
target_include_directories (
$ { T A R G E T } S Y S T E M P R I V A T E
l i b / m b e d t l s / i n c l u d e
l i b / T C L A P / i n c l u d e
l i b # TODO fix files including zlib/x instead of x
)
2020-05-21 18:52:19 -04:00
2020-05-27 18:48:49 -04:00
# Link dependencies as private:
target_link_libraries (
$ { T A R G E T } P R I V A T E
e v e n t _ c o r e
e v e n t _ e x t r a
f m t : : f m t
2021-04-11 19:25:51 -04:00
j s o n c p p _ s t a t i c
2021-01-11 11:39:43 -05:00
l i b d e f l a t e
2020-05-27 18:48:49 -04:00
l s q l i t e
2020-07-12 18:38:13 -04:00
l u a l i b
2020-05-27 18:48:49 -04:00
l u a e x p a t
m b e d t l s
S Q L i t e C p p
t o l u a l i b
)
2020-05-21 18:52:19 -04:00
2020-05-27 18:48:49 -04:00
# Link process information library:
if ( WIN32 )
target_link_libraries ( ${ TARGET } PRIVATE Psapi.lib )
endif ( )
2020-05-21 18:52:19 -04:00
2020-05-27 18:48:49 -04:00
# Special case handling for libevent pthreads:
if ( NOT WIN32 )
target_link_libraries ( ${ TARGET } PRIVATE event_pthreads )
endif ( )
2020-05-21 18:52:19 -04:00
2021-04-11 19:25:51 -04:00
# Prettify jsoncpp_static name in VS solution explorer:
set_property ( TARGET jsoncpp_static PROPERTY PROJECT_LABEL "jsoncpp" )
2020-05-27 18:48:49 -04:00
endfunction ( )