There are a couple of things that either you have done wrong or I don&#39;t understand.&nbsp; This is how I would implement things:<br><br>core/CMakeLists.txt<br><br>SET(SRC_LIST ConfigHolder.cpp DictItem.cpp Reciter.cpp ForgetCurve.cpp Task.cpp Dict.cpp Manager.cpp WordList.cpp)<br>

ADD_LIBRARY(core ${SRC_LIST})<br><br>ui/CMakeLists.txt<br><br># You can also use CMAKE_SOURCE_DIR if FREERECITE_SOURCE_DIR is the top of your CMake tree<br>ADD_DIRECTORIES(${CMAKE_SOURCE_DIR}/core)<br><br>ADD_LIBRARY(ui Cui.cpp)<br>
# Tell CMake that ui needs to link agains core<br>TARGET_LINK_LIBRARIES(ui core)<br><br>CMakeLists.txt<br>ADD_EXECUTABLE(myprogram main.cpp)<br># myprogram depends on ui library<br>TARGET_LINK_LIBRARIES(myprogram ui)<br><br>
You don&#39;t need to use LINK_DIRECTORIES, because CMake knows where core was built and how to link it against ui.<br><br>James<br><br><div class="gmail_quote">On Tue, Dec 9, 2008 at 3:40 PM, Kermit Mei <span dir="ltr">&lt;<a href="mailto:kermit.mei@gmail.com">kermit.mei@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello, My project is layout like this:<br>
<br>
Linux-cmd$ tree<br>
<br>
.<br>
|-- CMakeLists.txt<br>
|-- core<br>
| &nbsp; |-- CMakeLists.txt<br>
| &nbsp; |-- ... ... ...<br>
| &nbsp; |-- (Some source files to implement the internal function.)<br>
`-- ui<br>
&nbsp;|-- CMakeLists.txt<br>
&nbsp;|-- ... ... ...<br>
&nbsp;|-- (Some source files to impliment the UI)<br>
|-- main.cpp<br>
<br>
<br>
Their dependences is &nbsp; &nbsp; main.cpp -&gt; ui -&gt; core<br>
<br>
What&#39;s wrong with my CMakeLists.txt so that the files under the directory &quot;ui&quot; can&#39;t<br>
find the headers under the directory &quot;core&quot;.<br>
<br>
1.ui/CMakeLists.txt :<br>
<br>
# Make sure the compiler can find include files from our ui library.<br>
INCLUDE_DIRECTORIES(${FREERECITE_SOURCE_DIR}/core)<br>
<br>
# Make sure the linker can find the ui library once it is built.<br>
LINK_DIRECTORIES(${FREERECITE_BINARY_DIR}/core)<br>
<br>
TARGET_LINK_LIBRARIES(Cui.o core)<br>
ADD_LIBRARY(ui Cui.cpp)<br>
<br>
<br>
<br>
2. core/CMakeLists.txt:<br>
<br>
# Set a variable $SRC_LIST to declare the source files.<br>
<br>
SET(SRC_LIST ConfigHolder.cpp DictItem.cpp Reciter.cpp ForgetCurve.cpp Task.cpp Dict.cpp Manager.cpp WordList.cpp)<br>
<br>
<br>
# Create a library called &quot;Core&quot; which includes the source files.<br>
# The extension is already found. Any number of sources could be listed here.<br>
<br>
ADD_LIBRARY(core ${SRC_LIST})<br>
<br>
Thanks.<br>
_______________________________________________<br>
CMake mailing list<br>
<a href="mailto:CMake@cmake.org" target="_blank">CMake@cmake.org</a><br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br>