diff --git a/depend/libconfig-1.7.3.tar.gz b/depend/libconfig-1.7.3.tar.gz index 424e971..f077a54 100644 Binary files a/depend/libconfig-1.7.3.tar.gz and b/depend/libconfig-1.7.3.tar.gz differ diff --git a/depend/system_libs.cmake b/depend/system_libs.cmake index 153c9a4..d5be3fd 100644 --- a/depend/system_libs.cmake +++ b/depend/system_libs.cmake @@ -19,11 +19,11 @@ FUNCTION(LINUX_INSTALL_SYSTEM_PACKAGE) MESSAGE("Run this command to install system(${OS_DISTRIB_NAME}) dependencies libraries:") IF (${OS_DISTRIB_NAME} MATCHES "CentOS") - MESSAGE(ERROR "$sudo yum -y install libcurl-devel czmq-devel openssl-devel uuid-devel") + MESSAGE(FATAL_ERROR "$sudo yum -y install libcurl-devel czmq-devel openssl-devel uuid-devel") ELSEIF (${OS_DISTRIB_NAME} MATCHES "Ubuntu") - MESSAGE(ERROR "$sudo -S apt -y install libcurl4-openssl-dev libczmq-dev libssl-dev uuid-dev") + MESSAGE(FATAL_ERROR "$sudo -S apt -y install libcurl4-openssl-dev libczmq-dev libssl-dev uuid-dev") ENDIF () ELSE() - MESSAGE(ERROR "Run command to install system dependencies libraries by yourself") + MESSAGE(FATAL_ERROR "Run command to install system dependencies libraries by yourself") ENDIF () ENDFUNCTION(LINUX_INSTALL_SYSTEM_PACKAGE) \ No newline at end of file diff --git a/depend/third_libs.cmake b/depend/third_libs.cmake new file mode 100644 index 0000000..a76a5fe --- /dev/null +++ b/depend/third_libs.cmake @@ -0,0 +1,75 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 3.14) +INCLUDE(FetchContent) + +PKG_SEARCH_MODULE(LIBUV QUIET libuv) +PKG_SEARCH_MODULE(LIBCONFIG QUIET libconfig) +FIND_LIBRARY(LIBZLOG zlog PATHS "/usr/local/lib") + +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 (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 () + 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 () + 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 () + LIST(APPEND COMMON_LIBS "zlog") +ELSE () + MESSAGE(STATUS "zlog found of ${LIBZLOG}") + LIST(APPEND COMMON_LIBS "${LIBZLOG}") +ENDIF () \ No newline at end of file diff --git a/depend/zlog-1.2.15.zip b/depend/zlog-1.2.15.zip deleted file mode 100644 index 6002458..0000000 Binary files a/depend/zlog-1.2.15.zip and /dev/null differ diff --git a/depend/zlog-1.2.16.tar.gz b/depend/zlog-1.2.16.tar.gz new file mode 100644 index 0000000..9ce5a7a Binary files /dev/null and b/depend/zlog-1.2.16.tar.gz differ diff --git a/srcs/CMakeLists.txt b/srcs/CMakeLists.txt index 50ea6a6..81602ef 100644 --- a/srcs/CMakeLists.txt +++ b/srcs/CMakeLists.txt @@ -20,12 +20,12 @@ IF ((NOT LIBZMQ_FOUND) OR (NOT LIBCRYPTO_FOUND) OR (NOT LIBSSL_FOUND) OR (NOT LI LINUX_INSTALL_SYSTEM_PACKAGE() ENDIF () -PKG_SEARCH_MODULE(LIBUV REQUIRED libuv) -PKG_SEARCH_MODULE(LIBCONFIG REQUIRED libconfig) -FIND_LIBRARY(LIBZLOG zlog REQUIRED) +SET(COMMON_LIBS "") -LIST(APPEND COMMON_LIBS "${LIBUV_LDFLAGS} ${LIBCURL_LDFLAGS} ${LIBSSL_LDFLAGS} ${LIBCRYPTO_LDFLAGS}") -LIST(APPEND COMMON_LIBS "${LIBCONFIG_LDFLAGS} ${LIBZMQ_LDFLAGS} ${LIBZLOG} ${LIBUUID}") +INCLUDE(../depend/third_libs.cmake) + +LIST(APPEND COMMON_LIBS "${LIBCURL_LDFLAGS} ${LIBSSL_LDFLAGS} ${LIBCRYPTO_LDFLAGS}") +LIST(APPEND COMMON_LIBS "${LIBZMQ_LDFLAGS} ${LIBUUID}") LIST(APPEND COMMON_LIBS "-lm -lpthread") ADD_DEFINITIONS(${COMMON_DEFINE}) diff --git a/srcs/httpserver/CMakeLists.txt b/srcs/httpserver/CMakeLists.txt index 9d662bf..827fc67 100644 --- a/srcs/httpserver/CMakeLists.txt +++ b/srcs/httpserver/CMakeLists.txt @@ -34,6 +34,6 @@ INCLUDE_DIRECTORIES(. ./include) #find_package(Threads REQUIRED) ADD_LIBRARY(haywire STATIC ${HW_SRC} ${HW_HEADS}) -TARGET_LINK_LIBRARIES(haywire -luv -pthread) +TARGET_LINK_LIBRARIES(haywire) diff --git a/srcs/libs/CMakeLists.txt b/srcs/libs/CMakeLists.txt index f83146f..e51c96f 100644 --- a/srcs/libs/CMakeLists.txt +++ b/srcs/libs/CMakeLists.txt @@ -52,10 +52,9 @@ ENDIF () ADD_DEFINITIONS(${COMMON_DEFINE}) -LINK_LIBRARIES(${COMMON_LIBS}) ADD_LIBRARY(${LIB_PROJECT_TARGET} ${C_SRC} ${C_HEADS}) -TARGET_LINK_LIBRARIES(${LIB_PROJECT_TARGET} haywire) +TARGET_LINK_LIBRARIES(${LIB_PROJECT_TARGET} ${COMMON_LIBS} haywire) IF (USED_OPENDHCPD) TARGET_LINK_LIBRARIES(${LIB_PROJECT_TARGET} opendhcpd)