diff --git a/apps/ccam/CMakeLists.txt b/apps/ccam/CMakeLists.txt index 25880eb..26da617 100644 --- a/apps/ccam/CMakeLists.txt +++ b/apps/ccam/CMakeLists.txt @@ -1,16 +1,7 @@ set(SOURCES configuration.h) set(SOURCES statehandlerutils.h) -# Allow warnings for paho.mqtt.cpp -if ( ROSA_COMPILER_IS_GCC_COMPATIBLE ) - remove("-Werror" CMAKE_CXX_FLAGS) -elseif ( MSVC ) - remove("/WX" CMAKE_CXX_FLAGS) -endif() - ROSA_add_app(ccam ccam.cpp) ROSA_add_library_dependencies(ccam ROSAConfig) ROSA_add_library_dependencies(ccam ROSAApp) ROSA_add_library_dependencies(ccam ROSAAgent) -ROSA_add_library_dependencies(ccam paho-mqttpp3) -ROSA_add_library_dependencies(ccam paho-mqttc3::MQTTAsync) diff --git a/examples/mqtt-client/CMakeLists.txt b/examples/mqtt-client/CMakeLists.txt index c7d9920..68d6658 100644 --- a/examples/mqtt-client/CMakeLists.txt +++ b/examples/mqtt-client/CMakeLists.txt @@ -1,17 +1,8 @@ # Allow exceptions for cxxopts and paho.mqtt.cpp by removing restricting flag. if ( ROSA_COMPILER_IS_GCC_COMPATIBLE ) remove("-fno-exceptions" CMAKE_CXX_FLAGS) endif() -# Allow warnings for paho.mqtt.cpp -if ( ROSA_COMPILER_IS_GCC_COMPATIBLE ) - remove("-Werror" CMAKE_CXX_FLAGS) -elseif ( MSVC ) - remove("/WX" CMAKE_CXX_FLAGS) -endif() - add_executable(mqtt-client mqtt-client.cpp) ROSA_add_library_dependencies(mqtt-client ROSAConfig) ROSA_add_library_dependencies(mqtt-client ROSASupport) -ROSA_add_library_dependencies(mqtt-client paho-mqttpp3) -ROSA_add_library_dependencies(mqtt-client paho-mqttc3::MQTTAsync) diff --git a/examples/mqtt-client/mqtt-client.cpp b/examples/mqtt-client/mqtt-client.cpp index d8222c7..4380739 100644 --- a/examples/mqtt-client/mqtt-client.cpp +++ b/examples/mqtt-client/mqtt-client.cpp @@ -1,154 +1,160 @@ //===-- examples/mqtt-client/mqtt-client.cpp --------------------*- C++ -*-===// // // The RoSA Framework // // Distributed under the terms and conditions of the Boost Software License 1.0. // See accompanying file LICENSE. // // If you did not receive a copy of the license file, see // http://www.boost.org/LICENSE_1_0.txt. // //===----------------------------------------------------------------------===// /// /// \file examples/mqtt-client/mqtt-client.cpp /// /// \author David Juhasz (david.juhasz@tuwien.ac.at) /// /// \date 2020 /// /// \brief An example showcasing the basic usage of paho-mqttpp3. /// //===----------------------------------------------------------------------===// #include "rosa/config/version.h" +#include "rosa/support/diagnostics.h" #include "rosa/support/log.h" #include "rosa/support/terminal_colors.h" #include "cxxopts/cxxopts.hpp" +// NOTE: MSVC warns about some things in the following header. +ROSA_DISABLE_WARNING_PUSH +ROSA_DISABLE_WARNING_MSVC_C4100 +ROSA_DISABLE_WARNING_MSVC_C4201 #include "mqtt/async_client.h" +ROSA_DISABLE_WARNING_POP #include #include #include using namespace rosa; using namespace rosa::terminal; /** * Local callback & listener class for use with the client connection. * This implementation is to receive messages but the mqtt::callback interface * allows further actions to be defined. */ class MQTTCallback : public virtual mqtt::callback { /** Callback for when a message arrives. * @param Msg Pointer for the MQTT message **/ void message_arrived(mqtt::const_message_ptr Msg) override { std::string Topic = Msg->get_topic(); std::string Message = Msg->to_string(); LOG_INFO_STREAM << "[Message @ " << Topic << "] " << Message << std::endl; } public: /** Constructor **/ MQTTCallback(void) noexcept = default; }; /// Helper function to print an error message in red color to the terminal and /// exit from the application. /// /// \note The function never returns as it calles `exit()`. /// /// \param Error error message /// \param ExitCode exit code to return from the application void logErrorAndExit(const std::string &Error, const int ExitCode) { LOG_ERROR_STREAM << Color::Red << Error << Color::Default << std::endl; exit(ExitCode); } int main(int argc, char *argv[]) { // std::cout << "Das da?" << std::endl; /// Host name of the MQTT server std::string ServerHost = "localhost"; /// Port number of the MQTT server uint16_t ServerPort = 1883; /// MQTT topic std::string Topic = "test"; /// Message to publish. Subscribe and log messages otherwise. std::string Message = ""; /// How long to receive messages. const size_t TimeoutSecs = 60; // Handle command-line arguments. try { cxxopts::Options Options(argv[0], library_string() + " -- PahoMQTT CPP Client Example"); Options.add_options()( "host", "Server host", cxxopts::value(ServerHost)->default_value("localhost"))( "port", "Server port", cxxopts::value(ServerPort)->default_value("1883"))( "t,topic", "MQTT topic", cxxopts::value(Topic)->default_value("test"))( "m,message", "Message to publish (subscribe and log messages otherwise)", cxxopts::value(Message))("h,help", "Print usage"); auto Args = Options.parse(argc, argv); if (Args.count("help")) { LOG_INFO_STREAM << '\n' << Options.help() << std::endl; exit(0); } } catch (const cxxopts::OptionException &e) { logErrorAndExit(e.what(), 1); } catch (const std::invalid_argument &e) { logErrorAndExit(e.what(), 1); } try { std::stringstream ss; ss << "tcp://" << ServerHost << ":" << ServerPort; const std::string ServerURI = ss.str(); LOG_INFO_STREAM << "Initializing for " << ServerURI << std::endl; mqtt::async_client Client(ServerURI, ""); LOG_INFO_STREAM << "Connecting to server" << std::endl; Client.connect()->wait(); if (!Message.empty()) { LOG_INFO_STREAM << "Publishing message '" << Message << "' to topic '" << Topic << "'" << std::endl; mqtt::topic T(Client, Topic); T.publish(Message.c_str())->wait(); } else { LOG_INFO_STREAM << "Receiving messages from topic '" << Topic << "' for a short while..." << std::endl; MQTTCallback Callback; Client.set_callback(Callback); Client.subscribe(Topic, {}); std::this_thread::sleep_for(std::chrono::seconds(TimeoutSecs)); } LOG_INFO_STREAM << "Disconnecting from the server" << std::endl; Client.disconnect()->wait(); } catch (const mqtt::exception &e) { logErrorAndExit(e.what(), 1); } LOG_INFO_STREAM << "Done." << std::endl; return 0; } diff --git a/include/rosa/support/diagnostics.h b/include/rosa/support/diagnostics.h index 99b3fe4..190fc31 100644 --- a/include/rosa/support/diagnostics.h +++ b/include/rosa/support/diagnostics.h @@ -1,55 +1,61 @@ //===-- rosa/support/diagnostics.h ------------------------------*- C++ -*-===// // // The RoSA Framework // // Distributed under the terms and conditions of the Boost Software License 1.0. // See accompanying file LICENSE. // // If you did not receive a copy of the license file, see // http://www.boost.org/LICENSE_1_0.txt. // //===----------------------------------------------------------------------===// /// /// \file rosa/support/diagnostics.h /// /// \author David Juhasz (david.juhasz@tuwien.ac.at) /// /// \date 2020 /// /// \brief Facility for diagnostics. /// //===----------------------------------------------------------------------===// #if defined(_MSC_VER) #define ROSA_DISABLE_WARNING_PUSH __pragma(warning(push)) #define ROSA_DISABLE_WARNING_POP __pragma(warning(pop)) #define ROSA_DISABLE_WARNING(warningNumber) \ __pragma(warning(disable : warningNumber)) +#define ROSA_DISABLE_WARNING_MSVC_C4100 ROSA_DISABLE_WARNING(4100) +#define ROSA_DISABLE_WARNING_MSVC_C4201 ROSA_DISABLE_WARNING(4201) + #define ROSA_DISABLE_WARNING_UNUSED_LAMBDA_CAPTURE #define ROSA_DISABLE_WARNING_ADDING_INT_TO_STRING #elif defined(__GNUC__) || defined(__clang__) #define _ROSA_DIAG_DO_PRAGMA(X) _Pragma(#X) #define ROSA_DISABLE_WARNING_PUSH _ROSA_DIAG_DO_PRAGMA(GCC diagnostic push) #define ROSA_DISABLE_WARNING_POP _ROSA_DIAG_DO_PRAGMA(GCC diagnostic pop) #define ROSA_DISABLE_WARNING(warningName) \ _ROSA_DIAG_DO_PRAGMA(GCC diagnostic ignored warningName) +#define ROSA_DISABLE_WARNING_MSVC_C4100 +#define ROSA_DISABLE_WARNING_MSVC_C4201 + #define ROSA_DISABLE_WARNING_UNUSED_LAMBDA_CAPTURE \ ROSA_DISABLE_WARNING("-Wunused-lambda-capture") #define ROSA_DISABLE_WARNING_ADDING_INT_TO_STRING \ ROSA_DISABLE_WARNING("-Wstring-plus-int") #else #define ROSA_DISABLE_WARNING_PUSH #define ROSA_DISABLE_WARNING_POP #define ROSA_DISABLE_WARNING_UNUSED_LAMBDA_CAPTURE #define ROSA_DISABLE_WARNING_ADDING_INT_TO_STRING #endif diff --git a/include/rosa/support/mqtt/MQTTReader.hpp b/include/rosa/support/mqtt/MQTTReader.hpp index 97fc08e..7e80a67 100644 --- a/include/rosa/support/mqtt/MQTTReader.hpp +++ b/include/rosa/support/mqtt/MQTTReader.hpp @@ -1,316 +1,324 @@ //===-- rosa/support/MQTT/MQTTReader.hpp --------------------------*- C++ //-*-===// // // The RoSA Framework // // Distributed under the terms and conditions of the Boost Software License 1.0. // See accompanying file LICENSE. // // If you did not receive a copy of the license file, see // http://www.boost.org/LICENSE_1_0.txt. // //===----------------------------------------------------------------------===// /// /// \file rosa/support/MQTT/MQTTReader.hpp /// /// \authors Benedikt Tutzer (benedikt.tutzer@tuwien.ac.at), /// Maximilian Götzinger (maximilian.goetzinger@tuwien.ac.at), /// David Juhasz (david.juhasz@tuwien.ac.at) /// /// \date 2020 /// /// \brief Facitilities to read from MQTT brokers. /// //===----------------------------------------------------------------------===// #ifndef ROSA_SUPPORT_MQTT_MQTTREADER_HPP #define ROSA_SUPPORT_MQTT_MQTTREADER_HPP -#include "mqtt/async_client.h" +#include "rosa/support/diagnostics.h" #include "rosa/support/debug.hpp" +#include "rosa/support/log.h" + +// NOTE: MSVC warns about some things in the following header. +ROSA_DISABLE_WARNING_PUSH +ROSA_DISABLE_WARNING_MSVC_C4100 +ROSA_DISABLE_WARNING_MSVC_C4201 +#include "mqtt/async_client.h" +ROSA_DISABLE_WARNING_POP #include #include #include namespace rosa { namespace MQTT { // @TODO this is a copy of CSVReader.hpp. Move this functionalities to common // file /// Anonymous namespace providing implementation details for /// \c rosa::MQTT::MQTTCallback, consider it private. namespace { /// Provides facility for parsing one value from a string. /// /// \tparam T type of value to parse /// \tparam IsSignedInt if \p T is a signed integral type, always use default /// \tparam IsUnsignedInt if \p T is an unsigned integral type, always use /// default /// \tparam IsFloat if \p T is a floating-point type, always use default /// \tparam IsString if \p T is \c std::string, always use default /// /// \note Specializations of this struct are provided for arithmentic types /// and \c std::string. template ::value && std::is_signed::value), bool IsUnsignedInt = (std::is_integral::value && std::is_unsigned::value), bool IsFloat = std::is_floating_point::value, bool IsString = std::is_same::value> struct ValueParser { /// /// /// \param Cell the \c std::string to parse /// /// \return the parsed value /// /// \note The function silently fails if cannot parse \p Cell for type \p T. static T parse(const std::string &Cell) noexcept; }; template struct ValueParser { STATIC_ASSERT((std::is_integral::value && std::is_signed::value), "wrong type"); // Sanity check. static T parse(const std::string &Cell) noexcept { return static_cast(std::stoll(Cell)); } }; template struct ValueParser { STATIC_ASSERT((std::is_integral::value && std::is_unsigned::value), "wrong type"); // Sanity check. static T parse(const std::string &Cell) noexcept { return static_cast(std::stoull(Cell)); } }; template struct ValueParser { STATIC_ASSERT((std::is_floating_point::value), "wrong type"); // Sanity check. static T parse(const std::string &Cell) noexcept { return static_cast(std::stold(Cell)); } }; template struct ValueParser { STATIC_ASSERT((std::is_same::value), "wrong type"); // Sanity check. static T parse(const std::string &Cell) noexcept { return Cell; } }; } // End namespace /** * Local callback & listener class for use with the client connection. * This implementation is to receive messages but the mqtt::callback interface * allows further actions to be defined. */ template class MQTTCallback : public virtual mqtt::callback { /** Callback for when a message arrives. * @param Msg Pointer for the MQTT message **/ void message_arrived(mqtt::const_message_ptr Msg) override { LOG_DEBUG_STREAM << "New value" << std::endl; std::string Message = Msg->to_string(); const auto Value = ValueParser::parse(Message); LOG_DEBUG_STREAM << "Got value " << Value << std::endl; Buffer->push(Value); } /** * This method is called when the connection to the server is lost. * @param Cause Why connection got lost */ void connection_lost(const std::string &Cause) override { LOG_INFO_STREAM << "Connection to MQTT broker lost: " << Cause << std::endl; } private: const std::shared_ptr> Buffer; public: /* Constructor */ MQTTCallback(const std::shared_ptr> Buffer) noexcept : Buffer(Buffer) {} }; /// Provides `InputIterator` features for iterating over messages published in /// an MQTT topic. /// /// \todo Make \c rosa::MQTT::MQTTITerator::Buffer thread-safe. /// \todo Make \c rosa::MQTT::MQTTIterator be able to recover connection in case /// of any error. /// /// \tparam T type of values stored in MQTT messages /// /// /// \note The referred value of the iterator is initialized to a default /// initialized instance of \p T upon creation. The first received message may /// be read in by incrementing the iterator first. Also \see \c /// rosa::MQTT::MQTTIterator /// /// \note The iterator expects each MQTT message to match \p T /// /// \note The implementation relies on \c rosa::MQTT::MQTTCallback, which in /// turn relies on \c rosa::MQTT::ValueParser, which is implemented only for /// `arithmetic` types -- signed and unsigned integral types and floating-point /// types -- and for \c std::string. Those are the valid values for \p T template class MQTTIterator { public: /// \defgroup MQTTIteratorTypedefs Typedefs of rosa::MQTT::MQTTIterator /// /// Standard `typedef`s for iterators. /// ///@{ typedef std::input_iterator_tag iterator_category; ///< Category of the iterator. typedef T value_type; ///< Type of values iterated over. typedef std::size_t difference_type; ///< Type to identify distance. typedef T *pointer; ///< Pointer to the type iterated over. typedef T &reference; ///< Reference to the type iterated over. ///@} /// Creates a new instance. /// /// \param MQTTTopic MQTT topic to subscribe to /// \param Blocking Whether to block if next value is not arrived when /// incrementing /// \param ServerHost Hostname of MQTT broker to connect to /// \param ServerPort Port number of MQTT broker to connect to /// /// \note If \p Blocking, incrementing the iterator blocks in case the next /// value has not arrived yet. If not \p Blocking, incrementing the iterator /// has no effect when the next value is not arrived yet; \c nextReady() can /// be used to check whether incrementing can move to the next value. MQTTIterator(const std::string &MQTTTopic, const bool Blocking = true, const std::string ServerHost = "localhost", const uint16_t ServerPort = 1883) noexcept : Empty(false), Blocking(Blocking), ServerHost(ServerHost), ServerPort(ServerPort), MQTTTopic(MQTTTopic), Current(), Buffer(std::make_shared>()), Callback(std::make_shared>(Buffer)) { // Connect and register callback. std::stringstream ss; ss << "tcp://" << ServerHost << ":" << ServerPort; const std::string ServerURI = ss.str(); LOG_INFO_STREAM << "Initializing for " << ServerURI << std::endl; Client = std::make_shared(ServerURI, ""); // @note async_client is destructed when the shared pointer is destructed. LOG_INFO_STREAM << "Connecting to server" << std::endl; Client->connect()->wait(); LOG_INFO_STREAM << "Receiving messages from topic '" << MQTTTopic << "' for a short while..." << std::endl; Client->set_callback(*Callback); Client->subscribe(this->MQTTTopic, {}); } /// Creates an empty new instance. MQTTIterator(void) noexcept : Empty(true), Blocking(false), ServerHost(""), ServerPort(0), MQTTTopic(""), Current(), Buffer(std::make_shared>()), Callback(nullptr) {} /// Tells whether incrementing \p this can move to the next value. /// /// \return if the next value has already been received inline bool nextReady(void) const noexcept { return !Buffer->empty(); } /// Pre-increment operator. /// /// The implementation reads the next value. If If the end of the input stream is /// reached, the operator becomes empty and has no further effect. /// /// \return \p this object after incrementing it. MQTTIterator &operator++() { // Wait if Blocking and next value is not ready yet. auto &out = LOG_DEBUG_STREAM; out << "Getting next value "; while (Blocking && !nextReady()) { out << '+'; } out << '.' << std::endl; // Next value is ready, or not Blocking and so we leave the last one if (nextReady()) { LOG_DEBUG_STREAM << "Moving MQTTIterator to next value." << std::endl; Current = Buffer->front(); Buffer->pop(); } else { LOG_DEBUG_STREAM << "Trying to move MQTTIterator without next value." << std::endl; } return *this; } /// Post-increment operator. /// /// The implementation uses the pre-increment operator and returns a copy of /// the original state of \p this object. /// /// \return \p this object before incrementing it. MQTTIterator operator++(int) { MQTTIterator Tmp(*this); ++(*this); return Tmp; } /// Returns a constant reference to the current entry. /// /// \note Should not dereference the iterator when it is empty. /// /// \return constant reference to the current entry. const T &operator*(void)const noexcept { return Current; } /// Returns a constant pointer to the current entry. /// /// \note Should not dereference the iterator when it is empty. /// /// \return constant pointer to the current entry. const T *operator->(void)const noexcept { return &Current; } /// Tells if \p this object is equal to another one. /// /// Two \c rosa::MQTT::MQTTIterator instances are equal if and only if they /// are the same or both are empty. /// /// \param RHS other object to compare to /// /// \return whether \p this object is equal with \p RHS bool operator==(const MQTTIterator &RHS) const noexcept { return this == &RHS || (this->Empty && RHS.Empty); } /// Tells if \p this object is not equal to another one. /// /// \see rosa::MQTT::MQTTIterator::operator== /// /// \param RHS other object to compare to /// /// \return whether \p this object is not equal with \p RHS. bool operator!=(const MQTTIterator &RHS) const noexcept { return !((*this) == RHS); } private: const bool Empty; const bool Blocking; const std::string ServerHost; const uint16_t ServerPort; const std::string MQTTTopic; T Current; const std::shared_ptr> Buffer; const std::shared_ptr> Callback; std::shared_ptr Client; }; } // End namespace MQTT } // End namespace rosa #endif // ROSA_SUPPORT_MQTT_MQTTREADER_HPP diff --git a/lib/support/CMakeLists.txt b/lib/support/CMakeLists.txt index 318486d..076bc5c 100644 --- a/lib/support/CMakeLists.txt +++ b/lib/support/CMakeLists.txt @@ -1,46 +1,53 @@ set(LIB_INCLUDE_DIR ${ROSA_MAIN_INCLUDE_DIR}/rosa/support) add_library(ROSASupport ${LIB_INCLUDE_DIR}/debug.hpp debug.cpp ${LIB_INCLUDE_DIR}/terminal_colors.h terminal_colors.cpp ${LIB_INCLUDE_DIR}/log.h log.cpp ${LIB_INCLUDE_DIR}/math.hpp math.cpp ${LIB_INCLUDE_DIR}/type_helper.hpp type_helper.cpp ${LIB_INCLUDE_DIR}/types.hpp types.cpp ${LIB_INCLUDE_DIR}/atom.hpp atom.cpp ${LIB_INCLUDE_DIR}/type_pair.hpp type_pair.cpp ${LIB_INCLUDE_DIR}/type_list.hpp type_list.cpp ${LIB_INCLUDE_DIR}/squashed_int.hpp squashed_int.cpp ${LIB_INCLUDE_DIR}/type_numbers.hpp type_numbers.cpp ${LIB_INCLUDE_DIR}/type_token.hpp type_token.cpp ${LIB_INCLUDE_DIR}/tokenized_storages.hpp tokenized_storages.cpp ${LIB_INCLUDE_DIR}/sequence.hpp sequence.cpp ${LIB_INCLUDE_DIR}/csv/namespace.h csv/namespace.cpp ${LIB_INCLUDE_DIR}/csv/CSVReader.hpp csv/CSVReader.cpp ${LIB_INCLUDE_DIR}/csv/CSVWriter.hpp csv/CSVWriter.cpp + ${LIB_INCLUDE_DIR}/mqtt/namespace.h + mqtt/namespace.cpp + ${LIB_INCLUDE_DIR}/mqtt/MQTTReader.hpp + mqtt/MQTTReader.cpp ${LIB_INCLUDE_DIR}/iterator/namespace.h iterator/namespace.cpp ${LIB_INCLUDE_DIR}/iterator/split_tuple_iterator.hpp iterator/split_tuple_iterator.cpp ${LIB_INCLUDE_DIR}/writer/namespace.h writer/namespace.cpp ${LIB_INCLUDE_DIR}/writer/split_tuple_writer.hpp writer/split_tuple_writer.cpp ) + +ROSA_add_library_dependencies(ROSASupport paho-mqttpp3) +ROSA_add_library_dependencies(ROSASupport paho-mqttc3::MQTTAsync) diff --git a/lib/support/mqtt/MQTTReader.cpp b/lib/support/mqtt/MQTTReader.cpp new file mode 100644 index 0000000..344ede5 --- /dev/null +++ b/lib/support/mqtt/MQTTReader.cpp @@ -0,0 +1,26 @@ +//===-- support/mqtt/MQTTReader.cpp -----------------------------*- C++ -*-===// +// +// The RoSA Framework +// +// Distributed under the terms and conditions of the Boost Software License 1.0. +// See accompanying file LICENSE. +// +// If you did not receive a copy of the license file, see +// http://www.boost.org/LICENSE_1_0.txt. +// +//===----------------------------------------------------------------------===// +/// +/// \file support/mqtt/MQTTReader.cpp +/// +/// \author David Juhasz (david.juhasz@tuwien.ac.at) +/// +/// \date 2020 +/// +/// \brief Implementation for rosa/support/mqtt/MQTTReader.hpp. +/// +/// \note Empty implementation, source file here to have a compile database +/// entry for rosa/support/mqtt/MQTTReader.hpp. +/// +//===----------------------------------------------------------------------===// + +#include "rosa/support/mqtt/MQTTReader.hpp" diff --git a/lib/support/mqtt/namespace.cpp b/lib/support/mqtt/namespace.cpp new file mode 100644 index 0000000..9362c68 --- /dev/null +++ b/lib/support/mqtt/namespace.cpp @@ -0,0 +1,26 @@ +//===-- support/mqtt/namespace.cpp ------------------------------*- C++ -*-===// +// +// The RoSA Framework +// +// Distributed under the terms and conditions of the Boost Software License 1.0. +// See accompanying file LICENSE. +// +// If you did not receive a copy of the license file, see +// http://www.boost.org/LICENSE_1_0.txt. +// +//===----------------------------------------------------------------------===// +/// +/// \file support/mqtt/namespace.cpp +/// +/// \author David Juhasz (david.juhasz@tuwien.ac.at) +/// +/// \date 2020 +/// +/// \brief Placeholder for rosa/support/mqtt/namespace.h. +/// +/// \note Empty implementation, source file here to have a compile database +/// entry for rosa/support/mqtt/namespace.h. +/// +//===----------------------------------------------------------------------===// + +#include "rosa/support/mqtt/namespace.h" diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index b1b8c21..628870b 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -1,19 +1,25 @@ if ( ROSA_COMPILER_IS_GCC_COMPATIBLE ) # Allow exceptions by removing restricting flag (needed by cxxopts) remove("-fno-exceptions" CMAKE_CXX_FLAGS) # Allow dynamic casts by removing restriction flag (needed by cxxopts) remove("-fno-rtti" CMAKE_CXX_FLAGS) + + # Allow warnings in submodules + remove("-Werror" CMAKE_CXX_FLAGS) elseif ( MSVC ) # Exceptions enabled for MSVC by default but need to allow RTTI # (needed by cxxopts) remove("/GR-" CMAKE_CXX_FLAGS) + + # Allow warnings in submodules + remove("/WX" CMAKE_CXX_FLAGS) endif() execute_process(COMMAND git submodule update --init --recursive WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) # Add the different subdirectories ADDALLSUBDIRS(${ROSA_EXCLUDE_SUBMODULES})