I create and small test that's reproduce the problem described in this
thread

Download the cmake-customcommand-test.tar.gz attached to this mail

How to run the test.

uncompress it with "tar zxvf cmake-customcommand-test.tar.gz"
go to the build subdir "cd cmake-customcommand-test/build"
type "cmake ../"
type "make"

Here i put cmake files contents for easy view with out need download the
attch

#### CMakeLists.txt BEGIN ##########

SET(CMAKE_VERBOSE_MAKEFILE ON)

# project name
PROJECT( text-custom-command )

SET( LEXER_SOURCE_FILES MplLexer.g )


MESSAGE ( STATUS "Lexer sources: ${LEXER_SOURCE_FILES}" )

INCLUDE ( ./cmake/ydra_lexer_rules.cmake )

YDRA_LEXER_RULES( LEXER_CPP_GENERATED_SOURCE ${LEXER_SOURCE_FILES} )

MESSAGE ( STATUS "--------------- Lexer Rules ------------------" )
MESSAGE ( STATUS "Lexer source: ${LEXER_CPP_GENERATED_SOURCE}" )


add_library ( MplParser SHARED ${LEXER_CPP_GENERATED_SOURCE} )

###### CMakeLists.txt END ##############################################


#####  ydra_lexer_rules.cmake ############################################

#
# Author: [EMAIL PROTECTED]
#


SET ( COPY_FILE cp -v )

#
# Generate rules for buil slice files.
#
MACRO ( YDRA_LEXER_RULES LEXER_CPP_GENERATED_SOURCE )

    SET( LEXER_GRAMMAR_FILE ${ARGN} )

    STRING( REGEX REPLACE "\\.g" .cpp LEXER_SOURCE_BASENAME
"${LEXER_GRAMMAR_FILE}" )

    SET( LEXER_SOURCE_TMP ${PROJECT_BINARY_DIR}/${LEXER_SOURCE_BASENAME} )
    SET( LEXER_SOURCE_TARGET
${PROJECT_SOURCE_DIR}/src/generated/${LEXER_SOURCE_BASENAME} )
    SET(LEXER_SOURCE_PATH ${PROJECT_SOURCE_DIR}/antlr/${LEXER_GRAMMAR_FILE}
)

    MESSAGE ( STATUS " Lexer imput: ${LEXER_SOURCE_PATH}" )
    MESSAGE ( STATUS " Lexer cpp source filename: ${LEXER_SOURCE_BASENAME} "
)
    MESSAGE ( STATUS " Lexer cpp source tmp filepath: ${LEXER_SOURCE_TMP} "
)
    MESSAGE ( STATUS " Lexer source target filepath: ${LEXER_SOURCE_TARGET}
" )

    ADD_CUSTOM_COMMAND(
        OUTPUT ${LEXER_SOURCE_TMP}
        COMMAND ${COPY_FILE} ${LEXER_SOURCE_PATH} ${LEXER_SOURCE_TMP}
        DEPENDS ${LEXER_SOURCE_PATH}
        COMMENT "step 1 ${LEXER_SOURCE_TMP} ")

    ADD_CUSTOM_COMMAND(
        OUTPUT ${LEXER_SOURCE_TARGET}
        COMMAND ${COPY_FILE} ${LEXER_SOURCE_BASENAME} ${LEXER_SOURCE_TARGET}
        DEPENDS ${LEXER_SOURCE_TMP}
        COMMENT "step 2 ${LEXER_SOURCE_TARGET}")

    SET( LEXER_CPP_GENERATED_SOURCE ${LEXER_SOURCE_TARGET} )

ENDMACRO ( YDRA_LEXER_RULES LEXER_CPP_GENERATED_SOURCE )

###### ydra_lexer_rules.cmake END
###################################################

###### CMake output BEGIN
#########################################################
cmake-customcommand-test/build $ cmake ../
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Check size of void*
-- Check size of void* - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Lexer sources: MplLexer.g
--  Lexer imput: /home/pepone/kk/cmake-customcommand-test/antlr/MplLexer.g
--  Lexer cpp source filename: MplLexer.cpp
--  Lexer cpp source tmp filepath:
/home/pepone/kk/cmake-customcommand-test/build/MplLexer.cpp
--  Lexer source target filepath:
/home/pepone/kk/cmake-customcommand-test/src/generated/MplLexer.cpp
-- --------------- Lexer Rules ------------------
-- Lexer source:
/home/pepone/kk/cmake-customcommand-test/src/generated/MplLexer.cpp
-- Configuring done
-- Generating done
-- Build files have been written to:
/home/pepone/kk/cmake-customcommand-test/build
###### CMake output END
###########################################################


############## make output BEGIN ##########################
cmake-customcommand-test/build $ make
[ 50%] step 1 /home/pepone/kk/cmake-customcommand-test/build/MplLexer.cpp
`/home/pepone/kk/cmake-customcommand-test/antlr/MplLexer.g' ->
`/home/pepone/kk/cmake-customcommand-test/build/MplLexer.cpp'
make[2]: *** No rule to make target `../src/generated/MplLexer.cpp', needed
by `CMakeFiles/MplParser.dir/depend.make.mark'.  Stop.
make[1]: *** [CMakeFiles/MplParser.dir/all] Error 2
make: *** [all] Error 2
############## make output END ############################

Any ideas why this don't work ?

Thanks in advance

Attachment: cmake-customcommand-test.tar.gz
Description: GNU Zip compressed data

_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to