[CMake] include file

Philip Lowman philip at yhbt.com
Sun Aug 30 07:32:38 EDT 2009


On Sat, Aug 29, 2009 at 8:01 PM, Alex H <aditya15417 at hotmail.com> wrote:

>  I have a test.cpp file and the test file needs to be linked with another
> .h file... they are all in the same directory, however when I run the
> Makefile that is generated by CMake, it shows this error:
> CMakeFiles/bcoin.dir/test.cpp.o: In function `main':
> test.cpp:(.text+0xd7): undefined reference to `Exp::Exp(double)'
> test.cpp:(.text+0x114): undefined reference to `Exp::execute()'
>
> I think I need to add some more command to my CMakeLists.txt, how can I do
> this??
>


If the Exp class is contained in a library, use
target_link_libraries(<test_target_name> <library_name_with_Exp_in_it>)
If the Exp class is not contained in a library, add it to the list of source
files, use add_executable(<test_target_name> test.cpp <Exp_cpp_filename>)


-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090830/3ea39819/attachment-0001.htm>


More information about the CMake mailing list