CMake generates -isystem /usr/include and breaks compilation
I'm working on this project, and I cannot compile it due to the error:
/usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_DATE_TIME_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_IOSTREAMS_DYN_LINK -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_REGEX_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_TEST_DYN_LINK -DBOOST_THREAD_DYN_LINK -DFRANKA_EMULATOR=franka_emulator -DFRANKA_EMULATOR_VERSION_MAJOR=1 -DFRANKA_EMULATOR_VERSION_MINOR=0 -DFRANKA_EMULATOR_VERSION_PATCH=0 -DFRANKA_VERSION_MAJOR=1 -DFRANKA_VERSION_MINOR=0 -DFRANKA_VERSION_PATCH=0 -DLIBBULLET_VERSION=3.17 -DLIBBULLET_VERSION_GT_282 -Dfranka_emulator_plugin_EXPORTS -I/usr/include/gazebo-11 -I/usr/include/bullet -I/usr/include/sdformat-9.5 -I/usr/include/ignition/math6 -I/usr/include/OGRE -I/usr/include/OGRE/Terrain -I/usr/include/OGRE/Paging -I/usr/include/ignition/transport8 -I/usr/include/ignition/msgs5 -I/usr/include/ignition/common3 -I/usr/include/ignition/fuel_tools4 -I/mnt/D/Project/franka_emulator/include -I/usr/include/eigen3 -I/usr/include/sdformat-9.5/sdf/.. -I/usr/include/ignition/cmake2 -I/usr/include/uuid -isystem /usr/include -fPIC -pthread -I/usr/include/uuid -MD -MT CMakeFiles/franka_emulator_plugin.dir/source/emulator/plugin.cpp.o -MF CMakeFiles/franka_emulator_plugin.dir/source/emulator/plugin.cpp.o.d -o CMakeFiles/franka_emulator_plugin.dir/source/emulator/plugin.cpp.o -c /mnt/D/Project/franka_emulator/source/emulator/plugin.cpp
In file included from /usr/include/c++/11.1.0/ext/string_conversions.h:41,
from /usr/include/c++/11.1.0/bits/basic_string.h:6594,
from /usr/include/c++/11.1.0/string:55,
from /usr/include/c++/11.1.0/bits/locale_classes.h:40,
from /usr/include/c++/11.1.0/bits/ios_base.h:41,
from /usr/include/c++/11.1.0/ios:42,
from /usr/include/c++/11.1.0/ostream:38,
from /mnt/D/Project/franka_emulator/source/emulator/../../include/franka_emulator/emulator/../robot_state.h:6,
from /mnt/D/Project/franka_emulator/source/emulator/../../include/franka_emulator/emulator/robot_protocol.h:2,
from /mnt/D/Project/franka_emulator/source/emulator/../../include/franka_emulator/emulator/shared.h:3,
from /mnt/D/Project/franka_emulator/source/emulator/../../include/franka_emulator/emulator/plugin.h:1,
from /mnt/D/Project/franka_emulator/source/emulator/plugin.cpp:1:
/usr/include/c++/11.1.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
75 | #include_next <stdlib.h>
Known issue, there were some bigfixes, but it is still happening. The reason of the issue is that CMake generates -isystem /usr/include
option. Probably because someone in Gazebo decided to make target_include_directories(/usr/include)
without SYSTEM
keyword. Could you please make CMake more foolproof?
I used to decide this issue with -DCMAKE_NO_SYSTEM_FROM_IMPORTED=FALSE
option, but it is not working this time.
I am using Arch Linux and cmake 3.22.1. On the second PC I have Ubuntu 20.04 and cmake 3.16 and everything works alright.
Thank you