Whitelist NO_SYSTEM_FROM_IMPORTED properties for INTERFACE IMPORTED targets
According to the documentation (https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#imported-targets), the only allowed target properties for INTERFACE IMPORTED targets are:
The properties permitted to be set on or read from an INTERFACE library are:
Properties matching INTERFACE_* Built-in properties matching COMPATIBLE_INTERFACE_* EXPORT_NAME IMPORTED NAME Properties matching MAP_IMPORTED_CONFIG_*
My issue is that GCC does more than just hidding compiler warnings for system includes. It might also treat them as if they were wrapped around extern "C"
blocks as explained here: https://gcc.gnu.org/onlinedocs/cpp/System-Headers.html
I am using a gcc based toolchain from Atollic (6.0.0) on Windows. In my embedded ARM C++ project, when I try to use boost (found via a find_package(Boost)
), I get thousands of "template with C linkage" errors as soon as I include a boost header:
#include <boost/circular_buffer.hpp>
int main(int argc, char** argv)
{
auto buffer = boost::circular_buffer<float>{100};
(void)buffer;
return 0;
}
In order to work around that issue, I would like to be able to use, in my CMakeLists.txt:
find_package(Boost 1.62 REQUIRED)
set_target_properties(Boost::boost PROPERTIES NO_SYSTEM_FROM_IMPORTED true)
But this is not allowed. Instead I have to do:
set(CMAKE_NO_SYSTEM_FROM_IMPORTED true)
find_package(Boost 1.62 REQUIRED)
Which leaks the CMAKE_NO_SYSTEM_FROM_IMPORTED to all targets instead of just boost.