vcpe/depend/third_libs.cmake

134 lines
4.7 KiB
CMake
Raw Normal View History

2023-01-30 10:30:39 +00:00
CMAKE_MINIMUM_REQUIRED(VERSION 3.14 FATAL_ERROR)
INCLUDE(FetchContent)
PKG_SEARCH_MODULE(LIBCURL REQUIRED libcurl)
PKG_SEARCH_MODULE(LIBSSL REQUIRED libssl)
PKG_SEARCH_MODULE(LIBCRYPTO REQUIRED libcrypto)
IF (USED_SQLITE AND (NOT USED_SQLITE_CRYPTO))
PKG_SEARCH_MODULE(LIBSQLITE3 REQUIRED sqlite3)
ENDIF ()
IF (USED_ZMQ)
PKG_SEARCH_MODULE(LIBZMQ QUIET libzmq)
2023-03-14 06:14:14 +00:00
IF (NOT LIBZMQ_FOUND)
LINUX_INSTALL_SYSTEM_PACKAGE()
ENDIF ()
ENDIF ()
2023-03-14 06:14:14 +00:00
IF ((NOT LIBCRYPTO_FOUND) OR (NOT LIBSSL_FOUND) OR (NOT LIBCURL_FOUND))
LINUX_INSTALL_SYSTEM_PACKAGE()
ENDIF ()
LIST(APPEND COMMON_LIBS "${LIBCURL_LDFLAGS} ${LIBSSL_LDFLAGS} ${LIBCRYPTO_LDFLAGS} ${LIBSQLITE3_LDFLAGS}")
LIST(APPEND COMMON_LIBS "${LIBZMQ_LDFLAGS}")
LIST(APPEND COMMON_LIBS "-lm -lpthread")
PKG_SEARCH_MODULE(LIBUV QUIET libuv)
PKG_SEARCH_MODULE(LIBCONFIG QUIET libconfig)
FIND_LIBRARY(LIBZLOG zlog PATHS "/usr/local/lib")
IF (USED_JSON_VALIDATE)
PKG_CHECK_MODULES(LIBJSON-C QUIET json-c>=0.13)
IF (NOT LIBJSON-C_FOUND)
FETCHCONTENT_DECLARE(libjson-c
URL file://${CMAKE_SOURCE_DIR}/depend/json-c-0.16.tar.gz
URL_MD5 a549a833f886d427148fb5710c3e613e
)
ENDIF ()
ENDIF ()
IF (NOT LIBUV_FOUND)
FETCHCONTENT_DECLARE(libuv
URL file://${CMAKE_SOURCE_DIR}/depend/libuv-v1.44.2.tar.gz
URL_MD5 0addbddcb1098e2c1c99f03f0108e1e7)
ENDIF ()
IF (NOT LIBCONFIG_FOUND)
FETCHCONTENT_DECLARE(libconfig
URL file://${CMAKE_SOURCE_DIR}/depend/libconfig-1.7.3.tar.gz
URL_MD5 8f96910eee26118258ac8d4cd128a0b2)
ENDIF ()
IF (LIBZLOG STREQUAL "LIBZLOG-NOTFOUND")
FETCHCONTENT_DECLARE(zlog
URL file://${CMAKE_SOURCE_DIR}/depend/zlog-1.2.16.tar.gz
URL_MD5 74ebc6fc119d756a13e692b734642ea6)
ENDIF ()
IF (NOT LIBUV_FOUND)
FETCHCONTENT_MAKEAVAILABLE(libuv)
ENDIF ()
IF (NOT LIBCONFIG_FOUND)
FETCHCONTENT_MAKEAVAILABLE(libconfig)
ENDIF ()
IF (LIBZLOG STREQUAL "LIBZLOG-NOTFOUND")
FETCHCONTENT_MAKEAVAILABLE(zlog)
ENDIF ()
IF (USED_JSON_VALIDATE)
IF (NOT LIBJSON-C_FOUND)
FETCHCONTENT_MAKEAVAILABLE(libjson-c)
ENDIF ()
ENDIF ()
IF (NOT LIBUV_FOUND)
MESSAGE(STATUS "libuv not found, will be used source code to build it ...")
FETCHCONTENT_GETPROPERTIES(libuv)
IF (NOT libuv_POPULATED)
FETCHCONTENT_POPULATE(libuv)
ADD_SUBDIRECTORY(${libuv_SOURCE_DIR} ${libuv_BINARY_DIR})
ENDIF ()
INCLUDE_DIRECTORIES(${libuv_SOURCE_DIR}/include)
LIST(APPEND COMMON_LIBS "uv_a")
ELSE ()
MESSAGE(STATUS "libuv found ${LIBUV_VERSION} at ${LIBUV_LIBRARY_DIRS}")
LIST(APPEND COMMON_LIBS "${LIBUV_LDFLAGS}")
ENDIF ()
IF (NOT LIBCONFIG_FOUND)
MESSAGE(STATUS "libconfig not found, will be used source code to build it ...")
FETCHCONTENT_GETPROPERTIES(libconfig)
IF (NOT libconfig_POPULATED)
FETCHCONTENT_POPULATE(libconfig)
ADD_SUBDIRECTORY(${libconfig_SOURCE_DIR} ${libconfig_BINARY_DIR})
ENDIF ()
INCLUDE_DIRECTORIES(${libconfig_SOURCE_DIR}/lib)
LIST(APPEND COMMON_LIBS "config")
ELSE ()
MESSAGE(STATUS "libconfig found ${LIBCONFIG_VERSION} at ${LIBCONFIG_LIBRARY_DIRS}")
LIST(APPEND COMMON_LIBS "${LIBCONFIG_LDFLAGS}")
ENDIF ()
IF (LIBZLOG STREQUAL "LIBZLOG-NOTFOUND")
MESSAGE(STATUS "zlog not found, will be used source code to build it ...")
FETCHCONTENT_GETPROPERTIES(zlog)
IF (NOT zlog_POPULATED)
FETCHCONTENT_POPULATE(zlog)
ADD_SUBDIRECTORY(${zlog_SOURCE_DIR} ${zlog_BINARY_DIR})
ENDIF ()
INCLUDE_DIRECTORIES(${zlog_SOURCE_DIR}/src)
LIST(APPEND COMMON_LIBS "zlog")
ELSE ()
MESSAGE(STATUS "zlog found of ${LIBZLOG}")
LIST(APPEND COMMON_LIBS "${LIBZLOG}")
ENDIF ()
IF (USED_JSON_VALIDATE)
IF (NOT LIBJSON-C_FOUND)
MESSAGE(STATUS "json-c not found, will be used source code to build it ...")
FETCHCONTENT_GETPROPERTIES(libjson-c)
IF (NOT libjson-c_POPULATED)
FETCHCONTENT_POPULATE(libjson-c)
ADD_SUBDIRECTORY(${libjson-c_SOURCE_DIR} ${libjson-c_BINARY_DIR})
ENDIF ()
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory "json-c"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${libjson-c_BINARY_DIR}/json.h" "./json-c/"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${libjson-c_BINARY_DIR}/json_config.h" "."
WORKING_DIRECTORY ${libjson-c_SOURCE_DIR})
INCLUDE_DIRECTORIES(${libjson-c_SOURCE_DIR})
LIST(APPEND COMMON_LIBS "json-c")
ELSE ()
MESSAGE(STATUS "json-c found ${LIBJSON-C_VERSION} at ${LIBJSON-C_LIBRARY_DIRS}")
LIST(APPEND COMMON_LIBS "${LIBJSON-C_LDFLAGS}")
ENDIF ()
ENDIF ()