Is there a way to have CMake include_directories
include the system directory prefix with equals(=
) character? So that I can have gcc prefix the associated dirs with -isysroot
flag for the cross compilation.
When I try to include the path with equals(=
) prefix, assumes relative path and prefixes with current source path:
include_directories(AFTER SYSTEM "=/usr/include")
results:
-isystem /root/opencv-2-4-9/opencv/modules/highgui/=/usr/include/
what I expect is:
-isystem=/usr/include/
I checked the source code of CMake (both 2.8.12.2 and 3.0.0); It seems CMake adds current source directory all paths which are not starting with '/' in non windows systems.
Only exception is generator expressions. If path starts with "$<", then it skips prefixing the path and does not prefix it after evaluation of the generator expression. Therefore
include_directories(AFTER SYSTEM "$<1:=>/usr/include")
generates
-isystem =/usr/include/
This seems to be working at least for CMake 3.0.0. Ofcourse you should set CMAKE_SYSROOT for gcc to prefix with proper path.
set(CMAKE_SYSROOT /usr/arm-linux-gnueabi)
Set it together in one command:
set_target_properties(<targetname> PROPERTIES COMPILE_FLAGS "-isystem=/usr/include/")