On Ubuntu 22.04 log4cxx is configured to use the std library for
shared_mutex and shared_lock. Unfortunately this requires C++17,
because otherwise the reverse dependencies of rosconsole fail with an
error like this:
[ 50%] Building CXX object CMakeFiles/resource_retriever.dir/src/retriever.cpp.o
In file included from /usr/include/log4cxx/log4cxx.h:45,
from /usr/include/log4cxx/logstring.h:28,
from /usr/include/log4cxx/level.h:22,
from /root/ws/src/rosconsole/include/ros/console.h:46,
from /root/ws/src/resource_retriever/src/retriever.cpp:33:
/usr/include/log4cxx/boost-std-configuration.h:10:18: error: ‘shared_mutex’ in namespace ‘std’ does not name a type
10 | typedef std::shared_mutex shared_mutex;
| ^~~~~~~~~~~~
/usr/include/log4cxx/boost-std-configuration.h:10:13: note: ‘std::shared_mutex’ is only available from C++17 onwards
10 | typedef std::shared_mutex shared_mutex;
| ^~~
/usr/include/log4cxx/boost-std-configuration.h:12:30: error: ‘shared_lock’ in namespace ‘std’ does not name a template type
12 | using shared_lock = std::shared_lock<T>;
| ^~~~~~~~~~~
/usr/include/log4cxx/boost-std-configuration.h:12:25: note: ‘std::shared_lock’ is only available from C++14 onwards
12 | using shared_lock = std::shared_lock<T>;
| ^~~
This means that if log4cxx requires C++17 everything that links
rosconsole_log4xx also needs to compile with C++17 enabled, which is
why I am setting the CXX_STANDARD and CXX_STANDARD_REQUIRED
properties.
We cannot change this, since this is an upstream package and the
decision is made during configure time. Since this is an option that can
be toggled by the provider of the log4cxx library and since it is not
version dependent the best way I found to figure out whether the option
was set or not is by "inspecting" the
log4cxx/boost-std-configuration.h file.
Unfortunately try_compile has no option to set the
include_directories when using the overload for a single source file
and since we did not include_directoriesLOG4CXX_INCLUDE_DIRS at
this point I created a small cmake project which includes the log4cxx
headers.
On Ubuntu 22.04
log4cxx
is configured to use the std library forshared_mutex
andshared_lock
. Unfortunately this requiresC++17
, because otherwise the reverse dependencies of rosconsole fail with an error like this:This means that if
log4cxx
requiresC++17
everything that linksrosconsole_log4xx
also needs to compile withC++17
enabled, which is why I am setting theCXX_STANDARD
andCXX_STANDARD_REQUIRED
properties.We cannot change this, since this is an upstream package and the decision is made during configure time. Since this is an option that can be toggled by the provider of the
log4cxx
library and since it is not version dependent the best way I found to figure out whether the option was set or not is by "inspecting" thelog4cxx/boost-std-configuration.h
file.Unfortunately
try_compile
has no option to set theinclude_directories
when using the overload for a single source file and since we did notinclude_directories
LOG4CXX_INCLUDE_DIRS
at this point I created a small cmake project which includes thelog4cxx
headers.