From: <ai...@us...> - 2009-09-11 04:32:36
|
Revision: 10396 http://plplot.svn.sourceforge.net/plplot/?rev=10396&view=rev Author: airwin Date: 2009-09-11 04:32:14 +0000 (Fri, 11 Sep 2009) Log Message: ----------- Fix long-standing dependency issues for the ocaml bindings and examples. As far as I know, with this fix no ocaml-related builds are done when they shouldn't be, and we now have proper file dependencies (as demonstrated by touch) and target dependencies (as demonstrated by parallel builds) between builds of libplplot(d), the ocaml bindings, and the ocaml examples. Modified Paths: -------------- trunk/bindings/ocaml/CMakeLists.txt trunk/examples/ocaml/CMakeLists.txt Modified: trunk/bindings/ocaml/CMakeLists.txt =================================================================== --- trunk/bindings/ocaml/CMakeLists.txt 2009-09-10 14:19:35 UTC (rev 10395) +++ trunk/bindings/ocaml/CMakeLists.txt 2009-09-11 04:32:14 UTC (rev 10396) @@ -32,9 +32,6 @@ plplot.mli touchup.ml ) - set(GEN_SOURCE_LIST - ${CMAKE_CURRENT_BINARY_DIR}/myocamlbuild.ml - ) set(OCAML_INSTALL_FILES plplot.cma @@ -50,7 +47,7 @@ set(OCAML_FULL_INSTALL_FILES ${OCAML_FULL_INSTALL_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/${OCAML_FILE}) endforeach(OCAML_FILE ${OCAML_INSTALL_FILES}) - # Configure the META file +# Configure the META file # Configure pkg-config *.pc file corresponding to plplot.cma if(PKG_CONFIG_EXECUTABLE) if(LIB_TAG) @@ -97,7 +94,9 @@ # Configure the file controlling the ocamlbuild process configure_file(myocamlbuild.ml.cmake ${CMAKE_CURRENT_BINARY_DIR}/myocamlbuild.ml) - set(DEPENDS_LIST ${GEN_SOURCE_LIST}) + # Don't bother with dependency on configured myocamlbuild.ml since + # that file is created at initial cmake time. + set(DEPENDS_LIST) # Copy all source into the build tree since the whole project must be in # the same directory @@ -105,41 +104,69 @@ add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} COMMAND ${CMAKE_COMMAND} - -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} + -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FILE} ) - set(DEPENDS_LIST ${DEPENDS_LIST} ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE}) + list(APPEND DEPENDS_LIST ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE}) endforeach(SRC_FILE ${SOURCE_LIST}) # Note: ocamlbuild requires build-dir to be a relative path # Also the build-dir must not be the project root - hence the # new subdirectory - # Build bytecode version + + # N.B. "touch_nocreate" commands below are used to always update the + # date on the OUTPUT files since under certain circumstances (a + # rebuild with new plplot${LIB_TAG}) ${OCAMLBUILD} does not update + # the date itself which screws up file dependencies. + + # Build bytecode version. add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.cma COMMAND ${OCAMLBUILD} -tag debug -classic-display -build-dir ${OCAML_BUILD_DIR} plplot.cma + COMMAND ${CMAKE_COMMAND} -E touch_nocreate + ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.cma DEPENDS ${DEPENDS_LIST} plplot${LIB_TAG} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) + add_custom_target( + plplot_ocaml_bytecode + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.cma + ) - # Build native version. Use DEPENDS to serialize against plplot.cma - # since the two ocamlbuilds interfere with each other when in parallel - # build mode. + # Build native version. add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.cmxa + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.cmxa ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.a COMMAND ${OCAMLBUILD} -tag debug -classic-display -build-dir ${OCAML_BUILD_DIR} plplot.cmxa + COMMAND ${CMAKE_COMMAND} -E touch_nocreate + ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.cmxa + COMMAND ${CMAKE_COMMAND} -E touch_nocreate + ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.a DEPENDS ${DEPENDS_LIST} plplot${LIB_TAG} - ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.cma WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) - add_custom_target( - plplot_ocaml ALL - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.cma ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.cmxa ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.a + plplot_ocaml_native + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.cmxa + ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.a ) + # Serialize these two with a target dependency since the two builds + # interfere with each other if done in parallel. + add_dependencies(plplot_ocaml_native plplot_ocaml_bytecode) + + add_custom_target(plplot_ocaml ALL) + add_dependencies(plplot_ocaml plplot_ocaml_native) + + # Need to keep track of file dependencies since this is a custom target. + set_property(GLOBAL PROPERTY FILES_plplot_ocaml + ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.cma + ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.cmxa + ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.a + ) # Most files go in the plplot subdirectory install(FILES ${OCAML_FULL_INSTALL_FILES} ${CMAKE_CURRENT_BINARY_DIR}/META @@ -151,11 +178,12 @@ DESTINATION ${OCAML_INSTALL_DIR}/stublibs ) - # This does not work as the clean rule will not remove directories which - # are not empty + # Remove entire contents of ${OCAML_BUILD_DIR} when the clean target + # is run. This proved to work fine on cmake-2.6.4, but may not for + # earlier versions according to a remark made here before. set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${OCAML_BUILD_DIR} - ) + ) endif(ENABLE_ocaml) Modified: trunk/examples/ocaml/CMakeLists.txt =================================================================== --- trunk/examples/ocaml/CMakeLists.txt 2009-09-10 14:19:35 UTC (rev 10395) +++ trunk/examples/ocaml/CMakeLists.txt 2009-09-11 04:32:14 UTC (rev 10396) @@ -65,8 +65,7 @@ if(CORE_BUILD) set(ocaml_SRCS) foreach(STRING_INDEX ${ocaml_STRING_INDICES}) - set(SOURCE_FILE x${STRING_INDEX}.ml) - set(ocaml_SRCS ${ocaml_SRCS} ${SOURCE_FILE}) + list(APPEND ocaml_SRCS x${STRING_INDEX}.ml) endforeach(STRING_INDEX ${ocaml_STRING_INDICES}) configure_file( @@ -99,7 +98,9 @@ set(ccopt_OPTION "-L ${CMAKE_INSTALL_LIBDIR} -Wl,-rpath -Wl,${CMAKE_INSTALL_LIBDIR} ") endif(CORE_BUILD) + get_property(files_plplot_ocaml GLOBAL PROPERTY FILES_plplot_ocaml) set_property(GLOBAL PROPERTY TARGETS_examples_ocaml) + set_property(GLOBAL PROPERTY FILES_examples_ocaml) foreach(STRING_INDEX ${ocaml_STRING_INDICES}) set(EXECUTABLE_NAME x${STRING_INDEX}ocaml) set(SOURCE_FILE x${STRING_INDEX}.ml) @@ -121,7 +122,9 @@ plplot.cma -o ${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_FILE} - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_FILE} + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_FILE} + ${files_plplot_ocaml} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} VERBATIM ) @@ -133,6 +136,7 @@ add_dependencies(target_${EXECUTABLE_NAME} plplot_ocaml) endif(CORE_BUILD) set_property(GLOBAL APPEND PROPERTY TARGETS_examples_ocaml target_${EXECUTABLE_NAME}) + set_property(GLOBAL APPEND PROPERTY FILES_examples_ocaml ${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE_NAME}) endforeach(STRING_INDEX ${ocaml_STRING_INDICES}) set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${ocaml_EXTRA_CLEAN_FILES}") endif(BUILD_TEST) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |