我的项目结构:
/external-source-generating-tool
/external-source-generating-tool/CMakeLists.txt
/external-source-generating-tool/*.cpp
/src
/src/CMakeLists.txt
/src/*.cpp
/CMakeLists.txt
的CMakeLists.txt :
add_subdirectory(external-source-generating-tool)
add_subdirectory(src)
/src/CMakeLists.txt :
add_custom_command(OUTPUT generated-source.cpp
COMMAND external-source-generating-tool -o generated-source.cpp
MAIN_DEPENDENCY external-source-generating-tool
COMMENT "Generating...")
add_executable(my-app source1.cpp generated-source.cpp)
问题是/src/CMakeLists.txt
找不到external-source-generating-tool
:
错误:找不到源文件:
外部源产生的工具
尝试扩展.c .C .c ++ .cc .cpp .cxx .m .M .mm .h .hh .h ++ .hm .hpp .hxx .in .txx
如何从external-source-generating-tool
正确拨打/src/CMakeLists.txt
?
答案 0 :(得分:1)
问题在于MAIN_DEPENDENCY external-source-generating-tool
的{{1}}参数。我将其替换为add_custom_command
:
DEPENDS external-source-generating-tool
现在一切正常。