Referencing Visual studio variables from cmake -
i'm using cmake generate visual c++ project , want add visual studio variable include path.
for normal variables hardcoded path can include_directories(pathtofolderiwanttoinclude)
however want same thing variable visual studio knows about. $(kit_shared_includepath)
i tried doing include_directories($(kit_shared_includepath))
however yields c:\path\to\my\project\$(kit_shared_includepath). tried storing value in variable , using variable instead didn't work either. how prevent cmake prepending current path onto include path?
the problem cmake doesn't have straight way pass relative path in include_directories
, have not preppended value of cmake_current_source_dir
variable(setting nothing doesn't either). given vs macros expand absolute paths try circumvent cmake guards providing vs macro follows:
include_directories("\\\\?\\$(kit_shared_includepath)")
it trick because absolute path sure , correct path added additional include path compiler. alas, in 2016 ms tool, msvc compiler, doesn't know how handle paths ms introduced many years ago. way of doing things people lives in better time when msvc knows how handle extended-length paths.
but not done yet. have 1 more way circumvent contorversial cmake behavior: can use generator expressions. 1 can use @ top of list:
include_directories($<1:$(kit_shared_includepath)>)
that way cmake doesn't stand chance , has comply — correct line gets added list of additional includes. has side effect: cmake starts complaining(gives warning, not error) relative path in include_directories
command can shut either following command:
cmake_policy(set cmp0021 old)
or run cmake following parameter each time: -wno-dev
. latter 1 disable warnings consider first option preferable in case.
upd: found easier way achieve same. add following line cmake file:
add_definitions(-i$(kit_shared_includepath))
Comments
Post a Comment