Re: [CMake] Re: Custom build step

2008-01-21 Thread pepone . onrez
>On Jan 21, 2008 7:40 AM, Brandon Van Every <[EMAIL PROTECTED]> wrote:

>This fails because add_library only understands target level
>dependencies.  add_custom_command only generates file level

I think there is an inconsistence in the way ADD_CUSTOM_COMMAND run and how
dependencies are managed, but also this my be same misunderstanding of me.

If i generated my files in one ADD_CUSTOM_COMMAND make don't report any
problems and project builds fine, all dependencies are found.

When i try to split the generation process  in multiple custom_commands it
don't generate the correct targets. Even when one command depends on the
other and the library depends on the output files from the second command.
make reports that there isn't a target for the second one.


When i try to resolve with ADD_DEPENDECIES ,ALL targets are found but the
generation code runs two times each time i run make (I think this is
expected with ADD_DEPENDENCIES because doc says is considered always out of
date).

When i try to resolve with
ADD_CUSTOM_COMMAND(TARGET MyLib PRE_BUILD DEPENDS ${GeneratedFiles})
Cmake runs with out erros but make reports that there is no target for
generate ${GeneratedFiles}  that is the output of my second command. The
same as when i use 2 ADD_CUSTOM_COMMAND with out ADD_DEPENDENCIES.


Thanks in advance any help is appreciated.


On Jan 21, 2008 5:14 PM, pepone. onrez <[EMAIL PROTECTED]> wrote:

> Hi Brandon thanks for your help
> problem with ADD_CUSTOM_TARGET is that runs allways even when it generate
> files are up to date.
>
> Quoted From Cmake docs:
>
> Adds a target with the given name that executes the given commands. The
> target has no output file and is ALWAYS CONSIDERED OUT OF DATE even if the
> commands try to create a file with the name of the target.
>
> In my case now the commands that generated the files now run tow times. I
> now trying with ADD_CUSTOM_COMMAND(TARGET foo PRE_BUILD) with out success at
> this point.
>
>
>
>
>
> On Jan 21, 2008 2:41 PM, Brandon Van Every <[EMAIL PROTECTED]> wrote:
>
> > On Jan 21, 2008 8:39 AM, Brandon Van Every <[EMAIL PROTECTED]> wrote:
> > >
> > >  then ADD_DEPENDENCIES(mylib DEPENDS blah).
> >
> > Er, add_dependencies(mylib blah).
> >
> >
> > Cheers,
> > Brandon Van Every
> > ___
> > CMake mailing list
> > CMake@cmake.org
> > http://www.cmake.org/mailman/listinfo/cmake
> >
>
>
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Re: Custom build step

2008-01-21 Thread pepone . onrez
Hi Brandon thanks for your help
problem with ADD_CUSTOM_TARGET is that runs allways even when it generate
files are up to date.

Quoted From Cmake docs:

Adds a target with the given name that executes the given commands. The
target has no output file and is ALWAYS CONSIDERED OUT OF DATE even if the
commands try to create a file with the name of the target.

In my case now the commands that generated the files now run tow times. I
now trying with ADD_CUSTOM_COMMAND(TARGET foo PRE_BUILD) with out success at
this point.




On Jan 21, 2008 2:41 PM, Brandon Van Every <[EMAIL PROTECTED]> wrote:

> On Jan 21, 2008 8:39 AM, Brandon Van Every <[EMAIL PROTECTED]> wrote:
> >
> >  then ADD_DEPENDENCIES(mylib DEPENDS blah).
>
> Er, add_dependencies(mylib blah).
>
>
> Cheers,
> Brandon Van Every
> ___
> CMake mailing list
> CMake@cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Re: Custom build step

2008-01-21 Thread Brandon Van Every
On Jan 21, 2008 8:39 AM, Brandon Van Every <[EMAIL PROTECTED]> wrote:
>
>  then ADD_DEPENDENCIES(mylib DEPENDS blah).

Er, add_dependencies(mylib blah).


Cheers,
Brandon Van Every
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Re: Custom build step

2008-01-21 Thread Brandon Van Every
On Jan 21, 2008 7:40 AM, Brandon Van Every <[EMAIL PROTECTED]> wrote:
> On Jan 21, 2008 6:16 AM, pepone. onrez <[EMAIL PROTECTED]> wrote:
> >
> > SET ( COPY_FILE cp -v )
>
> Better: ${CMAKE_COMMAND} -E copy
> Type cmake -E for details of OS portable commands.
>
> Your example build fails on Cygwin with the same problem.

Ok, here's the essence of what your code does.  In the future when
providing a "trivial reproducer" for a problem, it would be best to
strip it down to this level.  One very simple CMakeLists.txt, no
subdirectories, no long variable names, no extraneous stuff.  To the
degree that you can, of course.

project(copygen)
SET(f0 sample.g)
STRING( REGEX REPLACE "\\.g" .cpp f1 "${f0}" )

ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_BINARY_DIR}/${f1}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_SOURCE_DIR}/${f0} ${CMAKE_BINARY_DIR}/${f0}
DEPENDS ${CMAKE_SOURCE_DIR}/${f0}
COMMENT "step 1")

ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_BINARY_DIR}/generated/${f1}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_BINARY_DIR}/${f1} ${CMAKE_BINARY_DIR}/generated/${f1}
DEPENDS ${CMAKE_BINARY_DIR}/${f1}
COMMENT "step 2")

add_library (mylib SHARED ${CMAKE_BINARY_DIR}/generated/${f1} )


This fails because add_library only understands target level
dependencies.  add_custom_command only generates file level
dependencies.  To make a target level dependency, you'd have to wrap
the last add_custom_command with an add_custom_target(blah DEPENDS
${CMAKE_BINARY_DIR}/generated/${f1}), then ADD_DEPENDENCIES(mylib
DEPENDS blah).

add_library would have understood the dependency just fine, if it were
not generated.  Question: why couldn't add_library look for generated
files as well as non-generated files?


Cheers,
Brandon Van Every
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Re: Custom build step

2008-01-21 Thread Brandon Van Every
On Jan 21, 2008 6:16 AM, pepone. onrez <[EMAIL PROTECTED]> wrote:
>
> SET ( COPY_FILE cp -v )

Better: ${CMAKE_COMMAND} -E copy
Type cmake -E for details of OS portable commands.

Your example build fails on Cygwin with the same problem.


Cheers,
Brandon Van Every
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Re: Custom build step

2008-01-21 Thread pepone . onrez
I Attach a incorrect file in the last mail, get the file attached to this
mail for view the correct example.

Thanks


cmake-customcommand-test.tar.gz
Description: GNU Zip compressed data
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Re: Custom build step

2008-01-21 Thread pepone . onrez
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


cmake-customcommand-test.tar.gz
Description: GNU Zip compressed data
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Re: Custom build step

2008-01-19 Thread pepone . onrez
I Create a small test to try replicate the problem and all works Fine at
first view and ADD_CUSTOM_COMMAND is called as expected.

I now thinking that can be a problem in how i concatenate values in OUTPUT
of the command, i  go to change my script for clean and further inspect this
issue.

BTW i can buid my system with Cmake :)


On Jan 19, 2008 8:02 PM, pepone. onrez <[EMAIL PROTECTED]> wrote:

> I test various debug messages before my first post here and variable
> values seems alright. Now ill try to reproduce the problem in a self
> contained example and post here the results.
>
> Thanks for all
>
>
> On Jan 19, 2008 7:15 PM, Brandon Van Every <[EMAIL PROTECTED]> wrote:
>
> > I'm going to take a wild guess that one of your variables is emitting
> > extra quotes or open parentheses or something, such that the 2nd
> > ADD_CUSTOM_COMMAND gratuitously disappears.  Suggest you message() all
> > your variables to see what they are, and also write a small test case
> > that simulates the behavior you're trying to implement, without all
> > the fancy extra logic.
> >
> > Cheers,
> > Brandon Van Every
> > ___
> > CMake mailing list
> > CMake@cmake.org
> > http://www.cmake.org/mailman/listinfo/cmake
> >
>
>
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Re: Custom build step

2008-01-19 Thread pepone . onrez
I test various debug messages before my first post here and variable values
seems alright. Now ill try to reproduce the problem in a self contained
example and post here the results.

Thanks for all

On Jan 19, 2008 7:15 PM, Brandon Van Every <[EMAIL PROTECTED]> wrote:

> I'm going to take a wild guess that one of your variables is emitting
> extra quotes or open parentheses or something, such that the 2nd
> ADD_CUSTOM_COMMAND gratuitously disappears.  Suggest you message() all
> your variables to see what they are, and also write a small test case
> that simulates the behavior you're trying to implement, without all
> the fancy extra logic.
>
> Cheers,
> Brandon Van Every
> ___
> CMake mailing list
> CMake@cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Re: Custom build step

2008-01-19 Thread Brandon Van Every
I'm going to take a wild guess that one of your variables is emitting
extra quotes or open parentheses or something, such that the 2nd
ADD_CUSTOM_COMMAND gratuitously disappears.  Suggest you message() all
your variables to see what they are, and also write a small test case
that simulates the behavior you're trying to implement, without all
the fancy extra logic.

Cheers,
Brandon Van Every
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Re: Custom build step

2008-01-19 Thread pepone . onrez
Hi Brandon

[EMAIL PROTECTED] ~/proyects/ydra-ipluginservice/build $ grep Moving * -R
[EMAIL PROTECTED] ~/proyects/ydra-ipluginservice/build $


I grep -R in  the build  dir and don't  see the keword Moving that i put in
the Comment of the second ADD_CUSTOM_COMAND  in any of CMake generated
files.

Thanks for the sugestion in any way
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Re: Custom build step

2008-01-19 Thread Brandon Van Every
On Jan 19, 2008 11:50 AM, pepone. onrez <[EMAIL PROTECTED]> wrote:
>
> Case 2 - i don`t see that Cmake generated any rule for the second commands.

Did you grep all the files in the generated CMake tree?  Perhaps they
were output to a different file.


Cheers,
Brandon Van Every
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Re: Custom build step

2008-01-19 Thread pepone . onrez
I know is not a good practice but this library only has generated code, and
the generated headers are need for build other applications made by third
parties. This is why i prefer to put in sources.

I atach here the relevant code for both cases and generated rules.
Case 1 - works as expected
Case 2 - i don`t see that Cmake generated any rule for the second commands.

Case 1)
ADD_CUSTOM_COMMAND(
OUTPUT  ${PROJECT_SOURCE_DIR}/src/${SOURCE_OUTPUT_BASENAME}
${PROJECT_SOURCE_DIR}/include/${PROJECT_NAMESPACE}/${HEADER_OUTPUT_BASENAME}
COMMAND ${SLICE2CPP_COMMAND} ${SLICE_ARGS} ${SLICE_SOURCE}
COMMAND ${MOVE_FILE_COMMAND}
${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_OUTPUT_BASENAME}
${PROJECT_SOURCE_DIR}/src/${SOURCE_OUTPUT_BASENAME}
COMMAND ${MOVE_FILE_COMMAND}
${CMAKE_CURRENT_BINARY_DIR}/${HEADER_OUTPUT_BASENAME}
${PROJECT_SOURCE_DIR}/include/${PROJECT_NAMESPACE}/${HEADER_OUTPUT_BASENAME}
DEPENDS ${DEPENDS}
COMMENT "-- Generating ${SOURCE_OUTPUT_BASENAME}
${HEADER_OUTPUT_BASENAME} file from ${SLICE_SOURCE_BASENAME}")

 Rules in Makefile For Case1 #


../src/IPluginService.cpp: ../slice/Oz/IPluginService.ice
$(CMAKE_COMMAND) -E cmake_progress_report
/home/pepone/proyects/ydra-ipluginservice/build/CMakeFiles
$(CMAKE_PROGRESS_2)
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold
"-- Generating IPluginService.cpp IPluginService.h file from
IPluginService.ice"
/usr/bin/slice2cpp --include-dir Oz
-I/home/pepone/proyects/ydra-ipluginservice/slice -I/usr/share/slice
/home/pepone/proyects/ydra-ipluginservice/slice/Oz/IPluginService.ice
mv /home/pepone/proyects/ydra-ipluginservice/build/IPluginService.cpp
/home/pepone/proyects/ydra-ipluginservice/src/IPluginService.cpp
mv /home/pepone/proyects/ydra-ipluginservice/build/IPluginService.h
/home/pepone/proyects/ydra-ipluginservice/include/Oz/IPluginService.h

../include/Oz/IPluginService.h: ../src/IPluginService.cpp

CMakeFiles/IPluginService.dir/depend:
CMakeFiles/IPluginService.dir/depend.make.mark

# END ##3


Case 2)

ADD_CUSTOM_COMMAND(
OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_OUTPUT_BASENAME}
${CMAKE_CURRENT_BINARY_DIR}/${HEADER_OUTPUT_BASENAME}
COMMAND ${SLICE2CPP_COMMAND} ${SLICE_ARGS} ${SLICE_SOURCE}
DEPENDS ${DEPENDS}
COMMENT "-- Generating ${SOURCE_OUTPUT_BASENAME}
${HEADER_OUTPUT_BASENAME} file from ${SLICE_SOURCE_BASENAME}")

ADD_CUSTOM_COMMAND(
OUTPUT  ${PROJECT_SOURCE_DIR}/src/${SOURCE_OUTPUT_BASENAME}
${PROJECT_SOURCE_DIR}/include/${PROJECT_NAMESPACE}/${HEADER_OUTPUT_BASENAME}
COMMAND ${MOVE_FILE_COMMAND}
${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_OUTPUT_BASENAME}
${PROJECT_SOURCE_DIR}/src/${SOURCE_OUTPUT_BASENAME}
COMMAND ${MOVE_FILE_COMMAND}
${CMAKE_CURRENT_BINARY_DIR}/${HEADER_OUTPUT_BASENAME}
${PROJECT_SOURCE_DIR}/include/${PROJECT_NAMESPACE}/${HEADER_OUTPUT_BASENAME}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_OUTPUT_BASENAME}
${CMAKE_CURRENT_BINARY_DIR}/${HEADER_OUTPUT_BASENAME}
COMMENT "-- Moving generated file ${SOURCE_OUTPUT_BASENAME} to
${PROJECT_SOURCE_DIR}/src")

# Rules in Makefile  for Case 2)
##

# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.4

#=
# Special targets provided by cmake.

# Disable implicit rules so canoncical targets will work.
.SUFFIXES:

.SUFFIXES: .hpux_make_needs_suffix_list

# Suppress display of executed commands.
$(VERBOSE).SILENT:

# A target that is always out of date.
cmake_force:

#=
# Set environment variables for the build.

# The shell in which to execute make rules.
SHELL = /bin/sh

# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake

# The command to remove a file.
RM = /usr/bin/cmake -E remove -f

# The program to use to edit the cache.
CMAKE_EDIT_COMMAND = /usr/bin/ccmake

# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /home/pepone/proyects/ydra-ipluginservice

# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /home/pepone/proyects/ydra-ipluginservice/build

# Include any dependencies generated for this target.
include CMakeFiles/IPluginService.dir/depend.make

# Include the progress variables for this target.
include CMakeFiles/IPluginService.dir/progress.make

# Include the compile flags for this target's objects.
include CMakeFiles/IPluginService.dir/flags.make

CMakeFiles/IPluginService.dir/depend.make.mark:
CMakeFiles/IPluginService.dir/flags.make
CMakeFiles/IPluginService.dir/depend.make.mark: ../src/IPluginService.cpp

CMakeFiles/IPluginService.dir/src/IPluginService.o:
CMakeFiles/IPluginService.dir/flags.make
CMakeFiles/IPluginSer