Commit b32ea7e2 authored by Shervin Nourbakhsh's avatar Shervin Nourbakhsh
Browse files

(split) Fixed Rapidjson download from GIT if not installed in the system

parent 330d7e63
...@@ -3,6 +3,7 @@ if(NOT DEFINED PROJECT_NAME) ...@@ -3,6 +3,7 @@ if(NOT DEFINED PROJECT_NAME)
# Project name and version # Project name and version
project(cameo VERSION 1.0.1 LANGUAGES CXX) project(cameo VERSION 1.0.1 LANGUAGES CXX)
#cmake_policy(SET CMP0048 NEW)
endif() endif()
message("========================================") message("========================================")
...@@ -10,9 +11,11 @@ message("Project ${PROJECT_NAME}, major version: ${PROJECT_VERSION_MAJOR}, versi ...@@ -10,9 +11,11 @@ message("Project ${PROJECT_NAME}, major version: ${PROJECT_VERSION_MAJOR}, versi
include(GNUInstallDirs) include(GNUInstallDirs)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
include(FetchContent)
if(NOT DEFINED BUILD_SHARED_LIBS) if(NOT DEFINED BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS True) option(BUILD_SHARED_LIBS "Building dynamic (ON) or static (OFF)" ON)
#set(BUILD_SHARED_LIBS True)
endif() endif()
if(NOT DEFINED CMAKE_CXX_STANDARD) if(NOT DEFINED CMAKE_CXX_STANDARD)
...@@ -32,9 +35,22 @@ endif() ...@@ -32,9 +35,22 @@ endif()
#------------------------------------------------------------ #------------------------------------------------------------
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package(ZeroMQ REQUIRED) find_package(ZeroMQ REQUIRED)
find_package(Rapidjson REQUIRED) find_package(Rapidjson QUIET)
if(NOT Rapidjson_FOUND)
message(WARNING "Using Rapidjson from GIT repository")
FetchContent_Declare(rapidjson
GIT_REPOSITORY https://github.com/Tencent/rapidjson.git
GIT_TAG v1.1.0
GIT_SHALLOW True
#INSTALL_COMMAND "make install"
)
FetchContent_GetProperties(rapidjson)
FetchContent_Populate(rapidjson)
set(Rapidjson_ROOT ${rapidjson_SOURCE_DIR})
find_package(Rapidjson REQUIRED)
endif()
message(${Rapidjson_INCLUDE_DIRS})
#------------------------------------------------------------ #------------------------------------------------------------
# Libraries # Libraries
#------------------------------------------------------------ #------------------------------------------------------------
...@@ -42,9 +58,6 @@ find_package(Rapidjson REQUIRED) ...@@ -42,9 +58,6 @@ find_package(Rapidjson REQUIRED)
#--------------- #---------------
# Files # Files
file(GLOB_RECURSE CAMEO_SOURCE_FILES "src/*.cpp") file(GLOB_RECURSE CAMEO_SOURCE_FILES "src/*.cpp")
#file(GLOB CAMEO_PUBLIC_HEADER_FILES "./*.h")
#message(${CAMEO_PUBLIC_HEADER_FILES})
#message(${CAMEO_SOURCE_FILES})
add_library(cameo ${CAMEO_SOURCE_FILES}) add_library(cameo ${CAMEO_SOURCE_FILES})
target_link_libraries(cameo PRIVATE zmq) target_link_libraries(cameo PRIVATE zmq)
...@@ -53,6 +66,9 @@ target_include_directories(cameo ...@@ -53,6 +66,9 @@ target_include_directories(cameo
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
) )
target_include_directories(cameo
SYSTEM PRIVATE ${Rapidjson_INCLUDE_DIRS}/
)
#target_include_directories(cameo PRIVATE ${DOCTEST_INCLUDE_DIR}) #target_include_directories(cameo PRIVATE ${DOCTEST_INCLUDE_DIR})
#target_compile_features(cameo PUBLIC cxx_std_11) #target_compile_features(cameo PUBLIC cxx_std_11)
...@@ -156,7 +172,7 @@ if (DOXYGEN_FOUND) ...@@ -156,7 +172,7 @@ if (DOXYGEN_FOUND)
message("Doxygen build started") message("Doxygen build started")
# note the option ALL which allows to build the docs together with the application # note the option ALL which allows to build the docs together with the application
add_custom_target( doc add_custom_target( cameo_doc
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" COMMENT "Generating API documentation with Doxygen"
......
...@@ -83,7 +83,7 @@ const State SUCCESS = 64; ...@@ -83,7 +83,7 @@ const State SUCCESS = 64;
const State STOPPED = 128; const State STOPPED = 128;
const State KILLED = 256; const State KILLED = 256;
/** \class This /** \class This
* \brief class managing the current CAMEO application. * \brief class managing the current CAMEO application.
* *
* \details The application has to be launched by CAMEO command line or another CAMEO app * \details The application has to be launched by CAMEO command line or another CAMEO app
...@@ -103,7 +103,7 @@ class This : private Services, private EventListener { ...@@ -103,7 +103,7 @@ class This : private Services, private EventListener {
friend class cameo::Server; friend class cameo::Server;
friend std::ostream& operator<<(std::ostream&, const cameo::application::This&); friend std::ostream& operator<<(std::ostream&, const cameo::application::This&);
typedef std::function<void ()> StopFunctionType; typedef std::function<void()> StopFunctionType;
public: public:
/** /**
...@@ -123,24 +123,26 @@ public: ...@@ -123,24 +123,26 @@ public:
void releasePort(int port) const; void releasePort(int port) const;
private: private:
Com(Server * server, int applicationId); Com(Server* server, int applicationId);
Server * m_server; Server* m_server;
int m_applicationId; int m_applicationId;
}; };
This(); This();
~This(); ~This();
static void init(int argc, char *argv[]); static void init(int argc, char* argv[]);
static void init(const std::string& name, const std::string& endpoint); static void init(const std::string& name, const std::string& endpoint);
/** /**
* The terminate call is not necessary unless the static instance of This is not destroyed automatically. * The terminate call is not necessary unless the static instance of This is not destroyed
* automatically.
*/ */
static void terminate(); static void terminate();
static const std::string& getName(); ///< returns the name of the CAMEO application corresponding to this instance /// \brief returns the name of the CAMEO application corresponding to this instance
static const std::string& getName();
static int getId(); ///< returns the ID number of the instance static int getId(); ///< returns the ID number of the instance
static void setTimeout(int timeout); static void setTimeout(int timeout);
static int getTimeout(); static int getTimeout();
...@@ -156,9 +158,10 @@ public: ...@@ -156,9 +158,10 @@ public:
static bool isStopping(); static bool isStopping();
/** /**
* Sets the stop handler with stopping time that overrides the one that may be defined in the configuration of the server. * Sets the stop handler with stopping time that overrides the one that may be defined in the
* configuration of the server.
*/ */
template<typename Type> template <typename Type>
static void handleStop(Type function, int stoppingTime = -1) { static void handleStop(Type function, int stoppingTime = -1) {
m_instance.handleStopImpl(function, stoppingTime); m_instance.handleStopImpl(function, stoppingTime);
} }
...@@ -179,7 +182,7 @@ public: ...@@ -179,7 +182,7 @@ public:
static std::unique_ptr<Instance> connectToStarter(); static std::unique_ptr<Instance> connectToStarter();
private: private:
void initApplication(int argc, char *argv[]); void initApplication(int argc, char* argv[]);
void initApplication(const std::string& name, const std::string& endpoint); void initApplication(const std::string& name, const std::string& endpoint);
static State parseState(const std::string& value); static State parseState(const std::string& value);
...@@ -222,7 +225,7 @@ class Instance : private EventListener { ...@@ -222,7 +225,7 @@ class Instance : private EventListener {
friend std::ostream& operator<<(std::ostream&, const Instance&); friend std::ostream& operator<<(std::ostream&, const Instance&);
public: public:
typedef std::function<void (State)> StateHandlerType; typedef std::function<void(State)> StateHandlerType;
class Com { class Com {
...@@ -232,9 +235,9 @@ public: ...@@ -232,9 +235,9 @@ public:
std::string getKeyValue(const std::string& key) const; std::string getKeyValue(const std::string& key) const;
private: private:
Com(Server * server); Com(Server* server);
Server * m_server; Server* m_server;
int m_applicationId; int m_applicationId;
}; };
...@@ -291,7 +294,7 @@ public: ...@@ -291,7 +294,7 @@ public:
std::shared_ptr<OutputStreamSocket> getOutputStreamSocket(); std::shared_ptr<OutputStreamSocket> getOutputStreamSocket();
private: private:
Instance(Server * server); Instance(Server* server);
void setId(int id); void setId(int id);
void setErrorMessage(const std::string& message); void setErrorMessage(const std::string& message);
...@@ -300,7 +303,7 @@ private: ...@@ -300,7 +303,7 @@ private:
void setInitialState(State state); void setInitialState(State state);
State waitFor(int states, const std::string& eventName, KeyValue& keyValue, StateHandlerType handler, bool blocking); State waitFor(int states, const std::string& eventName, KeyValue& keyValue, StateHandlerType handler, bool blocking);
Server * m_server; Server* m_server;
std::shared_ptr<OutputStreamSocket> m_outputStreamSocket; std::shared_ptr<OutputStreamSocket> m_outputStreamSocket;
int m_id; int m_id;
std::string m_errorMessage; std::string m_errorMessage;
...@@ -379,7 +382,8 @@ public: ...@@ -379,7 +382,8 @@ public:
bool isEnded() const; bool isEnded() const;
private: private:
Publisher(application::This * application, int publisherPort, int synchronizerPort, const std::string& name, int numberOfSubscribers); Publisher(application::This* application, int publisherPort, int synchronizerPort,
const std::string& name, int numberOfSubscribers);
std::unique_ptr<PublisherImpl> m_impl; std::unique_ptr<PublisherImpl> m_impl;
std::unique_ptr<WaitingImpl> m_waiting; std::unique_ptr<WaitingImpl> m_waiting;
...@@ -397,7 +401,7 @@ class Subscriber { ...@@ -397,7 +401,7 @@ class Subscriber {
public: public:
~Subscriber(); ~Subscriber();
static std::unique_ptr<Subscriber> create(Instance & instance, const std::string& publisherName); static std::unique_ptr<Subscriber> create(Instance& instance, const std::string& publisherName);
const std::string& getPublisherName() const; const std::string& getPublisherName() const;
const std::string& getInstanceName() const; const std::string& getInstanceName() const;
...@@ -423,7 +427,9 @@ public: ...@@ -423,7 +427,9 @@ public:
void cancel(); void cancel();
private: private:
Subscriber(Server * server, int publisherPort, int synchronizerPort, const std::string& publisherName, int numberOfSubscribers, const std::string& instanceName, int instanceId, const std::string& instanceEndpoint, const std::string& statusEndpoint); Subscriber(Server* server, int publisherPort, int synchronizerPort, const std::string& publisherName,
int numberOfSubscribers, const std::string& instanceName, int instanceId,
const std::string& instanceEndpoint, const std::string& statusEndpoint);
void init(); void init();
std::unique_ptr<SubscriberImpl> m_impl; std::unique_ptr<SubscriberImpl> m_impl;
...@@ -461,7 +467,7 @@ public: ...@@ -461,7 +467,7 @@ public:
std::unique_ptr<Server> getServer(); std::unique_ptr<Server> getServer();
private: private:
Request(std::unique_ptr<RequestImpl> & impl); Request(std::unique_ptr<RequestImpl>& impl);
std::unique_ptr<RequestImpl> m_impl; std::unique_ptr<RequestImpl> m_impl;
std::unique_ptr<Server> m_requesterServer; std::unique_ptr<Server> m_requesterServer;
...@@ -496,7 +502,7 @@ public: ...@@ -496,7 +502,7 @@ public:
bool isCanceled() const; bool isCanceled() const;
private: private:
Responder(application::This * application, int responderPort, const std::string& name); Responder(application::This* application, int responderPort, const std::string& name);
std::unique_ptr<ResponderImpl> m_impl; std::unique_ptr<ResponderImpl> m_impl;
std::unique_ptr<WaitingImpl> m_waiting; std::unique_ptr<WaitingImpl> m_waiting;
...@@ -507,7 +513,7 @@ private: ...@@ -507,7 +513,7 @@ private:
class Requester { class Requester {
friend std::ostream& operator<<(std::ostream&, const Requester&); friend std::ostream& operator<<(std::ostream&, const Requester&);
public: public:
~Requester(); ~Requester();
...@@ -516,7 +522,7 @@ public: ...@@ -516,7 +522,7 @@ public:
* Returns the responder with name. * Returns the responder with name.
* throws RequesterCreationException. * throws RequesterCreationException.
*/ */
static std::unique_ptr<Requester> create(Instance & instance, const std::string& name); static std::unique_ptr<Requester> create(Instance& instance, const std::string& name);
const std::string& getName() const; const std::string& getName() const;
...@@ -532,7 +538,8 @@ public: ...@@ -532,7 +538,8 @@ public:
bool isCanceled() const; bool isCanceled() const;
private: private:
Requester(application::This * application, const std::string& url, int requesterPort, int responderPort, const std::string& name, int responderId, int requesterId); Requester(application::This* application, const std::string& url, int requesterPort,
int responderPort, const std::string& name, int responderId, int requesterId);
std::unique_ptr<RequesterImpl> m_impl; std::unique_ptr<RequesterImpl> m_impl;
std::unique_ptr<WaitingImpl> m_waiting; std::unique_ptr<WaitingImpl> m_waiting;
...@@ -546,7 +553,8 @@ class Configuration { ...@@ -546,7 +553,8 @@ class Configuration {
friend std::ostream& operator<<(std::ostream&, const Configuration&); friend std::ostream& operator<<(std::ostream&, const Configuration&);
public: public:
Configuration(const std::string& name, const std::string& description, bool singleInfo, bool restart, int startingTime, int stoppingTime); Configuration(const std::string& name, const std::string& description, bool singleInfo, bool restart,
int startingTime, int stoppingTime);
const std::string& getName() const; const std::string& getName() const;
const std::string& getDescription() const; const std::string& getDescription() const;
...@@ -572,7 +580,8 @@ class Info { ...@@ -572,7 +580,8 @@ class Info {
friend std::ostream& operator<<(std::ostream&, const Info&); friend std::ostream& operator<<(std::ostream&, const Info&);
public: public:
Info(const std::string& name, int id, int pid, State applicationState, State pastApplicationStates, const std::string& args); Info(const std::string& name, int id, int pid, State applicationState, State pastApplicationStates,
const std::string& args);
int getId() const; int getId() const;
State getState() const; State getState() const;
...@@ -623,9 +632,7 @@ std::ostream& operator<<(std::ostream&, const cameo::application::Configuration& ...@@ -623,9 +632,7 @@ std::ostream& operator<<(std::ostream&, const cameo::application::Configuration&
std::ostream& operator<<(std::ostream&, const cameo::application::Info&); std::ostream& operator<<(std::ostream&, const cameo::application::Info&);
std::ostream& operator<<(std::ostream&, const cameo::application::Port&); std::ostream& operator<<(std::ostream&, const cameo::application::Port&);
} } // namespace application
} } // namespace cameo
#endif #endif
...@@ -19,6 +19,10 @@ target_link_libraries(testapplicationidentity ...@@ -19,6 +19,10 @@ target_link_libraries(testapplicationidentity
target_include_directories(testapplicationidentity target_include_directories(testapplicationidentity
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src/ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src/
) )
target_include_directories(testapplicationidentity
SYSTEM PRIVATE ${Rapidjson_INCLUDE_DIRS}/
)
add_test(applicationidentity testapplicationidentity) add_test(applicationidentity testapplicationidentity)
...@@ -30,5 +34,8 @@ target_link_libraries(testapplicationwithstarteridentity PRIVATE ...@@ -30,5 +34,8 @@ target_link_libraries(testapplicationwithstarteridentity PRIVATE
target_include_directories(testapplicationwithstarteridentity target_include_directories(testapplicationwithstarteridentity
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src/ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src/
) )
target_include_directories(testapplicationwithstarteridentity
SYSTEM PRIVATE ${Rapidjson_INCLUDE_DIRS}/
)
add_test(applicationwithstarteridentity testapplicationwithstarteridentity) add_test(applicationwithstarteridentity testapplicationwithstarteridentity)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment