How to compile additional source files in cmake after the build process

佐手、 提交于 2019-12-01 18:53:05

I'm not familiar with Pro*C, but it looks like you're mixing together the two different versions of add_custom_command.

The first version add_custom_command(OUTPUT ...) is used to generate a file which is then added as a dependency of another CMake target. When that target is built, the custom command is executed first in order to generate the output file.

The second version add_custom_command(TARGET ...) is used to define a pre-build, pre-link or post-build command; one which does not necessarily create a file, but which executes in conjunction with building the associated target.

If you only have one target which depends on the output of Pro*C, then the first version is probably your best bet:

add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/connection.c
    COMMAND ${PROC} iname=${PROJECT_SOURCE_DIR}/connection.proc SQLCHECK=SYNTAX
        MODE=ANSI IRECLEN=255 ORECLEN=255
        ONAME=${PROJECT_SOURCE_DIR}/connection.c)
add_executable(myproj ${PROJECT_SOURCE_DIR}/connection.c <other sources>)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!