CMake: Access variables across sub directories -


i have 2 sub directories root on 1 has line:

 set(${libname}_publicheaders      localizeresource.h  ) 

i want able access variable other subdirectory. how can this?

@joakimgebart's answer more common way go this. however, can use get_directory_property directly within second subdir achieve you're after.

i see in comment, you've used ${lib_name}_publicheaders, in question have ${libname}_publicheaders. cause of problems, since command should work this:

get_directory_property(myvar     directory ${cmake_source_dir}/abc     definition ${libname}_publicheaders) 

however, there couple of provisos:

  1. this has called after setting variable in subdir. i.e. you'd have ensure add_subdirectory(abc) called before add_subdirectory 1 used.
  2. if libname set inside same subdir (abc), you'll need retrieve value first.

so, while less common solution, has advantage doesn't "pollute" global namespace subdir-specific variables - works subdir referring subdir.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -