[CMake] add_custom_target is executed during make install

Jbd evadream at gmail.com
Thu Dec 28 09:27:32 EST 2006


Hello everybody.

I'm running cmake version 2.4-patch 3.

I've got a problem. I'm quite sure i'm not using the good way to 
do it. I need to call a shell script during the building process.

# First, i'm generating some files using a python script
# After that, i've got a generated Makefile in the generated directory

add_custom_command(
  OUTPUT  generated-binding  # arbitrary since i'm gonna 
                             # generate a bunch of files
  COMMAND ${CMAKE_COMMAND}
  -E chdir ${CMAKE_CURRENT_SOURCE_DIR} ${PYTHON_EXECUTABLE} configure.py
  COMMENT "Generate files using python"
)

# I'm using the previously generated Makefile
# by calling "make" in the generated directory
add_custom_command(
  OUTPUT  compile-binding  # arbitrary file, again
  COMMAND ${CMAKE_COMMAND} # i'm running make
                           # in the ./generated/ directory
             -E chdir ${CMAKE_CURRENT_SOURCE_DIR}/generated make
  DEPENDS generated-binding
  COMMENT "Compiling using generated makefile"
)

# I want this target build each time i'm calling "make"
# but i don't want it to be build when i call "make install"
# Is that possible ?
add_custom_target(
  compile_binding ALL DEPENDS compile-binding
)

# i run make install in the generated directory
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND}
             -E chdir ${CMAKE_CURRENT_SOURCE_DIR}/generated make install)")


Everything's fine but even when i call "make install" from a parent
directory, compile_binding is always regenerated. I'd like to limit
the construction of compile_bing target only when calling "make".

Is there any solution, or better way to achieve what i'm looking for ?

Thank you.



More information about the CMake mailing list