playground/devtools/kdevelop4-extra-plugins/python/parser
Andreas Pakulat
apaku at gmx.de
Tue Jul 10 22:08:28 CEST 2007
On 09.07.07 23:22:23, Alexander Neundorf wrote:
> On Monday 09 July 2007 14:22, Andreas Pakulat wrote:
> > python/parser/CMakeLists.txt with
> >
> > add_executable(python-parser ${foo_SRCS} )
> >
> >
> > Then cmake will complain that it doesn't know how to create the files in
> > foo_SRCS for the python-parser target.
> >
> > And always setting the foo_SRCS GENERATED in the subdirs is not really
> > usable either as they are only generated when you've got the generator
> > tool installed (which is not required). So I'd again need to have
> > if(FOO_FOUND) stuff everywhere.
>
> Can you put the rules for generating the files in the directories where the
> file are used, e.g. with some macros ?
I think the macro I came up with causes a full rebuild of the project
using it when touching any of the CMakeLists.txt.
An example is playground/devtools/kdevelop4-extra-plugins/ruby
if I touch tests/CMakeLists.txt the whole project is rebuilt, the
generated and non-generated files are all recompiled.
The macro I use looks like this:
macro(GET_GENERATED_SRCS _srcsList)
if(KDEVPG_FOUND AND FLEX_FOUND)
include_directories(${KDEVPG_INCLUDE_DIR})
kdevpg_generate(_kdevpgList ruby DEBUG_VISITOR
"${CMAKE_SOURCE_DIR}/parser/ruby.g"
"${CMAKE_SOURCE_DIR}/parser/ruby_lexer.h")
# Copy ruby_lexer.ll to the builddir, so that flex doesn't write out
# absolute paths in the generated file when we pass them as arguments.
# In short, I don't want stuff like
# '#line 2 "/home/kde/build/.../ruby_lexer.cpp" in SVN.
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ruby_lexer.ll"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/parser/ruby_lexer.ll"
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different
"${CMAKE_SOURCE_DIR}/parser/ruby_lexer.ll"
"${CMAKE_CURRENT_BINARY_DIR}/ruby_lexer.ll"
)
# Add command to generate the lexer.
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ruby_lexer.cpp"
MAIN_DEPENDENCY "${CMAKE_CURRENT_BINARY_DIR}/ruby_lexer.ll"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/ruby_parser.h"
"${CMAKE_SOURCE_DIR}/parser/ruby_lexer.h"
COMMAND ${FLEX_EXECUTABLE}
ARGS -o"ruby_lexer.cpp"
"ruby_lexer.ll"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
set(${_srcsList} ${_kdevpgList} "${CMAKE_CURRENT_BINARY_DIR}/ruby_lexer.cpp")
else(KDEVPG_FOUND AND FLEX_FOUND)
include_directories(${CMAKE_SOURCE_DIR}/parser/generated)
message(STATUS "Assuming existence of generated parser files")
message( STATUS "Assuming existence of generated lexer files")
set(${_srcsList}
${CMAKE_SOURCE_DIR}/parser/generated/ruby_parser.cpp
${CMAKE_SOURCE_DIR}/parser/generated/ruby_visitor.cpp
${CMAKE_SOURCE_DIR}/parser/generated/ruby_default_visitor.cpp
${CMAKE_SOURCE_DIR}/parser/generated/ruby_lexer.cpp )
endif(KDEVPG_FOUND AND FLEX_FOUND)
endmacro(GET_GENERATED_SRCS)
Andreas
--
Make a wish, it might come true.
More information about the Kde-buildsystem
mailing list