[CMake] ADD_SUBDIRECTORY problem

William A. Hoffman billlist at nycap.rr.com
Fri Feb 17 08:30:46 EST 2006


What was your active target which you did Build?
Make sure it is the ALL_BUILD target.

-Bill


At 03:21 AM 2/17/2006, Prashanth Udupa wrote:
>Hello All,
>
>I have a project in directory XYZ. The directory has the
>following structure
>
>XYZ
>- include
>- sources
>- examples
>  - example_program1
>  - example_program2
>  - example_program3
>- tools
>  - tool1
>
>When I use the following CMakeLists.txt file set on Linux;
>run cmake and make I notice that it works as expected.
>I get a libxyz.a file, xyztool, example_program1, example_program2
>and example_program3 executables. 
>
>However when I use the same CMakeLists.txt file set on 
>Windows XP, and use cmake to generate a Visual Studio 
>6.0 workspace; and select Build -> Build (F7) only xyz.lib
>and xyztool.exe are created. The example programs are 
>not compiled and linked.
>
>I have pasted the structure of my CMakeLists.txt files below.
>I dont understand this difference between Linux and Windows.
>Am I missing something ? Please help.
>
>I have a CMakeLists.txt file in XYZ which looks like this
>--------------
># File: XYZ/CMakeLists.txt
>
>PROJECT(XYZ)
>
>INCLUDE_DIRECTORIES(
>${XYZ_SOURCE_DIR}/include
>)
>
>LINK_DIRECTORIES(
>${XYZ_BINARY_DIR}/
>)
>
>ADD_LIBRARY(xyz STATIC
>... < all the cpp files go here >
>...
>...
>)
>
>ADD_SUBDIRECTORY(tools)
>ADD_SUBDIRECTORY(examples)
>--------------
>
>The tools/CMakeLists.txt looks like this 
>--------------
># File: tools/CMakeLists.txt
>
>ADD_SUBDIRECTORY(tool1)
>--------------
>
>And tool1/CMakeLists.txt looks like this
>--------------
># File: tools/tool1/CMakeLists.txt
>
>ADD_EXECUTABLE(xyztool 
><cpp file list>
>)
>
>TARGET_LINK_LIBRARIES(xyztool xyz)
>--------------
>
>examples/CMakeLists.txt
>The tools/CMakeLists.txt looks like this
>--------------
># File: examples/CMakeLists.txt
>
>ADD_SUBDIRECTORY(example_program1)
>ADD_SUBDIRECTORY(example_program2)
>ADD_SUBDIRECTORY(example_program3)
>--------------
>
>The example_program[123] directories have their CMakeLists.txt similar to 
>the tools/tool1/CMakeLists.txt file.
>
>--------------
># File: examples/example_program1/CMakeLists.txt
>
>ADD_EXECUTABLE(example_program1
><cpp file list>
>)
>
>TARGET_LINK_LIBRARIES(example_program1 xyz)
>--------------
>
>--------------
># File: examples/example_program2/CMakeLists.txt
>
>ADD_EXECUTABLE(example_program2
><cpp file list>
>)
>
>TARGET_LINK_LIBRARIES(example_program2 xyz)
>--------------
>
>
>--------------
># File: examples/example_program1/CMakeLists.txt
>
>ADD_EXECUTABLE(example_program3
><cpp file list>
>)
>
>TARGET_LINK_LIBRARIES(example_program3 xyz)
>--------------
>
>--
>Thanks and Warm Regards,
>Prashanth N Udupa
>
>_______________________________________________
>CMake mailing list
>CMake at cmake.org
>http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list