Skip to content

Commit

Permalink
fixes: to CMake files
Browse files Browse the repository at this point in the history
Settled for pascal case on library names
Removed unused TEST_SOURCES definitions
Unified minimum CMake required version to 3.22
Removed HEADERS definitions from Agent target
  • Loading branch information
jr0me committed Aug 8, 2024
1 parent 83243bd commit 05bf17d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ project(wazuh-agent)
add_subdirectory(agent)

add_executable(wazuh-agent agent/src/main.cpp)
target_link_libraries(wazuh-agent agent)
target_link_libraries(wazuh-agent Agent)

if(BUILD_TESTS)
enable_testing()
Expand Down
6 changes: 3 additions & 3 deletions src/agent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ add_subdirectory(configuration_parser)
find_package(OpenSSL REQUIRED)
find_package(Boost REQUIRED COMPONENTS asio beast)

add_library(agent ${SOURCES})
target_include_directories(agent PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(agent PUBLIC ConfigurationParser communicator AgentInfo PRIVATE OpenSSL::SSL OpenSSL::Crypto Boost::asio Boost::beast)
add_library(Agent ${SOURCES})
target_include_directories(Agent PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(Agent PUBLIC ConfigurationParser Communicator AgentInfo PRIVATE OpenSSL::SSL OpenSSL::Crypto Boost::asio Boost::beast)

if(BUILD_TESTS)
enable_testing()
Expand Down
5 changes: 0 additions & 5 deletions src/agent/agent_info/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
find_package(GTest CONFIG REQUIRED)

set(TEST_SOURCES
agent_info_test.cpp
agent_info_persistance_test.cpp
)

add_executable(agent_info_test agent_info_test.cpp)
target_include_directories(agent_info_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include)
target_link_libraries(agent_info_test PRIVATE AgentInfo GTest::gtest)
Expand Down
6 changes: 3 additions & 3 deletions src/agent/communicator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ find_package(Boost REQUIRED COMPONENTS asio beast)
find_package(nlohmann_json CONFIG REQUIRED)
find_path(JWT_CPP_INCLUDE_DIRS "jwt-cpp/base.h")

add_library(communicator src/communicator.cpp src/http_client.cpp)
target_include_directories(communicator PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${JWT_CPP_INCLUDE_DIRS})
target_link_libraries(communicator PUBLIC Boost::asio PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto)
add_library(Communicator src/communicator.cpp src/http_client.cpp)
target_include_directories(Communicator PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${JWT_CPP_INCLUDE_DIRS})
target_link_libraries(Communicator PUBLIC Boost::asio PRIVATE Boost::beast OpenSSL::SSL OpenSSL::Crypto)

if(BUILD_TESTS)
enable_testing()
Expand Down
4 changes: 2 additions & 2 deletions src/agent/communicator/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
find_package(GTest CONFIG REQUIRED)

add_executable(communicator_test communicator_test.cpp)
target_link_libraries(communicator_test PUBLIC communicator GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)
target_link_libraries(communicator_test PUBLIC Communicator GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)
add_test(NAME CommunicatorTest COMMAND communicator_test)

add_executable(http_client_test http_client_test.cpp)
target_link_libraries(http_client_test PUBLIC communicator GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)
target_link_libraries(http_client_test PUBLIC Communicator GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)
add_test(NAME HttpClientTest COMMAND http_client_test)
15 changes: 4 additions & 11 deletions src/agent/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
find_package(GTest CONFIG REQUIRED)

set(TEST_SOURCES
agent_test.cpp
task_manager_test.cpp
register_test.cpp
signal_handler_test.cpp
)

add_executable(agent_test agent_test.cpp)
target_link_libraries(agent_test PRIVATE agent GTest::gtest)
target_link_libraries(agent_test PRIVATE Agent GTest::gtest)
add_test(NAME AgentTest COMMAND agent_test)

add_executable(task_manager_test task_manager_test.cpp)
target_link_libraries(task_manager_test PRIVATE agent GTest::gtest)
target_link_libraries(task_manager_test PRIVATE Agent GTest::gtest)
add_test(NAME TaskManagerTest COMMAND task_manager_test)

add_executable(register_test register_test.cpp)
target_link_libraries(register_test PRIVATE agent GTest::gtest)
target_link_libraries(register_test PRIVATE Agent GTest::gtest)
add_test(NAME RegisterTest COMMAND register_test)

add_executable(signal_handler_test signal_handler_test.cpp)
target_link_libraries(signal_handler_test PRIVATE agent GTest::gtest)
target_link_libraries(signal_handler_test PRIVATE Agent GTest::gtest)
add_test(NAME SignalHandlerTest COMMAND signal_handler_test)

0 comments on commit 05bf17d

Please sign in to comment.