[CMake] Include *.cpp files from external directory
Marc Kammer
mkammer at techfak.uni-bielefeld.de
Wed Jan 20 04:02:11 EST 2010
Hello,
I have a seemingly easy problem.
I develop a program and try to include some source code file (also developed
by me) that lies in an external directory:
first dir:
/homes/myName/program1/src/
->theProg.cpp
second dir:
/homes/myName/program2/src/
->theOtherProg.hpp
->theOtherProg.cpp
Therefore I added
INCLUDE_DIRECTORIES( /homes/myName/program2/src/ )
and
ADD_LIBRARY(ObjectManager STATIC /homes/myNameprogram2/src/theOtherProg.cpp)
to CMakeLists.txt in the "first dir".
If I now try to compile theProg.cpp I get the following error message:
-- Build files have been written to: /homes/myName/program1/src/make
[ 50%] Built target theOtherProg
Scanning dependencies of target yarpy
Linking CXX executable yarpy
CMakeFiles/yarpy.dir/theProg.cpp.o: In function
`__static_initialization_and_destruction_0(int, int)':
theProg.cpp:(.text+0x1d): undefined reference to
`theOtherProg::theOtherProg()'
CMakeFiles/yarpy.dir/theProg.cpp.o: In function `__tcf_0':
theProg.cpp:(.text+0x6a): undefined reference to
`theOtherProg::~theOtherProg()'
collect2: ld returned 1 exit status
make[2]: *** [yarpy] Error 1
make[1]: *** [CMakeFiles/yarpy.dir/all] Error 2
make: *** [all] Error 2
I've searched the whole internet, the documentation, the emailarchive, and so
on and it seems that this topic has been discussed several times but I was
not able to solve my problem.
Btw. if I copy theOtherProg.cpp into the "first dir" then the compilation
finishes.
Any suggestions or ideas?
Thank you in advance,
Marc
More information about the CMake
mailing list