[CMake] How to add a libaray for another libaray?

Kermit Mei kermit.mei at gmail.com
Tue Dec 9 17:40:17 EST 2008


Hello, My project is layout like this:

Linux-cmd$ tree

.
|-- CMakeLists.txt
|-- core
|   |-- CMakeLists.txt
|   |-- ... ... ...
|   |-- (Some source files to implement the internal function.)
`-- ui
  |-- CMakeLists.txt
  |-- ... ... ...
  |-- (Some source files to impliment the UI)
|-- main.cpp


Their dependences is     main.cpp -> ui -> core

What's wrong with my CMakeLists.txt so that the files under the 
directory "ui" can't
find the headers under the directory "core".

1.ui/CMakeLists.txt :

# Make sure the compiler can find include files from our ui library.
INCLUDE_DIRECTORIES(${FREERECITE_SOURCE_DIR}/core)

# Make sure the linker can find the ui library once it is built.
LINK_DIRECTORIES(${FREERECITE_BINARY_DIR}/core)

TARGET_LINK_LIBRARIES(Cui.o core)
ADD_LIBRARY(ui Cui.cpp)



2. core/CMakeLists.txt:

# Set a variable $SRC_LIST to declare the source files.

SET(SRC_LIST ConfigHolder.cpp DictItem.cpp Reciter.cpp ForgetCurve.cpp 
Task.cpp Dict.cpp Manager.cpp WordList.cpp)


# Create a library called "Core" which includes the source files.
# The extension is already found. Any number of sources could be listed 
here.

ADD_LIBRARY(core ${SRC_LIST})

Thanks.


More information about the CMake mailing list