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

Alexander Neundorf a.neundorf-work at gmx.net
Sun Nov 5 06:30:45 EST 2006


-------- Original-Nachricht --------
Datum: Sun, 5 Nov 2006 10:44:55 +0100 (MET)
Von: Timo Rumland <cr at olympclan.de>
An: cmake at cmake.org
Betreff: Re: [CMake] Please help with a simple Example, VS 8 project

> Hello Alex,
> 
> > 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.
> 
> thanks, I will just use "hello" as the executable name.
> 
> > 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...)
> 
> Well, I think that's the problem. I don't want to habe two
> executables, I just want to compile "hello.cpp" and "print.cpp" and
> link them together to one executable, that is "./hello".
> 
> Maybe my CMakeLists.txt file is wrong for the folder where "print.cpp"
> and "print.h" is placed (the output dir)? I just want to tell cmake,
> that there is a subdir (output) with two files (print.*) in it that
> must be compiled. At the end, the files must be linked to create only
> one executable out of it.


Ah, ok.
So just list all source files you need in the add_executable() call. It doesn't matter whether they are in different subdirectories. You only have to care about the include directories.

add_executable(hello print.cpp src/foo.cpp blah/blub.cpp)

etc.

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