Thanks for your directions, I'm experiencing one problem however:

I can't seem to communicate a variable from my project configure (which contains the ADD_CUSTOM_COMMAND) to the invocation of myscript.cmake.

The command below is:
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/myscript.cmake
I expected that I could used -D to pass a variable from the command like to the script:
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/myscript.cmake -D MYVAR:STRING=FOO

But that didn't work.

Any advice? It would be nice if myscript.cmake could use the same cache as the project configure too.


Thanks--

Abe

Brad King wrote:
Abe Stephens wrote:
  
How can I have a CMake script run if a certain non-source file has
changed since the last project build?

I have a script which extracts some revision information from "svn info"
and places it in a source file via CONFIGURE_FILE. I'd like this script
to be executed during build every time the
${CMAKE_SOURCE_DIR}/.svn/entries file changes.  (This file is altered
every time I commit a file or update from the repository.)
    

# Configure the script to know where to put the output file.
# It should reference @MYSCRIPT_OUTPUT@ to get this variable setting.
SET(MYSCRIPT_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/myoutput.txt)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/myscript.cmake.in
               ${CMAKE_CURRENT_BINARY_DIR}/myscript.cmake)

# Add a custom command to drive the script whenever the svn entries
# file changes.
ADD_CUSTOM_COMMAND(
  OUTPUT ${MYSCRIPT_OUTPUT}
  DEPENDS ${CMAKE_SOURCE_DIR}/.svn/entries
  COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/myscript.cmake
  )

# Add a custom target to drive the custom command.
ADD_CUSTOM_TARGET(svn_check ALL DEPENDS ${MYSCRIPT_OUTPUT})

-Brad
  

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

Reply via email to