Documentation of NO_SYSTEM_FROM_IMPORTED is misleading
EDIT: The problems reported here and in #16443 (closed) turned out to be due to using the property incorrectly. The documentation of the NO_SYSTEM_FROM_IMPORTED
does not clearly state that it is meant to be set on the consumers of imported targets.
The original report follows.
Since #16443 (closed) was fixed, it used to be possible to set_target_properties(<target> PROPERTIES NO_SYSTEM_FROM_IMPORTED true)
on an IMPORTED target.
However, this seems to not be actually working anymore (tried with cmake 3.8 and 3.9).
When building the following main.cpp
with the CMakeLists.txt
below, one can see the build command uses -isystem
instead of -I
for boost:
main.cpp
:
#include <boost/optional.hpp>
int main(int argc, char** argv)
{
boost::optional<int> opt;
return 0;
}
CMakeLists.txt
:
cmake_minimum_required(VERSION 3.9)
project(no-system-from-imported)
find_package(Boost 1.62 REQUIRED)
set_target_properties(Boost::boost PROPERTIES NO_SYSTEM_FROM_IMPORTED true)
add_executable(main main.cpp)
target_link_libraries(main Boost::boost)
Build command:
cmake -DBOOST_ROOT=/tmp/boost_1_64_0_src /tmp/no_system_from_imported`
VERBOSE=1 make
Outputs (notice -isystem
instead of -I
:
...
/usr/lib64/ccache/c++ -isystem /tmp/boost_1_64_0_src -o CMakeFiles/main.dir/main.cpp.o -c /tmp/no_system_from_imported/main.cpp
...
Edited by Brad King