Re: [CMake] Pass variables to sub directory CMakeLists.txt

2008-02-21 Thread Oliver Dole
Hello,

On 2/21/08, Vandenbroucke Sander [EMAIL PROTECTED] wrote:
 Hi,

  I want to pass a variable to CMakeLists.txt's in sub directories:

  Top directory CMakeLists.txt:
  set( VAR1  )
  add_subdirectory (subdir1)
  add_subdirectory (subdir2)

  Each subdir CMakeLists.txt:

  ...
  set( VAR1 ${VAR1} extend_var1 )
  ...

  I use VAR1 later on in the linker.

  How can I make this work?

See this thread form yesterday for your answer ;)
http://www.cmake.org/pipermail/cmake/2008-February/019986.html

Regards,

  Kind regards,
  Sander.

  ___
  CMake mailing list
  CMake@cmake.org
  http://www.cmake.org/mailman/listinfo/cmake



-- 
Olivier DOLE
Pleyo
Software Engineer
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Pass variables to sub directory CMakeLists.txt

2008-02-21 Thread Alan W. Irwin

On 2008-02-21 08:25+0100 Vandenbroucke Sander wrote:


Hi,

I want to pass a variable to CMakeLists.txt's in sub directories:

Top directory CMakeLists.txt:
set( VAR1  )
add_subdirectory (subdir1)
add_subdirectory (subdir2)

Each subdir CMakeLists.txt:

...
set( VAR1 ${VAR1} extend_var1 )
...

I use VAR1 later on in the linker.

How can I make this work?


The reason why this does not work in the present form is you are attempting
to pass VAR1 up from subdir1 to top-level, before passing it down again to
subdir2 from the top-level.  Passing variables down is fine, but passing
variables from subdirectories to their parent normally does not occur with
CMake.


From recent discussion on this list you should use the

GET_DIRECTORY_PROPERTY command to pass variable information to parent
directories.  So instead of the above use the following (subject to some
uncertainty since I have no practical experience with this method).

Top directory CMakeLists.txt:
set( VAR1  )
add_subdirectory (subdir1)
get_directory_property(VAR1 DIRECTORY subdir1 VARIABLES VAR1)
add_subdirectory (subdir2)
get_directory_property(VAR1 DIRECTORY subdir2 VARIABLES VAR1)
...

Anyhow, you get the general idea subject to some uncertainty on my part of
what the exact syntax for GET_DIRECTORY_PROPERTY should be.  Perhaps I am
just too sleepy at this time in the morning, but that particular
documentation seems to be a bit unclear to me.  So if the above syntax
doesn't work (which you can confirm by using the MESSAGE command), then you
may have to adjust it a bit.

Good luck.

Alan
__
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__

Linux-powered Science
__
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


[CMake] Pass variables to sub directory CMakeLists.txt

2008-02-20 Thread Vandenbroucke Sander
Hi,

I want to pass a variable to CMakeLists.txt's in sub directories:

Top directory CMakeLists.txt:
set( VAR1  )
add_subdirectory (subdir1)
add_subdirectory (subdir2)

Each subdir CMakeLists.txt:

...
set( VAR1 ${VAR1} extend_var1 )
...

I use VAR1 later on in the linker.

How can I make this work?

Kind regards,
Sander.

___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake