[CMake] Attaching cmake commands to a custom target

Andy Lego legoandy at gmail.com
Wed Mar 12 16:29:19 EDT 2008


Hi,

Just create another CMake file that has your command in it. Then execute it:

FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/myfile.cmake"
"FILE(GLOB_RECURSE HEADERS ${SRCDIR}/*.h)
MESSAGE(STATUS "Header files being processed: ${HEADERS}")
 ...
 MESSAGE(STATUS "Done processing...")")
 ADD_CUSTOM_TARGET(
     docs
     COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
     DEPENDS ${PROJECT_SOURCE_DIR}/Doxyfile
     )

Or something like that.

Andy

On Wed, Mar 12, 2008 at 1:23 PM, Kaleb Pederson
<kaleb.pederson at gmail.com> wrote:
> If I have a custom target, how can I attach a set of cmake commands to
>  it?  For example, if I have a target:
>
>  ADD_CUSTOM_TARGET(
>     docs
>     COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
>     DEPENDS ${PROJECT_SOURCE_DIR}/Doxyfile
>     )
>
>  And I want to run the following set of cmake commands any time that
>  target is executed:
>
>  FILE(GLOB_RECURSE HEADERS ${SRCDIR}/*.h)
>  MESSAGE(STATUS "Header files being processed: ${HEADERS}")
>  ...
>  MESSAGE(STATUS "Done processing...")
>
>  Is there a way to bind a set of cmake commands, like the above, to a
>  specific target?
>
>  Thanks.
>
>  --Kaleb
>  _______________________________________________
>  CMake mailing list
>  CMake at cmake.org
>  http://www.cmake.org/mailman/listinfo/cmake
>



-- 
http://legoandy.com -o- http://capitalmtb.org

Support my 150 mile bike ride to fight MS:
http://bikecan.nationalmssociety.org/site/TR?px=3921627&pg=personal&fr_id=9066


More information about the CMake mailing list