My project structure:
/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)
The problems is /src/CMakeLists.txt
cannot find external-source-generating-tool
:
Error:Cannot find source file:
external-source-generating-tool
Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx
How correctly call external-source-generating-tool
from /src/CMakeLists.txt
?
external-source-generating-tool
as source file foradd_executable()
. It has nothing common with inability to findexternal-source-generating-tool
executable for run it. – TsyvarevMAIN_DEPENDENCY external-source-generating-tool
parameter. I removed it and now all works fine. – york.beta