[CMake] [newbie] Do I have to list all .cpp files explicitly?
Harlan Wood
hwood at wgen.net
Fri Nov 17 11:18:15 EST 2006
Hi,
I'm hoping to find a tool that, given a top-level C++ file, will find
and compile and its dependencies (including headers and source files).
I'm brand new to CMake and wondering if I have to list all .cpp files
explicitly?
I have simplified the CMake "hello world" example to demonstrate what I
want: I have a "main" class which includes "hello.h" -- is there a way
to suggest to CMake that it look for hello.cpp in the same location?
Source files below. CMake version 2.4-patch 3 under cygwin.
Thanks for any help!
Harlan
____________________________
# CMakeLists.txt:
# add_executable (helloDemo main.cxx hello.cxx) # succeeds
add_executable (helloDemo main.cxx) # fails with message:
CMakeFiles/helloDemo.dir/main.o:main.cxx:(.text+0x31): undefined
reference to `Hello::Print()'
____________________________
// main.cxx:
#include "hello.h"
int main()
{
Hello hello;
hello.Print();
return 0;
}
____________________________
// hello.h:
#ifndef _hello_h
#define _hello_h
class Hello
{
public:
void Print();
};
#endif
____________________________
// hello.cxx:
#include "hello.h"
#include <stdio.h>
void Hello::Print()
{
printf("Hello, World!\n");
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20061117/c3bccbbe/attachment.htm
More information about the CMake
mailing list