Hi,

I've found an example to use bison and flex in cmake.
I have a static library where I want to add the generated
sources but the dependencies are not triggered. Why?

project(test)

include_directories(.
                    ${CMAKE_BINARY_DIR}/libs/test)

add_custom_target(ScannerAndParser echo "Creating scanner.cxx and parser.cxx")

add_custom_command(
    SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/scanner.l
    COMMAND flex
    ARGS -o ${CMAKE_BINARY_DIR}/libs/test/scanner.cxx
            ${CMAKE_CURRENT_SOURCE_DIR}/scanner.l
    TARGET ScannerAndParser
    DEPENDS ${CMAKE_BINARY_DIR}/libs/test/scanner.cxx
    OUTPUTS ${CMAKE_BINARY_DIR}/libs/test/scanner.cxx)

add_custom_command(
    SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/parser.y
    COMMAND bison
    ARGS -y -d ${CMAKE_CURRENT_SOURCE_DIR}/parser.y
         -o ${CMAKE_BINARY_DIR}/libs/test/parser.cxx
    TARGET ScannerAndParser
    DEPENDS ${CMAKE_BINARY_DIR}/libs/test/parser.cxx
    OUTPUTS ${CMAKE_BINARY_DIR}/libs/test/parser.cxx)

file(GLOB lib_sources *.cxx ${CMAKE_BINARY_DIR}/libs/test/scanner.cxx
                            ${CMAKE_BINARY_DIR}/libs/test/parser.cxx)

set_source_files_properties(${CMAKE_BINARY_DIR}/libs/test/parser.cxx GENERATED)

add_library(test STATIC ${lib_sources})
add_dependencies(test ScannerAndParser)



Thomas Lehmann
Scrum Master

[cid:rts-logo.png@fbda10bfcd534b0b8e20728cd423552e]

RTS Realtime Systems Software GmbH, Rembrandtstrasse 13, D-60596 Frankfurt am 
Main
T: +49.69.61009.0 / F: +49.69.61009.181

Sitz: Frankfurt am Main - HRB 84467 Amtsgericht Frankfurt am Main
Gesch?ftsf?hrer: Steffen Gemuenden, Igor Sluga

www.rtsgroup.net

This email and any attachments are for the exclusive and confidential use of 
the intended recipient. If you are not the intended recipient, or an employee 
or agent responsible for delivering this message to the intended recipient, 
please do not read, distribute or take action in reliance upon this message. If 
you have received this in error, please notify me immediately by return email 
and promptly delete this message and its attachments from your computer system.

<<inline: rts-logo.png>>

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to