nodepp cmake interface-target
I'm currently experimenting with nodepp as this is an uncommon, but very well done solution for problems I've been faced with working on my last projects.
For the ease of using an external project I like the cmake tools from FetchContent.
So perhaps something like this will improve the needed steps for using nodepp even more for everyone willing to try it as well. 😃 Nodepp is already implemented as a CMake based project, so exporting an interface target would be both great and easy to implement in nodepp itself and all related repositories.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f40e350..1d96612 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,4 +18,9 @@ endif()
find_package(ZLIB REQUIRED)
if(NOT ZLIB_FOUND)
message(FATAL_ERROR "ZLIB not found. Please install ZLIB development files.")
-endif()
\ No newline at end of file
+endif()
+
+add_library(nodepp INTERFACE)
+
+target_include_directories(nodepp INTERFACE ${NODEPP_INCLUDE_DIR})
+target_link_libraries(nodepp INTERFACE -lssl -lcrypto)
example cmake project
# [...]
include(FetchContent)
FetchContent_Declare(
nodepp
GIT_REPOSITORY https://github.com/NodeppOfficial/nodepp
GIT_TAG origin/main
GIT_PROGRESS ON
)
FetchContent_MakeAvailable(nodepp)
FetchContent_Declare(
nodepp-apify
GIT_REPOSITORY https://github.com/NodeppOfficial/nodepp-apify
GIT_TAG origin/main
GIT_PROGRESS ON
)
FetchContent_MakeAvailable(nodepp-apify)
add_executable(example
main.cpp
)
target_link_libraries(example
PUBLIC nodepp nodepp-apify
)
example main.cpp
#include <nodepp/nodepp.h>
#include <apify/apify.h>
using namespace nodepp;
void onMain() {
// [...]
}
I haven't found time to learn CMake, but it looks fun, I've modified the CMakeLists.txt in Nodepp and related libraries ( Most of them ), and now they must support dependency fetching.
include(FetchContent)
FetchContent_Declare(
nodepp
GIT_REPOSITORY https://github.com/NodeppOfficial/nodepp
GIT_TAG origin/main
GIT_PROGRESS ON
)
FetchContent_MakeAvailable(nodepp)
#[...]
target_link_libraries( #[...]
PUBLIC nodepp #[...]
)
I hope you enjoy the framework. Thanks 👍