Issue
I have an add_custom_target
that triggers a make for a project (that project does not use cmake!) and generates an object file. I would like to add this object file to an executable target in my project's cmake. Is there a way to do this?
Solution
SET(OBJS
${CMAKE_CURRENT_SOURCE_DIR}/libs/obj.o
)
ADD_EXECUTABLE(myProgram ${OBJS} <other-sources>)
SET_SOURCE_FILES_PROPERTIES(
${OBJS}
PROPERTIES
EXTERNAL_OBJECT true
GENERATED true
)
That worked for me. Apparently one must set these two properties, EXTERNAL_OBJECT and GENERATED.
Answered By - mkmostafa Answer Checked By - David Goodson (WPSolving Volunteer)