diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d20badd20c..606a592d9c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,15 +7,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake") -find_package(cJSON CONFIG REQUIRED) -find_package(CURL REQUIRED) -find_package(nlohmann_json CONFIG REQUIRED) -find_package(LibArchive REQUIRED) -find_package(Lua REQUIRED) -find_package(pcre2 CONFIG REQUIRED) -find_package(unofficial-sqlite3 CONFIG REQUIRED) -find_package(ZLIB REQUIRED) - project(wazuh-agent) add_subdirectory(agent) diff --git a/src/common/data_provider/CMakeLists.txt b/src/common/data_provider/CMakeLists.txt index ec5156dcd4..6c65cd3871 100644 --- a/src/common/data_provider/CMakeLists.txt +++ b/src/common/data_provider/CMakeLists.txt @@ -62,6 +62,12 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +find_package(cJSON CONFIG REQUIRED) +find_package(LibArchive REQUIRED) +find_package(Lua REQUIRED) +find_package(nlohmann_json CONFIG REQUIRED) +find_package(unofficial-sqlite3 CONFIG REQUIRED) + find_path(POPT_INCLUDE_DIR include/popt.h) include_directories(${POPT_INCLUDE_DIR}) diff --git a/src/common/dbsync/CMakeLists.txt b/src/common/dbsync/CMakeLists.txt index 1a20849c0f..d248d15fe9 100644 --- a/src/common/dbsync/CMakeLists.txt +++ b/src/common/dbsync/CMakeLists.txt @@ -36,6 +36,9 @@ if(APPLE) set(CMAKE_MACOSX_RPATH 1) endif(APPLE) +find_package(cJSON CONFIG REQUIRED) +find_package(nlohmann_json CONFIG REQUIRED) +find_package(unofficial-sqlite3 CONFIG REQUIRED) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/) @@ -54,8 +57,6 @@ else() endif(CMAKE_SYSTEM_NAME STREQUAL "HP-UX") link_directories(${SRC_FOLDER}) -link_directories(${SRC_FOLDER}/external/sqlite/) -link_directories(${SRC_FOLDER}/external/cJSON/) file(GLOB DBSYNC_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" diff --git a/src/common/debug_op/CMakeLists.txt b/src/common/debug_op/CMakeLists.txt index f0c272d957..72131b0ed9 100644 --- a/src/common/debug_op/CMakeLists.txt +++ b/src/common/debug_op/CMakeLists.txt @@ -1,5 +1,7 @@ add_library(debug_op STATIC src/debug_op.c) +find_package(cJSON CONFIG REQUIRED) + target_include_directories(debug_op PUBLIC include) target_link_libraries(debug_op diff --git a/src/common/expression/CMakeLists.txt b/src/common/expression/CMakeLists.txt index f045ae8976..0ba298b0cf 100644 --- a/src/common/expression/CMakeLists.txt +++ b/src/common/expression/CMakeLists.txt @@ -1,3 +1,5 @@ +find_package(pcre2 CONFIG REQUIRED) + add_library(expression STATIC src/expression.c) target_include_directories(expression PUBLIC include) diff --git a/src/common/file_op/CMakeLists.txt b/src/common/file_op/CMakeLists.txt index 13412f8e72..7eb35c1cf6 100644 --- a/src/common/file_op/CMakeLists.txt +++ b/src/common/file_op/CMakeLists.txt @@ -1,3 +1,5 @@ +find_package(ZLIB REQUIRED) + add_library(file_op STATIC src/file_op.c) target_include_directories(file_op PUBLIC include) diff --git a/src/common/http-request/CMakeLists.txt b/src/common/http-request/CMakeLists.txt index 3c0335af76..57b86aa872 100644 --- a/src/common/http-request/CMakeLists.txt +++ b/src/common/http-request/CMakeLists.txt @@ -11,75 +11,19 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_FLAGS "-fPIC") -if(NOT EXTERNAL_DEPS_VERSION) - set(EXTERNAL_DEPS_VERSION "19") -endif(NOT EXTERNAL_DEPS_VERSION) - -if(NOT RESOURCES_URL) - set(RESOURCES_URL "https://packages.wazuh.com/deps/${EXTERNAL_DEPS_VERSION}/libraries/sources") -endif(NOT RESOURCES_URL) - -if(NOT PRECOMPILED_RESOURCES_URL) - set(PRECOMPILED_RESOURCES_URL "https://packages.wazuh.com/deps/${EXTERNAL_DEPS_VERSION}/libraries/linux/amd64") -endif(NOT PRECOMPILED_RESOURCES_URL) - -if(USE_HTTP) - string(REPLACE "https://" "http://" RESOURCES_URL ${RESOURCES_URL}) - string(REPLACE "https://" "http://" PRECOMPILED_RESOURCES_URL ${PRECOMPILED_RESOURCES_URL}) -endif() - -function(check_and_download_dep libname url) - if(NOT EXISTS ${SRC_FOLDER}/external/${libname}) - message("==============================================") - message("Downloading ${libname}...") - file(DOWNLOAD ${url}/${libname}.tar.gz ${SRC_FOLDER}/external/${libname}.tar.gz - TIMEOUT 60 # seconds - STATUS DOWNLOAD_STATUS) - list(GET DOWNLOAD_STATUS 0 STATUS_CODE) - list(GET DOWNLOAD_STATUS 1 STATUS_MESSAGE) - if(NOT STATUS_CODE EQUAL 0) - message(FATAL_ERROR "Error downloading ${libname}: ${STATUS_MESSAGE} (${STATUS_CODE}) .") - endif(NOT STATUS_CODE EQUAL 0) - message("Extracting ${libname}.tar.gz") - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${SRC_FOLDER}/external/${libname}.tar.gz" WORKING_DIRECTORY ${SRC_FOLDER}/external RESULT_VARIABLE STATUS_VALUE) - if(NOT STATUS_VALUE EQUAL 0) - message(FATAL_ERROR "Error extracting ${libname}: ${STATUS_VALUE}.") - endif(NOT STATUS_VALUE EQUAL 0) - message("Cleaning ${libname}.tar.gz") - file(REMOVE ${SRC_FOLDER}/external/${libname}.tar.gz) - endif() -endfunction(check_and_download_dep) - -set(EXTERNAL_RES nlohmann googletest benchmark cpp-httplib) -set(PRECOMPILED_EXTERNAL_RES curl) - -foreach(loop_var ${EXTERNAL_RES}) - check_and_download_dep(${loop_var} ${RESOURCES_URL}) -endforeach(loop_var) - -foreach(loop_var ${PRECOMPILED_EXTERNAL_RES}) - check_and_download_dep(${loop_var} ${PRECOMPILED_RESOURCES_URL}) -endforeach(loop_var) - set(BENCHMARK_ENABLE_TESTING "OFF") +find_package(CURL REQUIRED) +find_package(nlohmann_json CONFIG REQUIRED) + include_directories(src/) include_directories(include/) -# include_directories(${SRC_FOLDER}/external/curl/include/curl/) -# include_directories(${SRC_FOLDER}/external/nlohmann/) include_directories(BEFORE PRIVATE shared/) -link_directories(${SRC_FOLDER}/external/curl/lib/.libs/) - file(GLOB URL_REQUEST_SRC src/*.cpp) add_library(urlrequest ${URL_REQUEST_SRC}) -if(NOT DEFINED CURL_DEP) - set(CURL_DEP curl) -endif(NOT DEFINED CURL_DEP) - -# target_link_libraries(urlrequest ${CURL_DEP}) target_link_libraries(urlrequest nlohmann_json::nlohmann_json CURL::libcurl) if (${CMAKE_PROJECT_NAME} STREQUAL "urlrequest") diff --git a/src/modules/inventory/CMakeLists.txt b/src/modules/inventory/CMakeLists.txt index 80dd5c5af7..0bb30a55ec 100644 --- a/src/modules/inventory/CMakeLists.txt +++ b/src/modules/inventory/CMakeLists.txt @@ -5,6 +5,9 @@ project(Inventory) get_filename_component(SRC_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/../../ ABSOLUTE) get_filename_component(COMMON_FOLDER ${SRC_FOLDER}/common/ ABSOLUTE) +find_package(cJSON CONFIG REQUIRED) +find_package(nlohmann_json CONFIG REQUIRED) + add_library(inventory src/inventory.cpp src/inventoryImp.cpp diff --git a/src/modules/inventory/include/inventory.h b/src/modules/inventory/include/inventory.h index 68a2979f2b..62fe05478f 100644 --- a/src/modules/inventory/include/inventory.h +++ b/src/modules/inventory/include/inventory.h @@ -8,7 +8,6 @@ #include #include #include -#include #include "sysInfoInterface.h" #include "configuration.h" #include "logging_helper.h" diff --git a/src/modules/inventory/src/inventory.cpp b/src/modules/inventory/src/inventory.cpp index 871cac26a2..69b14a7657 100644 --- a/src/modules/inventory/src/inventory.cpp +++ b/src/modules/inventory/src/inventory.cpp @@ -10,6 +10,7 @@ */ #include +#include #include "shared.h" #include "defs.h" #include "logging_helper.h" diff --git a/src/modules/pool.cpp b/src/modules/pool.cpp index 463c5ad284..6ce99b1c48 100644 --- a/src/modules/pool.cpp +++ b/src/modules/pool.cpp @@ -1,4 +1,5 @@ #include +#include "inventory.h" #include "pool.h" Pool::Pool() { diff --git a/src/modules/pool.h b/src/modules/pool.h index c539c90c71..247208a2fa 100644 --- a/src/modules/pool.h +++ b/src/modules/pool.h @@ -4,9 +4,9 @@ #include #include #include +#include #include "configuration.h" #include "moduleWrapper.h" -#include "inventory.h" using namespace std;