how to add prebuilt object files to executable in cmake

前端 未结 3 833
死守一世寂寞
死守一世寂寞 2020-11-28 12:30

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

3条回答
  •  离开以前
    2020-11-28 13:26

    You can list object files along sources in add_executable() and addlibrary():

    add_executable(myProgram
       source.cpp
       object.o
    )
    

    The only thing is that you need to use add_custom_command to produce object files, so CMake would know where to get them. This would also make sure your object files are built before myProgram is linked.

提交回复
热议问题