User:Argonel/mocGenerated: Difference between revisions

From KDE TechBase
(Created page with "{{Input|1=<syntaxhighlight lang="cmake"> include_directories(${CMAKE_CURRENT_BINARY_DIR}) set (converter_SCRIPT /path/to/script) set (generated inputfile) add_custom_command...")
 
mNo edit summary
 
Line 18: Line 18:
kde4_add_executable(appname ${app_SRCS})
kde4_add_executable(appname ${app_SRCS})
</syntaxhighlight>}}
</syntaxhighlight>}}
The dependency on ${converter_SCRIPT} let me edit the script and make would regenerate the output.
The dependency on ${converter_SCRIPT} let me edit the script and have make regenerate the output.

Latest revision as of 23:14, 20 April 2013

include_directories(${CMAKE_CURRENT_BINARY_DIR})

set (converter_SCRIPT /path/to/script)
set (generated inputfile)

add_custom_command(
    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${generated}.cpp ${CMAKE_CURRENT_BINARY_DIR}/${generated}.h
    COMMAND python ${converter_SCRIPT} ${converter_SCRIPT_ARGS}
    DEPENDS ${converter_SCRIPT}
)

set (generated_SRCS ${CMAKE_CURRENT_BINARY_DIR}/${generated}.cpp ${CMAKE_CURRENT_BINARY_DIR}/${generated}.h ${CMAKE_CURRENT_BINARY_DIR}/moc_${generated}.cpp)
set (app_SRCS ${other_SRCS} ${generated_SRCS})

QT4_GENERATE_MOC(${CMAKE_CURRENT_BINARY_DIR}/${generated}.h ${CMAKE_CURRENT_BINARY_DIR}/moc_${generated}.cpp)

kde4_add_executable(appname ${app_SRCS})

The dependency on ${converter_SCRIPT} let me edit the script and have make regenerate the output.