From 1b5c8665c071f6e06cd27cfe975fdf4f2693d7ef Mon Sep 17 00:00:00 2001 From: Matt Kolodziejski Date: Sat, 30 May 2015 17:09:30 +0200 Subject: [PATCH 1/3] Add MinGW mode. --- .gitignore | 3 +++ CMakeLists.txt | 16 +++++++++++++++- libs/Application/CMakeLists.txt | 4 +++- libs/Configuration/CMakeLists.txt | 4 +++- libs/Logger/CMakeLists.txt | 4 +++- libs/Mode/CMakeLists.txt | 4 +++- libs/ModeFactory/CMakeLists.txt | 4 +++- libs/ModeProxy/CMakeLists.txt | 4 +++- libs/ModeProxy/IPResolver.hpp | 8 ++++++++ libs/ModeProxy/ModeProxy.cpp | 11 +++++------ libs/ModeProxy/ModeProxy.hpp | 4 ++-- tests/CMakeLists.txt | 4 +++- utils/PortBlocker/CMakeLists.txt | 4 +++- 13 files changed, 57 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 620d3dc..c70c2d9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# IDE +.idea/ + # Compiled Object files *.slo *.lo diff --git a/CMakeLists.txt b/CMakeLists.txt index d0f07a4..4a127ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,18 @@ MSource_ForceOutOfSourceBuild() MSource_DetermineAddressModel(MSOURCE_ADDRESS_MODEL) message(STATUS "Detected ${MSOURCE_ADDRESS_MODEL}-bit address model.") +set(MINGW "TRUE" CACHE FILEPATH "MinGW environment") +set(CMAKE_INSTALL_PREFIX "C:/dev/mct/build/rtm" CACHE FILEPATH "Installation prefix") +set(CMAKE_BUILD_TYPE "Release" CACHE FILEPATH "Build type") +set(MOCCPPLIB_INCLUDES "C:/dev/deps/moccpplib_0_2_0_release32/include/" CACHE FILEPATH "moccpplib includes") +set(MOCCPPLIB_LIBRARIES "C:/dev/deps/moccpplib_0_2_0_release32/lib" CACHE FILEPATH "moccpplib libraries") +set(CPPUNIT_INCLUDES "C:/dev/deps/cppunit_1_13_2_release32/" CACHE FILEPATH "cppunit includes") +set(CPPUNIT_LIBRARY "C:/dev/deps/cppunit_1_13_2_release32/cppunit.lib" CACHE FILEPATH "cppunit library") +set(MOCTEST_LIB "C:/dev/deps/moctest_0_2_0_release32/lib" CACHE FILEPATH "moctest library") +set(MOCTEST_INCLUDES "C:/dev/deps/moctest_0_2_0_release32/include" CACHE FILEPATH "moctest includes") +set(BOOST_PATH "C:/dev/deps/boost_1_58_0_release32/" CACHE FILEPATH "boost path") +#set(BOOST_VERSION "1.58.0" CACHE FILEPATH "boost version") + # Output description of this script message( "\n\nThis script builds the mct application.\n" @@ -120,10 +132,12 @@ add_definitions( ${Boost_LIB_DIAGNOSTIC_DEFINITIONS} ) add_definitions( -DBOOST_ALL_DYN_LINK ) add_definitions( -DBOOST_FILESYSTEM_NO_DEPRECATED ) -if(WIN32) +if(WIN32 AND NOT MINGW) # Disable dll-external warnings for Visual Studio; [/GS-] disable buffer overflow security checks (optimization); # Boost.Asio needs to know windows version [0x0501 - WinXP minimum] set(PROGRAM_COMPILE_FLAGS ${PROGRAM_COMPILE_FLAGS} "/wd4251 /GS- -D_WIN32_WINNT=0x0501") +elseif(WIN32 AND MINGW) + set(PROGRAM_COMPILE_FLAGS ${PROGRAM_COMPILE_FLAGS} "-std=c++11 -D_WIN32_WINNT=0x0501") else() # Activate C++11 mode for GNU/GCC set(PROGRAM_COMPILE_FLAGS ${PROGRAM_COMPILE_FLAGS} "-std=c++11") diff --git a/libs/Application/CMakeLists.txt b/libs/Application/CMakeLists.txt index 66d8222..8903736 100644 --- a/libs/Application/CMakeLists.txt +++ b/libs/Application/CMakeLists.txt @@ -21,10 +21,12 @@ set(LIBRARY_NAME mctapp) -if(WIN32) +if(WIN32 AND NOT MINGW) # Disable dll-external warnings for Visual Studio; [/GS-] disable buffer overflow security checks (optimization) # Boost.Asio needs to know windows version [0x0501 - WinXP minimum] set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-DMCT_APPLICATION_DLL=1 /wd4251 /wd4275 /GS- -D_WIN32_WINNT=0x0501") +elseif(WIN32 AND MINGW) + set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-std=c++11 -DMCT_APPLICATION_DLL=1 -D_WIN32_WINNT=0x0501") else() # Activate C++11 mode for GNU/GCC set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-std=c++11 -DMCT_APPLICATION_DLL=1") diff --git a/libs/Configuration/CMakeLists.txt b/libs/Configuration/CMakeLists.txt index dbd000e..ccbaa1c 100644 --- a/libs/Configuration/CMakeLists.txt +++ b/libs/Configuration/CMakeLists.txt @@ -21,10 +21,12 @@ set(LIBRARY_NAME mctconfig) -if(WIN32) +if(WIN32 AND NOT MINGW) # Disable dll-external warnings for Visual Studio; [/GS-] disable buffer overflow security checks (optimization) # Boost.Asio needs to know windows version [0x0501 - WinXP minimum] set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-DMCT_CONFIGURATION_DLL=1 /wd4251 /wd4275 /GS- -D_WIN32_WINNT=0x0501") +elseif(WIN32 AND MINGW) + set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-std=c++11 -DMCT_CONFIGURATION_DLL=1 -D_WIN32_WINNT=0x0501") else() # Activate C++11 mode for GNU/GCC set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-std=c++11 -DMCT_CONFIGURATION_DLL=1") diff --git a/libs/Logger/CMakeLists.txt b/libs/Logger/CMakeLists.txt index 673e8cc..8e3d8ed 100644 --- a/libs/Logger/CMakeLists.txt +++ b/libs/Logger/CMakeLists.txt @@ -21,10 +21,12 @@ set(LIBRARY_NAME mctlog) -if(WIN32) +if(WIN32 AND NOT MINGW) # Disable dll-external warnings for Visual Studio; [/GS-] disable buffer overflow security checks (optimization) # Boost.Asio needs to know windows version [0x0501 - WinXP minimum] set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-DMCT_LOGGER_DLL=1 /wd4251 /wd4275 /GS- -D_WIN32_WINNT=0x0501") +elseif(WIN32 AND MINGW) + set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-std=c++11 -DMCT_LOGGER_DLL=1 -D_WIN32_WINNT=0x0501") else() # Activate C++11 mode for GNU/GCC set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-std=c++11 -DMCT_LOGGER_DLL=1") diff --git a/libs/Mode/CMakeLists.txt b/libs/Mode/CMakeLists.txt index 54d3748..3135b82 100644 --- a/libs/Mode/CMakeLists.txt +++ b/libs/Mode/CMakeLists.txt @@ -21,10 +21,12 @@ set(LIBRARY_NAME mctmode) -if(WIN32) +if(WIN32 AND NOT MINGW) # Disable dll-external warnings for Visual Studio; [/GS-] disable buffer overflow security checks (optimization) # Boost.Asio needs to know windows version [0x0501 - WinXP minimum] set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-DMCT_MODE_DLL=1 /wd4251 /wd4275 /GS- -D_WIN32_WINNT=0x0501") +elseif(WIN32 AND MINGW) + set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-std=c++11 -DMCT_MODE_DLL=1 -D_WIN32_WINNT=0x0501") else() # Activate C++11 mode for GNU/GCC set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-std=c++11 -DMCT_MODE_DLL=1") diff --git a/libs/ModeFactory/CMakeLists.txt b/libs/ModeFactory/CMakeLists.txt index 36caedb..cbd2cbb 100644 --- a/libs/ModeFactory/CMakeLists.txt +++ b/libs/ModeFactory/CMakeLists.txt @@ -21,10 +21,12 @@ set(LIBRARY_NAME mctmodefactory) -if(WIN32) +if(WIN32 AND NOT MINGW) # Disable dll-external warnings for Visual Studio; [/GS-] disable buffer overflow security checks (optimization) # Boost.Asio needs to know windows version [0x0501 - WinXP minimum] set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-DMCT_MODEFACTORY_DLL=1 /wd4251 /wd4275 /GS- -D_WIN32_WINNT=0x0501") +elseif(WIN32 AND MINGW) + set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-std=c++11 -DMCT_MODEFACTORY_DLL=1 -D_WIN32_WINNT=0x0501") else() # Activate C++11 mode for GNU/GCC set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-std=c++11 -DMCT_MODEFACTORY_DLL=1") diff --git a/libs/ModeProxy/CMakeLists.txt b/libs/ModeProxy/CMakeLists.txt index 28609c2..24a3882 100644 --- a/libs/ModeProxy/CMakeLists.txt +++ b/libs/ModeProxy/CMakeLists.txt @@ -21,10 +21,12 @@ set(LIBRARY_NAME mctmodeproxy) -if(WIN32) +if(WIN32 AND NOT MINGW) # Disable dll-external warnings for Visual Studio; [/GS-] disable buffer overflow security checks (optimization) # Boost.Asio needs to know windows version [0x0501 - WinXP minimum] set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-DMCT_MODEPROXY_DLL=1 /wd4251 /wd4275 /GS- -D_WIN32_WINNT=0x0501 -DBOOST_ASIO_HAS_MOVE") +elseif(WIN32 AND MINGW) + set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-std=c++11 -DMCT_MODEPROXY_DLL=1 -D_WIN32_WINNT=0x0501 -DBOOST_ASIO_HAS_MOVE") else() # Activate C++11 mode for GNU/GCC set(LIBRARY_COMPILE_FLAGS ${LIBRARY_COMPILE_FLAGS} "-std=c++11 -DMCT_MODEPROXY_DLL=1") diff --git a/libs/ModeProxy/IPResolver.hpp b/libs/ModeProxy/IPResolver.hpp index 20ab520..5ad45e7 100644 --- a/libs/ModeProxy/IPResolver.hpp +++ b/libs/ModeProxy/IPResolver.hpp @@ -34,6 +34,14 @@ #include +namespace boost +{ + namespace asio + { + class io_service; + } +} + namespace mct { diff --git a/libs/ModeProxy/ModeProxy.cpp b/libs/ModeProxy/ModeProxy.cpp index dd68b31..7ecc1ef 100644 --- a/libs/ModeProxy/ModeProxy.cpp +++ b/libs/ModeProxy/ModeProxy.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -64,10 +63,10 @@ const std::string& ModeProxy::get_name() const bool ModeProxy::validate_configuration() const { if (m_config.get_mode_proxy_local_hosts().size() != m_config.get_mode_proxy_remote_hosts().size() != m_config.get_mode_proxy_local_ports().size() != m_config.get_mode_proxy_remote_ports().size()) { - uint16_t lh = m_config.get_mode_proxy_local_hosts().size(); - uint16_t rh = m_config.get_mode_proxy_remote_hosts().size(); - uint16_t lp = m_config.get_mode_proxy_local_ports().size(); - uint16_t rp = m_config.get_mode_proxy_remote_ports().size(); + uint16_t lh = (uint16_t)m_config.get_mode_proxy_local_hosts().size(); + uint16_t rh = (uint16_t)m_config.get_mode_proxy_remote_hosts().size(); + uint16_t lp = (uint16_t)m_config.get_mode_proxy_local_ports().size(); + uint16_t rp = (uint16_t)m_config.get_mode_proxy_remote_ports().size(); uint16_t max = (std::max)({lh, rh, lp, rp}); auto report_conf_problem = [&](const std::string& conf_field, uint16_t expected_val, uint16_t actual_val) { @@ -104,7 +103,7 @@ bool ModeProxy::validate_configuration() const uint16_t ModeProxy::get_num_of_all_proxies() const { // since all vectors are equal (checked with validate_configuration()), return the size of the first one - return m_config.get_mode_proxy_local_hosts().size(); + return (uint16_t)m_config.get_mode_proxy_local_hosts().size(); } bool ModeProxy::run() diff --git a/libs/ModeProxy/ModeProxy.hpp b/libs/ModeProxy/ModeProxy.hpp index 6f8b253..d3d7232 100644 --- a/libs/ModeProxy/ModeProxy.hpp +++ b/libs/ModeProxy/ModeProxy.hpp @@ -50,9 +50,9 @@ class MCT_MODEPROXY_DLL_PUBLIC ModeProxy : public Mode ModeProxy(const ModeProxy&) = delete; ModeProxy& operator=(const ModeProxy&) = delete; - virtual const std::string& get_name() const; + virtual const std::string& get_name() const final; - virtual bool run(); + virtual bool run() final; protected: uint16_t get_num_of_all_proxies() const; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 61858ee..13ec154 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -39,9 +39,11 @@ add_definitions( -DBOOST_ALL_DYN_LINK ) add_definitions( -DBOOST_LOG_DYN_LINK ) add_definitions( -DBOOST_FILESYSTEM_NO_DEPRECATED ) -if(WIN32) +if(WIN32 AND NOT MINGW) # Disable dll-external warnings for Visual Studio; [/GS-] disable buffer overflow security checks (optimization) set(PROGRAM_COMPILE_FLAGS ${PROGRAM_COMPILE_FLAGS} "/wd4251 /wd4275 /wd4351 /GS-") +elseif(WIN32 AND MINGW) + set(PROGRAM_COMPILE_FLAGS ${PROGRAM_COMPILE_FLAGS} "-std=c++11") else() # Activate C++11 mode for GNU/GCC; set rpath to $ORIGIN so the shared library can be easily found set(PROGRAM_COMPILE_FLAGS ${PROGRAM_COMPILE_FLAGS} "-std=c++11") diff --git a/utils/PortBlocker/CMakeLists.txt b/utils/PortBlocker/CMakeLists.txt index 632b1d8..610606b 100644 --- a/utils/PortBlocker/CMakeLists.txt +++ b/utils/PortBlocker/CMakeLists.txt @@ -37,9 +37,11 @@ add_definitions( -DBOOST_ALL_DYN_LINK ) add_definitions( -DBOOST_LOG_DYN_LINK ) add_definitions( -DBOOST_FILESYSTEM_NO_DEPRECATED ) -if(WIN32) +if(WIN32 AND NOT MINGW) # Disable dll-external warnings for Visual Studio; [/GS-] disable buffer overflow security checks (optimization) set(PROGRAM_COMPILE_FLAGS ${PROGRAM_COMPILE_FLAGS} "/wd4251 /wd4275 /wd4351 /GS- -D_WIN32_WINNT=0x0501 -DBOOST_ASIO_HAS_MOVE") +elseif(WIN32 AND MINGW) + set(PROGRAM_COMPILE_FLAGS ${PROGRAM_COMPILE_FLAGS} "-std=c++11") else() # Activate C++11 mode for GNU/GCC; set rpath to $ORIGIN so the shared library can be easily found set(PROGRAM_COMPILE_FLAGS ${PROGRAM_COMPILE_FLAGS} "-std=c++11") From dd999d5735b2d0eb3e3a63f96027323318c17461 Mon Sep 17 00:00:00 2001 From: Mattsource Date: Sat, 30 May 2015 17:11:16 +0200 Subject: [PATCH 2/3] BOOST_VERSION CACHE corrected --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a127ee..7a21406 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,7 @@ set(CPPUNIT_LIBRARY "C:/dev/deps/cppunit_1_13_2_release32/cppunit.lib" CACHE FIL set(MOCTEST_LIB "C:/dev/deps/moctest_0_2_0_release32/lib" CACHE FILEPATH "moctest library") set(MOCTEST_INCLUDES "C:/dev/deps/moctest_0_2_0_release32/include" CACHE FILEPATH "moctest includes") set(BOOST_PATH "C:/dev/deps/boost_1_58_0_release32/" CACHE FILEPATH "boost path") -#set(BOOST_VERSION "1.58.0" CACHE FILEPATH "boost version") +set(BOOST_VERSION "1.58.0" CACHE BOOL "boost version") # Output description of this script message( From fe6522b162a08bbcb9eba0ea58bd47703332b743 Mon Sep 17 00:00:00 2001 From: Mattsource Date: Sat, 30 May 2015 17:12:47 +0200 Subject: [PATCH 3/3] MINGW is a bool in CMakeLists --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a21406..c1698c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ MSource_ForceOutOfSourceBuild() MSource_DetermineAddressModel(MSOURCE_ADDRESS_MODEL) message(STATUS "Detected ${MSOURCE_ADDRESS_MODEL}-bit address model.") -set(MINGW "TRUE" CACHE FILEPATH "MinGW environment") +set(MINGW "TRUE" CACHE BOOL "MinGW environment") set(CMAKE_INSTALL_PREFIX "C:/dev/mct/build/rtm" CACHE FILEPATH "Installation prefix") set(CMAKE_BUILD_TYPE "Release" CACHE FILEPATH "Build type") set(MOCCPPLIB_INCLUDES "C:/dev/deps/moccpplib_0_2_0_release32/include/" CACHE FILEPATH "moccpplib includes")