[CMake] Please help with a simple Example, VS 8 project

Alexander Neundorf a.neundorf-work at gmx.net
Sat Nov 4 18:02:39 EST 2006


-------- Original-Nachricht --------
Datum: Sat, 4 Nov 2006 21:42:07 +0100 (MET)
Von: Timo Rumland <cr at olympclan.de>
An: cmake at cmake.org
Betreff: [CMake] Please help with a simple Example, VS 8 project

> Hallo,
> 
> I'm fairly new to cmake. I have set up a small source tree for testing
> purposes and I try to generate a Visual Studio 8 project with cmake.
> 
> The file system looks like this:
> 
> Source-root is "src" with the following files:
> 
>   hello.cpp
>   CMakeLists.txt
> 
> In the "src" dir, there is one subdir "output" with the following
> files:
> 
>   print.cpp
>   print.h
>   CMakeLists.txt
> 
> 
> So I habe only two CMakeLists.txt files. The hello.cpp is my main
> application that uses a function declared and defined in
> "output/print.cpp" and "output/print.h".
> 
> The content of the first cmake input file is:
> 
>   PROJECT(HelloWorld)
>   ADD_SUBDIRECTORY(output)
>   ADD_EXECUTABLE(hello.exe hello.cpp)
> 
> The content of the second cmake input file (in the "output" dir) is:
> 
>   ADD_EXECUTABLE(hello.exe print.cpp)
> 
> 
> When I run cmake, it generates a Visual Studio 8 project, but in that
> project, the file "print.cpp" is missing.
> 
> What have I done wrong?

I see two things which might cause problems:
in the add_executable() calls you should not use any system specific prefix/suffix, i.e. use only "hello" instead of "hello.exe". Otherwise on UNIX also a hello.exe will be created while on Windows you might even end up with a hello.exe.exe maybe.

And it is no good idea to create to executables (targets) with the same name. So just name your two executables differently. If the resulting binaries really have to have the same name, use SET_TARGET_PROPERTIES(...OUTPUT_NAME...)

Bye
Alex

-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer


More information about the CMake mailing list