From 3ac4f170d4402af380b18e11e1f7b3de8e3a724f Mon Sep 17 00:00:00 2001 From: snider Date: Wed, 15 Oct 2025 20:59:18 +0100 Subject: [PATCH] Refactor CMake configuration to link lthn_api library with daemon and update include directories --- src/CMakeLists.txt | 2 +- src/api/CMakeLists.txt | 31 ++++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2132a36a..cb29a456 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -164,7 +164,7 @@ target_link_libraries(currency_core config lmdb mdbx) add_executable(daemon ${DAEMON} ${P2P} ${CURRENCY_PROTOCOL}) add_dependencies(daemon version) -target_link_libraries(daemon rpc stratum currency_core crypto common miniupnpc::miniupnpc ZLIB::ZLIB ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto) +target_link_libraries(daemon rpc stratum currency_core crypto common miniupnpc::miniupnpc ZLIB::ZLIB ethash lthn::api ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto) ENABLE_SHARED_PCH(daemon DAEMON) ENABLE_SHARED_PCH_EXECUTABLE(daemon) diff --git a/src/api/CMakeLists.txt b/src/api/CMakeLists.txt index f66301c3..63750b62 100644 --- a/src/api/CMakeLists.txt +++ b/src/api/CMakeLists.txt @@ -16,42 +16,43 @@ else() message(FATAL_ERROR "Could not find oatpp-swagger") endif() -add_library(lthn_api INTERFACE) +add_library(lthn_api ApiServer.cpp) add_library(lthn::api ALIAS lthn_api) -# Add the current directory for API headers and the main src directory for core headers -target_include_directories(lthn_api INTERFACE +target_include_directories(lthn_api PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src + ${oatpp_INCLUDE_DIRS} + ${oatpp-swagger_INCLUDE_DIRS} ) -include_directories(${oatpp_INCLUDE_DIRS}) -include_directories(${oatpp-swagger_INCLUDE_DIRS}) +target_link_libraries(lthn_api PUBLIC + oatpp::oatpp + oatpp::oatpp-swagger +) -# Add P2P and currency_protocol sources directly to the executable, like the main daemon does -add_executable(lethean-api main.cpp ApiServer.cpp ${P2P} ${CURRENCY_PROTOCOL}) +target_compile_definitions(lthn_api PUBLIC -DOATPP_SWAGGER_RES_PATH="${oatpp-swagger_INCLUDE_DIRS}/../bin/oatpp-swagger/res") -# Explicitly add the project's main src directory to the executable's include paths -target_include_directories(lethean-api PRIVATE ${CMAKE_SOURCE_DIR}/src) -# Link against the correct, existing library targets -target_link_libraries(lethean-api +#add_executable(lethean-api main.cpp) +# +#target_include_directories(lethean-api PRIVATE ${CMAKE_SOURCE_DIR}/src) + +target_link_libraries(lthn_api PRIVATE + config lthn::api rpc stratum currency_core crypto common - config ethash - oatpp::oatpp - oatpp::oatpp-swagger ${Boost_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB ) -add_definitions(-DOATPP_SWAGGER_RES_PATH="${oatpp-swagger_INCLUDE_DIRS}/../bin/oatpp-swagger/res") #add_subdirectory(tests)