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

2008-12-10 Thread James Bigler
There are a couple of things that either you have done wrong or I don't
understand.  This is how I would implement things:

core/CMakeLists.txt

SET(SRC_LIST ConfigHolder.cpp DictItem.cpp Reciter.cpp ForgetCurve.cpp
Task.cpp Dict.cpp Manager.cpp WordList.cpp)
ADD_LIBRARY(core ${SRC_LIST})

ui/CMakeLists.txt

# You can also use CMAKE_SOURCE_DIR if FREERECITE_SOURCE_DIR is the top of
your CMake tree
ADD_DIRECTORIES(${CMAKE_SOURCE_DIR}/core)

ADD_LIBRARY(ui Cui.cpp)
# Tell CMake that ui needs to link agains core
TARGET_LINK_LIBRARIES(ui core)

CMakeLists.txt
ADD_EXECUTABLE(myprogram main.cpp)
# myprogram depends on ui library
TARGET_LINK_LIBRARIES(myprogram ui)

You don't need to use LINK_DIRECTORIES, because CMake knows where core was
built and how to link it against ui.

James

On Tue, Dec 9, 2008 at 3:40 PM, Kermit Mei [EMAIL PROTECTED] wrote:

 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.
 ___
 CMake mailing list
 CMake@cmake.org
 http://www.cmake.org/mailman/listinfo/cmake

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

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

2008-12-09 Thread Kermit Mei

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.
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake