Repository: SpectrumIM/spectrum2 (language: python)

Issue:
Error when compiling on Arch Linux
Hi! Getting this error when trying to compile on Arch since some time. I think a later version of boot broke it somewhat.

```
   36 | BOOST_PRAGMA_MESSAGE(
      | ^~~~~~~~~~~~~~~~~~~~
[  7%] Building CXX object libtransport/CMakeFiles/transport.dir/Conversation.cpp.o
In file included from /home/knez/spectrum2/libtransport/Conversation.cpp:22:
/home/knez/spectrum2/include/transport/Conversation.h:187:22: error: ‘map’ in namespace ‘std’ does not name a template type
  187 |                 std::map<std::string, Participant> m_participants;
      |                      ^~~
In file included from /home/knez/spectrum2/libtransport/Conversation.cpp:22:
/home/knez/spectrum2/include/transport/Conversation.h:28:1: note: ‘std::map’ is defined in header ‘<map>’; did you forget to ‘#include <map>’?
   27 | #include "Swiften/Elements/Presence.h"
  +++ |+#include <map>
   28 | 
In file included from /usr/include/boost/smart_ptr/detail/sp_thread_sleep.hpp:22,
                 from /usr/include/boost/smart_ptr/detail/yield_k.hpp:23,
                 from /usr/include/boost/smart_ptr/detail/spinlock_gcc_atomic.hpp:14,
                 from /usr/include/boost/smart_ptr/detail/spinlock.hpp:42,
                 from /usr/include/boost/smart_ptr/detail/spinlock_pool.hpp:25,
                 from /usr/include/boost/smart_ptr/shared_ptr.hpp:29,
                 from /usr/include/boost/shared_ptr.hpp:17,
                 from /usr/include/boost/signals2/deconstruct.hpp:28,
                 from /usr/include/boost/signals2.hpp:15,
                 from /home/knez/spectrum2/include/transport/User.h:25,
                 from /home/knez/spectrum2/libtransport/Conversation.cpp:24:
/usr/include/boost/bind.hpp:36:1: note: ‘#pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.’
   36 | BOOST_PRAGMA_MESSAGE(
      | ^~~~~~~~~~~~~~~~~~~~
/home/knez/spectrum2/libtransport/Conversation.cpp: In member function ‘void Transport::Conversation::handleMessage(std::shared_ptr<Swift::Message>&, const string&, bool)’:
/home/knez/spectrum2/libtransport/Conversation.cpp:223:67: error: ‘m_participants’ was not declared in this scope; did you mean ‘getParticipants’?
  223 |                 std::map<std::string, Participant>::iterator it = m_participants.find(n);
      |                                                                   ^~~~~~~~~~~~~~
      |                                                                   getParticipants
/home/knez/spectrum2/libtransport/Conversation.cpp: In member function ‘std::string Transport::Conversation::getParticipants()’:
/home/knez/spectrum2/libtransport/Conversation.cpp:328:64: error: ‘m_participants’ was not declared in this scope; did you mean ‘getParticipants’?
  328 |         for (std::map<std::string, Participant>::iterator it = m_participants.begin(); it != m_participants.end(); it++) {
      |                                                                ^~~~~~~~~~~~~~
      |                                                                getParticipants
/home/knez/spectrum2/libtransport/Conversation.cpp: In member function ‘void Transport::Conversation::sendParticipants(const Swift::JID&, const string&)’:
/home/knez/spectrum2/libtransport/Conversation.cpp:362:64: error: ‘m_participants’ was not declared in this scope; did you mean ‘getParticipants’?
  362 |         for (std::map<std::string, Participant>::iterator it = m_participants.begin(); it != m_participants.end(); it++) {
      |                                                                ^~~~~~~~~~~~~~
      |                                                                getParticipants
/home/knez/spectrum2/libtransport/Conversation.cpp: In member function ‘void Transport::Conversation::handleRawPresence(Swift::Presence::ref)’:
/home/knez/spectrum2/libtransport/Conversation.cpp:495:9: error: ‘m_participants’ was not declared in this scope; did you mean ‘getParticipants’?
  495 |         m_participants[presence->getFrom().getResource()].presence = presence;
      |         ^~~~~~~~~~~~~~
      |         getParticipants
/home/knez/spectrum2/libtransport/Conversation.cpp: In member function ‘void Transport::Conversation::handleParticipantChanged(const string&, Transport::Conversation::ParticipantFlag, int, const string&, const string&, const string&, const string&)’:
/home/knez/spectrum2/libtransport/Conversation.cpp:511:17: error: ‘m_participants’ was not declared in this scope; did you mean ‘getParticipants’?
  511 |                 m_participants.erase(nick);
      |                 ^~~~~~~~~~~~~~
      |                 getParticipants
/home/knez/spectrum2/libtransport/Conversation.cpp:514:17: error: ‘m_participants’ was not declared in this scope; did you mean ‘getParticipants’?
  514 |                 m_participants[nick].presence = presence;
      |                 ^~~~~~~~~~~~~~
      |                 getParticipants
make[2]: *** [libtransport/CMakeFiles/transport.dir/build.make:132: libtransport/CMakeFiles/transport.dir/Conversation.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:492: libtransport/CMakeFiles/transport.dir/all] Error 2
make: *** [Makefile:156: all] Error 2
```


Discussion / hints:
Can you follow a compiler suggestion and add `#include <map>` to Conversation.h file?
Thank you, that worked!

Fix patch:
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index c3560a83f..0da3a6858 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -34,16 +34,23 @@ jobs:
     - name: Run tests
       run: docker run -tt --env LANG=en_US.UTF-8 spectrum:tests-musl
   macos:
-    runs-on: macOS-latest
+    runs-on: macOS-11.0
     steps:
     - uses: actions/checkout@v2
+    - name: Install MacPorts
+      run: |
+        curl -L -O "https://github.com/macports/macports-base/releases/download/v2.7.1/MacPorts-2.7.1-11-BigSur.pkg"
+        sudo installer -store -pkg MacPorts-2.7.1-11-BigSur.pkg -target /
+        echo "https://packages.spectrum.im/macports/ports.tar.bz2" | sudo tee -a /opt/local/etc/macports/sources.conf
     - name: Install dependencies
-      run: brew install cppunit log4cxx popt jsoncpp libswiften protobuf pkg-config
+      run: |
+        export PATH=$PATH:/opt/local/bin
+        sudo rm -rf /usr/local/*
+        sudo port -v selfupdate && sudo port -q install cppunit log4cxx popt jsoncpp protobuf3-cpp pkgconfig boost cmake zlib libswiften
     - name: Configure build
       run: |
-        rm /usr/local/include/Swiften/Network/DummyConnectionServer.h
-        rm /usr/local/include/Swiften/Network/DummyConnectionServerFactory.h
-        cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=ON -DENABLE_FROTZ=OFF -DCMAKE_UNITY_BUILD=ON .
+        export PATH=$PATH:/opt/local/bin:/usr/local/bin
+        cmake -DCMAKE_BUILD_TYPE=MacPorts -DENABLE_TESTS=ON -DCMAKE_UNITY_BUILD=ON .
     - name: Initialize CodeQL
       uses: github/codeql-action/init@v1
       with:
@@ -53,7 +60,13 @@ jobs:
     - name: Perform CodeQL Analysis
       uses: github/codeql-action/analyze@v1
     - name: Run tests
-      run:  make test
+      run:  |
+        install_name_tool -change libSwiften.4.dylib @rpath/libSwiften.4.dylib tests/libtransport/libtransport_test
+        install_name_tool -add_rpath /opt/local/lib tests/libtransport/libtransport_test
+        install_name_tool -change libSwiften.4.dylib @rpath/libSwiften.4.dylib libtransport/libtransport.2.0.dylib
+        install_name_tool -add_rpath /opt/local/lib libtransport/libtransport.2.0.dylib
+        make test
+    
 
   windows:
     runs-on: windows-latest
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 53b1228c8..61093eb4d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -165,10 +165,6 @@ if(NOT PROTOBUF_FOUND AND PROTOBUF_INCLUDE_DIR AND PROTOBUF_LIBRARY)
 endif()
 
 find_package(JsonCpp REQUIRED)
-if(JSONCPP_FOUND)
-	include_directories(${JSONCPP_INCLUDE_DIRS})
-	message(STATUS "Found jsoncpp: ${JSONCPP_INCLUDE_DIRS} ${JSONCPP_LIBRARY}, shared: ${JSONCPP_LIBRARY_IS_SHARED}")
-endif()
 
 if(WIN32)
 	add_definitions(-DSWIFTEN_STATIC=1)
diff --git a/backends/frotz/CMakeLists.txt b/backends/frotz/CMakeLists.txt
index 26dbeec3c..677dbae9c 100644
--- a/backends/frotz/CMakeLists.txt
+++ b/backends/frotz/CMakeLists.txt
@@ -1,5 +1,3 @@
-cmake_minimum_required(VERSION 2.6)
-
 add_subdirectory(dfrotz)
 
 file(GLOB SRC *.c *.cpp)
diff --git a/backends/frotz/dfrotz/CMakeLists.txt b/backends/frotz/dfrotz/CMakeLists.txt
index 1cd8ea7e0..7565a5b72 100644
--- a/backends/frotz/dfrotz/CMakeLists.txt
+++ b/backends/frotz/dfrotz/CMakeLists.txt
@@ -1,4 +1,3 @@
-cmake_minimum_required(VERSION 2.6)
 file(GLOB SRC common/*.c dumb/*.c)
 
 add_executable(dfrotz ${SRC})
diff --git a/backends/libcommuni/CMakeLists.txt b/backends/libcommuni/CMakeLists.txt
index 15778215d..47b591ba8 100644
--- a/backends/libcommuni/CMakeLists.txt
+++ b/backends/libcommuni/CMakeLists.txt
@@ -1,5 +1,3 @@
-cmake_minimum_required(VERSION 2.6)
-
 file(GLOB SRC *.cpp)
 file(GLOB HEADERS *.h)
 
diff --git a/backends/libpurple/CMakeLists.txt b/backends/libpurple/CMakeLists.txt
index 896370d5b..7b9f4145c 100644
--- a/backends/libpurple/CMakeLists.txt
+++ b/backends/libpurple/CMakeLists.txt
@@ -1,5 +1,3 @@
-cmake_minimum_required(VERSION 2.6)
-
 file(GLOB SRC *.cpp)
 
 add_executable(spectrum2_libpurple_backend ${SRC})
diff --git a/backends/smstools3/CMakeLists.txt b/backends/smstools3/CMakeLists.txt
index ea041462c..95ef831e5 100644
--- a/backends/smstools3/CMakeLists.txt
+++ b/backends/smstools3/CMakeLists.txt
@@ -1,5 +1,3 @@
-cmake_minimum_required(VERSION 2.6)
-
 file(GLOB SRC *.c *.cpp)
 
 add_executable(spectrum2_smstools3_backend ${SRC})
diff --git a/backends/swiften/CMakeLists.txt b/backends/swiften/CMakeLists.txt
index bc40e704b..411fc8ad5 100644
--- a/backends/swiften/CMakeLists.txt
+++ b/backends/swiften/CMakeLists.txt
@@ -1,5 +1,3 @@
-cmake_minimum_required(VERSION 2.6)
-
 file(GLOB SRC *.cpp)
 
 add_executable(spectrum2_swiften_backend ${SRC})
diff --git a/backends/template/CMakeLists.txt b/backends/template/CMakeLists.txt
index 02beae2ee..26fcde1b9 100644
--- a/backends/template/CMakeLists.txt
+++ b/backends/template/CMakeLists.txt
@@ -1,5 +1,3 @@
-cmake_minimum_required(VERSION 2.6)
-
 file(GLOB SRC *.c *.cpp)
 
 add_executable(spectrum2_template_backend ${SRC})
diff --git a/backends/twitter/CMakeLists.txt b/backends/twitter/CMakeLists.txt
index 1ff730567..6748305db 100644
--- a/backends/twitter/CMakeLists.txt
+++ b/backends/twitter/CMakeLists.txt
@@ -8,8 +8,7 @@ find_package(CURL)
 
 if(CURL_FOUND)
 	message(STATUS "Using curl ${CURL_VERSION_STRING}: ${CURL_INCLUDE_DIRS} ${CURL_LIBRARIES}")
-	include_directories (${CURL_INCLUDE_DIRS} ${JSONCPP_INCLUDE_DIRS})
-	target_link_libraries(spectrum2_twitter_backend transport ${CURL_LIBRARIES} ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
+	target_link_libraries(spectrum2_twitter_backend transport JsonCpp::JsonCpp ${CURL_LIBRARIES} ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
 else()
 	message(FATAL_ERROR "curl not found")
 endif()
diff --git a/cmake_modules/FindJsonCpp.cmake b/cmake_modules/FindJsonCpp.cmake
index 67045e97b..e08b06c64 100644
--- a/cmake_modules/FindJsonCpp.cmake
+++ b/cmake_modules/FindJsonCpp.cmake
@@ -26,8 +26,11 @@
 # Incorporates work from the module contributed to VRPN under the same license:
 # 2011 Philippe Crassous (ENSAM ParisTech / Institut Image) p.crassous _at_ free.fr
 #
-# Copyright Philippe Crassous 2011.
-# Copyright Sensics, Inc. 2016.
+# Copyright 2011, Philippe Crassous
+# Copyright 2016, Sensics, Inc.
+#
+# SPDX-License-Identifier: BSL-1.0
+#
 # Distributed under the Boost Software License, Version 1.0.
 # (See accompanying file LICENSE_1_0.txt or copy at
 # http://www.boost.org/LICENSE_1_0.txt)
@@ -84,7 +87,7 @@ if(jsoncpp_FOUND)
 		set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_RELEASE RELEASE RELWITHDEBINFO MINSIZEREL NONE ${_jsoncpp_debug_fallback})
 		set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_RELWITHDEBINFO RELWITHDEBINFO RELEASE MINSIZEREL NONE ${_jsoncpp_debug_fallback})
 		set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_MINSIZEREL MINSIZEREL RELEASE RELWITHDEBINFO NONE ${_jsoncpp_debug_fallback})
-		set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_NONE RELEASE RELWITHDEBINFO MINSIZEREL ${_jsoncpp_debug_fallback})
+		set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_NONE NONE RELEASE RELWITHDEBINFO MINSIZEREL ${_jsoncpp_debug_fallback})
 		if(NOT MSVC)
 			set_property(TARGET ${target} APPEND PROPERTY MAP_IMPORTED_CONFIG_DEBUG DEBUG RELWITHDEBINFO RELEASE MINSIZEREL NONE)
 		endif()
diff --git a/include/transport/Conversation.h b/include/transport/Conversation.h
index ebd026670..f92533127 100644
--- a/include/transport/Conversation.h
+++ b/include/transport/Conversation.h
@@ -23,6 +23,7 @@
 #include <string>
 #include <algorithm>
 #include <list>
+#include <map>
 #include "Swiften/Elements/Message.h"
 #include "Swiften/Elements/Presence.h"
 
diff --git a/libtransport/CMakeLists.txt b/libtransport/CMakeLists.txt
index c7c3cd77f..2e49ca93c 100644
--- a/libtransport/CMakeLists.txt
+++ b/libtransport/CMakeLists.txt
@@ -45,9 +45,9 @@ endif(PROTOBUF_FOUND)
 find_package(CURL)
 
 if(WIN32)
-	target_link_libraries(transport transport-plugin ${PQXX_LIBRARIES} ${CURL_LIBRARIES} ${PQ_LIBRARY} ${MYSQL_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES} ${PROTOBUF_LIBRARY} ${JSONCPP_LIBRARY} psapi.lib bcrypt.lib)
+	target_link_libraries(transport transport-plugin ${PQXX_LIBRARIES} ${CURL_LIBRARIES} ${PQ_LIBRARY} ${MYSQL_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES} ${PROTOBUF_LIBRARY} JsonCpp::JsonCpp psapi.lib bcrypt.lib)
 else()
-	target_link_libraries(transport transport-plugin ${PQXX_LIBRARIES} ${CURL_LIBRARIES} ${PQ_LIBRARY} ${SQLITE3_LIBRARIES} ${MYSQL_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES} ${POPT_LIBRARY} ${PROTOBUF_LIBRARY} ${JSONCPP_LIBRARY})
+	target_link_libraries(transport transport-plugin ${PQXX_LIBRARIES} ${CURL_LIBRARIES} ${PQ_LIBRARY} ${SQLITE3_LIBRARIES} ${MYSQL_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES} ${POPT_LIBRARY} ${PROTOBUF_LIBRARY} JsonCpp::JsonCpp)
 endif()
 
 set_target_properties(transport PROPERTIES
diff --git a/plugin/python/CMakeLists.txt b/plugin/python/CMakeLists.txt
index 60be2eec5..294207e6b 100644
--- a/plugin/python/CMakeLists.txt
+++ b/plugin/python/CMakeLists.txt
@@ -1,5 +1,3 @@
-cmake_minimum_required(VERSION 2.6)
-
 if(PROTOBUF_FOUND)
 	add_custom_command(
 		OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/protocol_pb2.py
diff --git a/spectrum/src/frontends/slack/CMakeLists.txt b/spectrum/src/frontends/slack/CMakeLists.txt
index 676faec78..fb1840631 100644
--- a/spectrum/src/frontends/slack/CMakeLists.txt
+++ b/spectrum/src/frontends/slack/CMakeLists.txt
@@ -1,5 +1,3 @@
-cmake_minimum_required(VERSION 2.6)
-
 file(GLOB SRC *.cpp *.h)
 file(GLOB HEADERS ${CMAKE_SOURCE_DIR}/include/transport/*.h)
 
diff --git a/spectrum/src/frontends/xmpp/CMakeLists.txt b/spectrum/src/frontends/xmpp/CMakeLists.txt
index 36bf81012..b48ee23d0 100644
--- a/spectrum/src/frontends/xmpp/CMakeLists.txt
+++ b/spectrum/src/frontends/xmpp/CMakeLists.txt
@@ -1,5 +1,3 @@
-cmake_minimum_required(VERSION 2.6)
-
 file(GLOB SRC *.cpp *.h)
 file(GLOB HEADERS ${CMAKE_SOURCE_DIR}/include/transport/*.h)
 
diff --git a/spectrum_manager/src/CMakeLists.txt b/spectrum_manager/src/CMakeLists.txt
index 7a720a00d..9fd258c2e 100644
--- a/spectrum_manager/src/CMakeLists.txt
+++ b/spectrum_manager/src/CMakeLists.txt
@@ -1,5 +1,3 @@
-cmake_minimum_required(VERSION 2.6)
-
 file(GLOB SRC *.cpp *.c)
 
 add_executable(spectrum2_manager ${SRC})


Test patch:
diff --git a/tests/libtransport/CMakeLists.txt b/tests/libtransport/CMakeLists.txt
index 3ced0a9eb..5b36e5b83 100644
--- a/tests/libtransport/CMakeLists.txt
+++ b/tests/libtransport/CMakeLists.txt
@@ -1,5 +1,3 @@
-cmake_minimum_required(VERSION 2.6)
-
 file(GLOB SRC *.cpp *.h)
 file(GLOB_RECURSE SWIFTEN_SRC ../include/Swiften/*.cpp)