I am writing cmake example for the first time.
Here is a part of CMakeFiles.txt:
add_custom_command(
OUTPUT ${CODEGEN_SRC}
PRE_BUILD
COMMAND ${CODEGEN_CMD} ${SERVICE_XML} --generate-cpp- code=/home/hello/include/gen/testGenCode
COMMENT "Generate gdbus code"
)
add_custom_target(${CODEGEN_TARGET}
DEPENDS ${CODEGEN_SRC}
)
Generate code using gdbus-codegen-glibmm
in command syntax using add_custom_command
.
However, contrary to my expectations, when I actually do cmake and make, it looks like this:
cmake ..
CMake Error at Server/CMakeLists.txt:1 (ADD_EXECUTABLE):
Cannot find source file:
#### generate File ####
CMake Error at Client/CMakeLists.txt:36 (ADD_EXECUTABLE):
Cannot find source file:
#### generate File ####
Then, if you proceed with make, the contents of COMMANT in add_custom_command are output, and codes are actually generated.
After checking the generated code, proceed with cmake .. and make again to build normally.
Server/CMakeLists.txt, Client/CMakeLists.txt
I set the dependency of ${CODEGEN_TARGET}
using ADD_DEPENDENCIES in , but it works differently than I expected.
How can I get the gdbus-codegen-glibmm command to run first?