- More cmake cleanup

This commit is contained in:
Ian Roddis
2021-08-13 13:21:55 -03:00
parent dfb71b63b8
commit d731f8b6dc
6 changed files with 33 additions and 42 deletions

View File

@@ -1,23 +1,25 @@
project(pistache)
include(ExternalProject)
ExternalProject_Add(PistacheDownload
PREFIX third_party
GIT_REPOSITORY https://github.com/pistacheio/pistache.git
GIT_TAG master
INSTALL_COMMAND ""
)
set_directory_properties(PROPERTIES EP_UPDATE_DISCONNECTED true)
set(PISTACHE_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/third_party/src/PistacheDownload/include)
set(PISTACHE_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/third_party/src/PistacheDownload-build/src)
set(pistache_root ${THIRD_PARTY_DIR}/${PROJECT_NAME})
ExternalProject_Add(PistacheDownload
PREFIX ${pistache_root}
GIT_REPOSITORY https://github.com/pistacheio/pistache.git
GIT_TAG master
INSTALL_COMMAND ""
)
ExternalProject_Get_Property(PistacheDownload SOURCE_DIR)
set(PISTACHE_INCLUDE_DIR ${SOURCE_DIR}/include)
set(PISTACHE_LIB_DIR ${pistache_root}/src/PistacheDownload-build/src)
file(MAKE_DIRECTORY ${PISTACHE_INCLUDE_DIR})
add_library(${PROJECT_NAME} SHARED IMPORTED)
add_dependencies(${PROJECT_NAME} $PistacheDownload)
set_target_properties(${PROJECT_NAME} PROPERTIES IMPORTED_LOCATION "${PISTACHE_LIB_DIR}/libpistache.a")
#add_library(${PROJECT_NAME} STATIC IMPORTED)
#set_target_properties(${PROJECT_NAME} PROPERTIES IMPORTED_LOCATION "${PISTACHE_BINARY_DIR}/lib/libpistache.a")
#file(MAKE_DIRECTORY "${PISTACHE_BINARY_DIR}/include")
#target_include_directories(${PROJECT_NAME} SYSTEM INTERFACE "${PISTACHE_BINARY_DIR}/include/")
add_dependencies(${PROJECT_NAME} PistacheDownload)
target_include_directories(${PROJECT_NAME} INTERFACE ${PISTACHE_INCLUDE_DIR})
set_target_properties(${PROJECT_NAME} PROPERTIES IMPORTED_LOCATION "${PISTACHE_LIB_DIR}/libpistache.a")

View File

@@ -2,6 +2,5 @@ project(daggy)
file(GLOB_RECURSE SOURCES src/*.cpp)
add_library(${PROJECT_NAME} STATIC ${SOURCES})
include_directories(${PISTACHE_INCLUDE_DIR})
target_include_directories(${PROJECT_NAME} PUBLIC include)
target_link_libraries(${PROJECT_NAME} pistache pthread rapidjson magicEnum)

View File

@@ -4,7 +4,7 @@
#include <pistache/endpoint.h>
#include <pistache/http.h>
// #include <pistache/thirdparty/serializer/rapidjson.h>
#include <rapidjson/document.h>
namespace daggy {
class Server {
@@ -19,18 +19,6 @@ namespace daggy {
private:
void createDescription();
//
// DAG Definition handlers
//
void listDAGs(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void upsertDAG(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void deleteDAG(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void getDAG(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
//
// DAG Runs
//
@@ -43,9 +31,10 @@ namespace daggy {
// Get status of specific run
void getDAGRun(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
void handleReady(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
Pistache::Http::Endpoint endpoint_;
Pistache::Rest::Description desc_;
Pistache::Rest::Router router_;
};
}

View File

@@ -32,13 +32,11 @@ namespace daggy {
.produces(MIME(Application, Json))
.consumes(MIME(Application, Json));
/*
desc_
.route(desc_.get("/ready"))
.bind(&Generic::handleReady)
.response(Http::Code::Ok, "Response to the /ready call")
.hide();
*/
.route(desc_.get("/ready"))
.bind(&Server::handleReady, this)
.response(Http::Code::Ok, "Response to the /ready call")
.hide();
auto versionPath = desc_.path("/v1");
@@ -53,4 +51,8 @@ namespace daggy {
*/
}
void Server::handleReady(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
response.send(Pistache::Http::Code::Ok, "All good here");
}
}

View File

@@ -1,5 +1,4 @@
project(rest_server)
file(GLOB SOURCES *.cpp)
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} daggy stdc++fs rapidjson pistache argparse)
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "daggy")
target_link_libraries(${PROJECT_NAME} pistache stdc++fs rapidjson argparse daggy)

View File

@@ -1,7 +1,7 @@
#include <iostream>
#include <fstream>
#include <argoarse/argparse.hpp>
#include <argparse.hpp>
#include <daggy/Server.hpp>
#include <daggy/executors/task/ForkingTaskExecutor.hpp>
@@ -19,5 +19,5 @@ int main(int argc, char **argv) {
.help("Port to listen to")
.action([](const std::string &value) { return std::stoi(value); });
daggy::Server endpoint;
// daggy::Server endpoint(10);
}