How to Link in an Object File in Cmake

Asked by Ted Kord

I have an object file generated by nvcc, which I'd like to link in during compilation of the executable. I've tried adding it to each of the commands below with no success for any:

add_executable(.... foo.o)

set(CMAKE_CXX_FLAGS "....... foo.o")

target_link_libraries(.... foo.o)

Is there a way to do this?

Ted

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Ted Kord
Solved:
Last query:
Last reply:
Revision history for this message
Johannes Ring (johannr) said :
#1

I'm a little surprised that it didn't work to add the object file to the list of sources in the add_executable command. Have you tried to add it to CMAKE_CMAKE_EXE_LINKER_FLAGS or similar? Here is an answer to a similar question on the CMake mailing list:

http://www.cmake.org/pipermail/cmake/2008-November/025541.html

Revision history for this message
Ted Kord (teddy-kord) said :
#2

Hi Johannes

It actually works by adding the object file to the list of sources in the add_executable command. I just forgot that on OSX, I had to switch compilers as only gcc 4.2 is supported and I was using 4.5.

Thanks.

Ted