Presence of CMake include_directories SYSTEM dirs prefix with equal sign (=)

Is there a way for CMake include_directories include the system directory prefix with an equal sign ( = )? So that I can have the gcc prefix of the associated dirs with the -isysroot flag for cross-compiling.

When I try to include a path with the equals ( = ) prefix, it assumes a relative path and prefixes with the current source path:

 include_directories(AFTER SYSTEM "=/usr/include") 

results:

 -isystem /root/opencv-2-4-9/opencv/modules/highgui/=/usr/include/ 

what i expect:

 -isystem=/usr/include/ 
0
source share
2 answers

I checked the source code of CMake (both 2.8.12.2 and 3.0.0); CMake seems to add the current source directory of all paths that don't start with '/' on windowless systems.

Only exception is the expression of the generator. If the path starts with "$ <", then it skips the path prefix and not the prefix after evaluating the generator expression. therefore

 include_directories(AFTER SYSTEM "$<1:=>/usr/include") 

generates

 -isystem =/usr/include/ 

This seems to work, at least for CMake 3.0.0. Of course, you must set CMAKE_SYSROOT for gcc for the prefix with the correct path.

 set(CMAKE_SYSROOT /usr/arm-linux-gnueabi) 
+2
source

Define it in one command:

 set_target_properties(<targetname> PROPERTIES COMPILE_FLAGS "-isystem=/usr/include/") 
0
source

All Articles