[CMake] cmake side effects: possible bug
Michael Bell
michael.bell at acm.org
Thu Aug 24 14:22:52 EDT 2006
Brad,
I have one more issue to deal with. I have been relying on
CONFIGURE_FILE to set some variables as my scripts get copied. How can
I integrate that into this framework? cmake -E copy does not seem to
set the variables.
thanks,
michael
On 8/24/06, Brad King <brad.king at kitware.com> wrote:
> Michael Bell wrote:
> > Ok, it certainly makes sense that running cmake globally would
> > simplify things, which is a good thing. It does seem to cause a
> > problem for me that maybe you can help me work around:
> >
> > Say I have a several subdirectories, each with C++ code and perl
> > wrappers to that code. If I change the code in one directory and run
> > make, it compiles the code, then ALL perl files are copied, but only
> > the files from the current directory are made executable. So, while I
> > had executable perl wrappers before, they are no longer executable
> > except from the one directory.
> >
> > The solution I have adopted for now is to run make from the root,
> > which copies and makes all scripts executable. But, that means C++
> > code must be compiled in every directory too, even if I don't want
> > that to happen. Or, perl scripts get copied that I don't want copied
> > yet. In other words, I need a way for make to act locally.
> >
> > Note that I am running cmake only once, before any of the above.
> > Everything I wrote about happens when I run make.
>
> The new "global" execution means things are now target oriented instead
> of directory oriented. This is consistent with how things have always
> worked on the Visual Studio generators.
>
> You should convert your view to be target based also and things will
> make much more sense. You could move the copy/set-exec to a custom
> target with a custom command and then make other targets depend on it.
>
> ADD_CUSTOM_COMMAND(
> OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/myscript1.pl
> COMMAND ${CMAKE_COMMAND} -E copy
> ${CMAKE_CURRENT_SOURCE_DIR}/myscript1.pl.in
> ${CMAKE_CURRENT_BINARY_DIR}/myscript1.pl
> COMMAND chmod 755 ${CMAKE_CURRENT_BINARY_DIR}/myscript1.pl
> DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/myscript1.pl.in
> )
> ADD_CUSTOM_COMMAND(
> OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/myscript2.pl
> COMMAND ${CMAKE_COMMAND} -E copy
> ${CMAKE_CURRENT_SOURCE_DIR}/myscript2.pl.in
> ${CMAKE_CURRENT_BINARY_DIR}/myscript2.pl
> COMMAND chmod 755 ${CMAKE_CURRENT_BINARY_DIR}/myscript2.pl
> DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/myscript2.pl.in
> )
> ADD_CUSTOM_TARGET(prepare_myscripts DEPENDS
> ${CMAKE_CURRENT_BINARY_DIR}/myscript1.pl
> ${CMAKE_CURRENT_BINARY_DIR}/myscript2.pl)
>
> Now for any target whose build requires the scripts do:
> ADD_DEPENDENCY(some_target prepare_myscripts)
>
> -Brad
>
--
michael.bell at acm.org
More information about the CMake
mailing list