<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<br>
<br>
<blockquote cite="mid200612210021.40832.axel.roebel@ircam.fr"
type="cite">
<pre wrap="">On Wednesday 20 December 2006 23:38, Mike Jackson wrote:
</pre>
<blockquote type="cite">
<pre wrap="">So in Project B's CMakeLists.txt file I have:
....
SUBDIRS(${PROJECT_SOURCE_DIR}/Project_A)
....
ADD_EXECUTABLE( MyProgram ${SOURCES})
TARGET_LINK_LIBRARIES( MyProgram ${A_LIB_OUTPUT_NAME})
</pre>
</blockquote>
<pre wrap=""><!---->
As far as I understand it variables defined in the main directory (=CMakeLists.txt) will be defined
in the sub directory (=CMakeLists.txt), BUT, variables defined in sub directories will NOT be
defined in the main directory This creates scopes for variables like in most other programming languages.
so this should do it. (It does for me, however I use ADD_SUBDIRECTORY)
SUBDIRS(${PROJECT_SOURCE_DIR}/Project_A)
GET_DIRECTORY_PROPERTY(outvar DIRECTORY ${PROJECT_SOURCE_DIR}/Project_A DEFINITION A_LIB_OUTPUT_NAME)
ADD_EXECUTABLE( MyProgram ${SOURCES})
TARGET_LINK_LIBRARIES( MyProgram ${outvar})
</pre>
</blockquote>
>From the man pages:<br>
<br>
SUBDIRS<br>
Add a list of subdirectories to the build.<br>
<br>
SUBDIRS(dir1 dir2 ...[EXCLUDE_FROM_ALL exclude_dir1<br>
exclude_dir2 ...] [PREORDER] )<br>
<br>
Add a list of subdirectories to the build. <b>The
ADD_SUBDIRECTORY<br>
command should be used instead of SUBDIRS although SUBDIRS will<br>
still work.<br>
<br>
</b>So you should not continue to use SUBDIRS and use ADD_SUBDIRECTORY
as Axel does.<br>
<br>
-Sylvain<br>
</body>
</html>