Code generation happens twice
Ian Monroe
ian at monroe.nu
Mon Jul 14 17:09:28 CEST 2008
So we're porting the QtScript Bindings from QMake to CMake.
So what should happen: the code generator is built, the generator is
run, and then several modules are built from the code (currently I've
only implemented one module building). However for some reason the
code generation is run twice: once for the target 'generator' and once
for the module. The generation takes a while, so this is bad :). It
doesn't make sense looking at the cmake code and its all based on
stuff from the CMake FAQ anyways.
Here's the cmake code in question, from
svn.kde.org/home/kde/trunk/extragear/multimedia/amarok/src/scriptengine/generator/generator/CMakeLists.txt
find_package(Qt4)
set ( QT_USE_QTXML TRUE )
set ( QT_USE_QTSCRIPT TRUE ) #generator doesn't need this, just the
qtscript libs
set ( QT_DONT_USE_QTGUI TRUE )
include(${QT_USE_FILE})
add_definitions( -DRXX_ALLOCATOR_INIT_0 )
include_directories(
${QT_INCLUDES}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/parser
${CMAKE_CURRENT_SOURCE_DIR}/parser/rpp
)
set(Rpp_SRCS
parser/rpp/preprocessor.cpp
)
set(Parser_SRCS
parser/ast.cpp
[snip]
parser/compiler_utils.cpp
)
set(Generator_SRCS
${Parser_SRCS}
${Rpp_SRCS}
generator.cpp
main.cpp
[snip]
docgenerator.cpp
)
set(Generator_MOCS
generator.h
[snip]
setupgenerator.h
)
QT4_WRAP_CPP(Generator_MOC_SRCS ${Generator_MOCS})
set(Generator_RCCS generator.qrc)
qt4_add_resources(Generator_RCC_SRCS ${Generator_RCCS})
include_directories( ${CMAKE_BINARY_DIR} )
add_executable(generator ${Generator_SRCS} ${Generator_MOC_SRCS}
${Generator_RCC_SRCS})
target_link_libraries(generator ${QT_LIBRARIES})
set( Generated_QtCore_SRCS
${CMAKE_CURRENT_BINARY_DIR}/generated_cpp/com_trolltech_qt_core/qtscript_QBasicTimer.cpp
${CMAKE_CURRENT_BINARY_DIR}/generated_cpp/com_trolltech_qt_core/qtscript_QBitArray.cpp
[snip]
${CMAKE_CURRENT_BINARY_DIR}/generated_cpp/com_trolltech_qt_core/qtscriptshell_QXmlStreamAttributes.cpp
${CMAKE_CURRENT_BINARY_DIR}/generated_cpp/com_trolltech_qt_core/qtscriptshell_QXmlStreamEntityResolver.cpp
${CMAKE_CURRENT_BINARY_DIR}/generated_cpp/com_trolltech_qt_core/main.cpp
)
get_target_property( GENERATOR_EXE generator LOCATION )
add_custom_command( OUTPUT ${Generated_QtCore_SRCS}
COMMAND ${GENERATOR_EXE}
--output-directory=${CMAKE_CURRENT_BINARY_DIR}
DEPENDS generator
# MAIN_DEPENDENCY build_all.txt
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../qtbindings/qtscript_core/ )
add_library( qtscript_core MODULE ${Generated_QtCore_SRCS} )
#qtscript bindings don't use moc
target_link_libraries(qtscript_core ${QT_LIBRARIES})
More information about the Kde-buildsystem
mailing list