[CMake] add_custom_target: always built during "make" and "make install"

Romain CHANU romainchanu at gmail.com
Mon Nov 2 09:48:49 EST 2009


Hi,

I have an issue and I do not know if there is a solution to it...

I have two CMakeLists.txt files as described below (just the important
parts):

=== root/src/CMakeLists.txt === (build a shared library)

# Compilation
add_library(
  ${CMAKE_PROJECT_NAME} SHARED
  ${CMAKE_BINARY_DIR}/xsd/mapping_file.cxx)

# XML mapping source files are generated
set_source_files_properties(
  ${CMAKE_BINARY_DIR}/xsd/mapping_file.cxx
  PROPERTIES GENERATED 1)

# Make sure the source files are generated before the executable builds.
add_dependencies(${CMAKE_PROJECT_NAME} cxx_xml_mapping)

=== root/xsd/CMakeLists.txt === (generates C++ / XML mapping files using
code synthesis XSD)

# Add a custom target to manage dependencies
add_custom_target(cxx_xml_mapping DEPENDS xml_mapping)

add_custom_command(
  OUTPUT cxx_xml_mapping
  COMMAND ${XSD_EXECUTABLE} ARGS ${XSD_ARGS}
${CMAKE_CURRENT_SOURCE_DIR}/*.xsd
  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.xsd
  COMMENT "Generating C++ / XML mapping files")


What happens is that when I build my library with "make" , it compiles and
works fine. If I do a "make install", it will compile again due to the
add_custom_target (which is always considered out of date and hence built
every time, cf. documentation).

Is there anyway to not compile again when running the make install???

Thank you for your help.

Romain Chanu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091102/38385f57/attachment.htm>


More information about the CMake mailing list