[CMake] Linking object file with executable

Dmytro Ovdiienko dmitriy.ovdienko at gmail.com
Wed May 20 08:22:13 EDT 2009


Hi Ankit.


Did you try TARGET_LINK_LIBRARIES?

TARGET_LINK_LIBRARIES( myexe ${myobj} )

2009/5/19 ankit jain <ankitguddu at gmail.com>

> Hi all,
>
> My Cmakelists contains:
>
> set(myobj  ${CMAKE_CURRENT_SOURCE_DIR}/../objfolder/myfile.obj)
> add_executable(myexe  main.c ${myobj})
>
> This myfile.obj object file is generated while building objfolder before
> creating this executable
>
> Now on building this executable i got a warning:
>
> main.obj: warning: earlier declaration of a function f1() found in
> myfile.obj: second definition ignored..
>
> This means it is taking the f1() function from myfile.obj but i want f1()
> function to be taken from main.obj..
>
> What to do?
>
> Also it is imp. to link this myfile.obj file to myexe  executable since it
> depends on other functions of this object file..
> So this object file has to be there.
> Just tell me how function f1() can be taken from main.c rahter than from
> myfile.obj evenif it still gives warning as:
>
> myfile.obj:warning: earlier definition of function f1() found in main.c
> (since if it takes f1() from main.c): second def. ignored
>
> Regards-
> Ankit Jain
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090520/9027de51/attachment.htm>


More information about the CMake mailing list