On Dec 20, 2006, at 3:15 PM, Axel Roebel wrote:

On Wednesday 20 December 2006 17:27, Mike Jackson wrote:
That did not seem to work either. Basically I am trying to set a
place where we can set the names of the libraries and apps and have
those found by other projects that depend on these base libraries.

   I have noticed that if you "INCLUDE(${PROJECT_SOURCE_DIR}/
FindHDF.cmake)" a file, in this case our module to find HDF, then
those variables are found..  So I guess I could have a Names.cmake
file where these variables are defined and then include that file in
each CMakeLists.txt file for the project..

Kinda seems like a heavy handed way to do this..
 For a single variable  PORTAUDIO_LINK_LIBRARIES)
defined in a sub directory "portaudio"
this definitely works for me.

 GET_DIRECTORY_PROPERTY(outvar DIRECTORY portaudio
DEFINITION PORTAUDIO_LINK_LIBRARIES)

If you use DEFINITIONS as suggested earlier here you get outvar to contain a text with all definitions made in the sub dir which is not what you want.

Note, that with get_directory_property the output variable
will always be set - to an empty string if the the variable
in the directory is not set. So testing for undefined
state is probably not working with this scheme.

You can however test for empty values
and -NOTFOUND and the like.

cheers

--
Axel Roebel
IRCAM Analysis/Synthesis Team
Phone: ++33-1-4478 4845 | Fax: ++33-1-4478 1540

Well I am just NOT getting this.. So let us start over. I think there was some confusion about the IF(). I had that in there for simple debugging. I do not really need it.

I have Project A and Project B. Both of their directories are at the same level in the file system. Project A builds a library which is needed in Project B. This part is not the problem. The problem is that we may need to change the name of the Library produced by Project A. So in Project A's CMakeLists.txt file I have the following:

SET (A_LIB_OUTPUT_NAME "MyGreatLibrary")
And I use that variable farther down in the same CMakeLists.txt file such as:
ADD_LIBRARY( ${A_LIB_OUTPUT_NAME} ${SOURCES} )

NOW.. on to Project B's CMakeLists.txt file. As I said, Project B is going to link against Project A's library but I would like to be able to use ${A_LIB_OUTPUT_NAME} in Project B's CMakeLists.txt file.

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})

In my situation, ${A_LIB_OUTPUT_NAME} is never built because the variable ${A_LIB_OUTPUT_NAME} is empty. How do I get the value for A_LIB_OUTPUT_NAME to be what it is in Project A?

Sorry for any confusion I created earlier for having a poorly commented example. I hope this explains better what I am trying to do. I would like it this way so that we only have to change the name of Project A's library in ONE place.. at the moment I have it set in _every_ CMakeLists.txt file that I use it in.. which is error prone.

This is on CMake 2.4.3 and OS X 10.4.8.
--
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services



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

Reply via email to