Skip to content

Commit

Permalink
fix: fixed inventory vckpg configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
nbertoldo committed Aug 15, 2024
1 parent ee74872 commit 5b84f7e
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 72 deletions.
9 changes: 0 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions src/common/data_provider/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
5 changes: 3 additions & 2 deletions src/common/dbsync/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand All @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/common/debug_op/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/common/expression/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
find_package(pcre2 CONFIG REQUIRED)

add_library(expression STATIC src/expression.c)

target_include_directories(expression PUBLIC include)
Expand Down
2 changes: 2 additions & 0 deletions src/common/file_op/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
find_package(ZLIB REQUIRED)

add_library(file_op STATIC src/file_op.c)

target_include_directories(file_op PUBLIC include)
Expand Down
62 changes: 3 additions & 59 deletions src/common/http-request/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions src/modules/inventory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/modules/inventory/include/inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <memory>
#include <string>
#include <memory>
#include <cjson/cJSON.h>
#include "sysInfoInterface.h"
#include "configuration.h"
#include "logging_helper.h"
Expand Down
1 change: 1 addition & 0 deletions src/modules/inventory/src/inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

#include <iostream>
#include <cjson/cJSON.h>
#include "shared.h"
#include "defs.h"
#include "logging_helper.h"
Expand Down
1 change: 1 addition & 0 deletions src/modules/pool.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <iostream>
#include "inventory.h"
#include "pool.h"

Pool::Pool() {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <map>
#include <memory>
#include <string>
#include <thread>
#include "configuration.h"
#include "moduleWrapper.h"
#include "inventory.h"

using namespace std;

Expand Down

0 comments on commit 5b84f7e

Please sign in to comment.