I am developing a c++ program and I want to generate a pair of source and header files from an xml file (for Qt DBus interface).
There are couple of problems:
- If the files that I need to be generated are not generated beforehand, cmake complians that files are not found, I guess at
add_executablecommand - I tried to create a dependency, but looks like my command
add_custom_targetdoes not work
Here is the part of cmake file:
add_custom_target(
generateDBusHeaders
COMMAND "${CMAKE_SYSROOT}/usr/bin/qdbusxml2cpp.exe \
-c TestAdapter \
-a ${CMAKE_CURRENT_SOURCE_DIR}/inc/testadapter.h : \
${CMAKE_CURRENT_SOURCE_DIR}/src/testadapter.cpp \
${CMAKE_CURRENT_SOURCE_DIR}/setup/com.example.test.xml"
)
add_executable(${PROJECT_NAME}
src/main.cpp
## inc/testadapter.h src/testadapter.cpp ## If fiels not found, cmake gives error
)
# Add dependencies
# I expect this to generate files before add_executable
# But it looks like nothing being generated at all!
add_dependencies(${PROJECT_NAME} generateDBusHeaders) # Use qdbusxml2cpp
So the questions are:
- How to deal with generating source files before calling
add_executable - How to make sure that custom command
qdbusxml2cpp.exeis being executed at all? I see no changes and no output in my cmake in terminal