[CMake] How to get a variable that is defined in another
CMakeLists.txt file
David Cole
david.cole at kitware.com
Tue Dec 19 13:37:41 EST 2006
DEFINED should be used with the variable name itself, not the value of the
variable:
IF(NOT DEFINED PROJECT_A_LIB_NAME)
Scratch the ${} and see what happens...
On 12/19/06, Mike Jackson <mike.jackson at imts.us> wrote:
>
> I have couple of projects, lets call them A and B. In project A I
> "SET" a variable as follows:
>
> SET (PROJECT_A_LIB_NAME MyLib)
>
> then use that further down A's cmake file in the ADD_LIBRARY() function.
>
> Now in Project B I would like to automagically be able to read the
> PROJECT_A_LIB_NAME variable. I have added the "ADD_SUBDIRECTORY
> (PATH_TO_A BIN_DIR) to B's CMakeLists.txt file and then I tried just
> using the variable like usual ( ${PROJECT_A_LIB_NAME} ) but it is
> undefined.
>
> IF (NOT DEFINED ${PROJECT_A_LIB_NAME} )
> MESSAGE (FATAL_ERROR "Ahh.. this is a problem")
> ENDIF (NOT DEFINED ${PROJECT_A_LIB_NAME} )
>
> So.. is there a way to get the variable value from one CMakeLists.txt
> file to another?
>
> Thanks for any help.
> --
> Mike Jackson Senior Research Engineer
> Innovative Management & Technology Services
>
>
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20061219/74c226d7/attachment.htm
More information about the CMake
mailing list