[CMake] Problem accessing variables and libraries in root, when they have been set in a subdirectory

Eugen Funk eugen.funk at gmail.com
Sat May 23 10:12:46 EDT 2009


Hello folks,
since I am very new to cmake, it is sometimes difficult for me to understand
how things work here.
e.g. I have difficulties to access already created libraries in a
subdirectory.
Here is the structure of my project:

root
  src
    core
  tests
    core

Every directory contains a CMakeLists.txt.

Here some excerpts:

*root:*
add_subdirectory(src)

*root/src:*
add_subdirectory(core)

*root/src/core:*
FILE(GLOB srcs_cpp ./*.cpp)
ADD_LIBRARY(corelib ${srcs_cpp})

*rot/tests/core:*
FILE(GLOB srcs_cpp ./*.cpp)
ADD_EXECUTABLE(core_test_suite  ${srcs_cpp})
ADD_DEPENDENCIES(core_test_suite corelib)

The bad result is that the linker throws an "*undefined reference" *error
while trying to link to a class found in library *core*.
*undefined reference to `viseval::core::CMatlabVector::CMatlabVector*

I ran some tests on variables and found out that:
if in *root/src/core* I use
SET(VAR1 "somevalue")
then I cannot access it in root or any other structures using
MESSAGE(STATUS "VAR1=${VAR})

How can i solve the problem? is this a bug or didnt I understand something?

thanks a lot to all ideas and hints!

Regards
Eugen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090523/3cdca3dc/attachment.htm>


More information about the CMake mailing list