From: <ai...@us...> - 2009-09-20 22:08:32
|
Revision: 10442 http://plplot.svn.sourceforge.net/plplot/?rev=10442&view=rev Author: airwin Date: 2009-09-20 22:08:21 +0000 (Sun, 20 Sep 2009) Log Message: ----------- As a convenience to help build the ocaml bindings, implement the GENERATE_PLPLOT_H_INC option (which defaults to OFF). If this option is set ON by the ocaml developer, then checks are made that all the proper extra required ocaml components are installed, and a custom target is made which generates generated_plplot_h.inc. That file should be the same as plplot_h.inc that occurs in the source tree. However, if it is not, a knowledgable ocaml developer should be able to adjust plplot_h or touchup.ml in the source tree to achieve consistency between the generated and source tree versions of plplot_h.inc. Of course, if those two files are fine, then there is always the option of overwriting the source code version of plplot_h.inc with the generated version to achieve the desired consistency. Modified Paths: -------------- trunk/bindings/ocaml/CMakeLists.txt trunk/cmake/modules/ocaml.cmake Modified: trunk/bindings/ocaml/CMakeLists.txt =================================================================== --- trunk/bindings/ocaml/CMakeLists.txt 2009-09-20 20:26:41 UTC (rev 10441) +++ trunk/bindings/ocaml/CMakeLists.txt 2009-09-20 22:08:21 UTC (rev 10442) @@ -22,6 +22,31 @@ if(ENABLE_ocaml) + # optional command to generate generated_plplot_h.inc. This generated + # version of the file should be identical to plplot_h.inc. + if(GENERATE_PLPLOT_H_INC) + # N.B. remove the first OUTPUT file and all the copy_if_different and + # remove commands once touchup.ml is changed to have multi-directory + # capability. + add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/plplot_h + ${CMAKE_CURRENT_BINARY_DIR}/generated_plplot_h.inc + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/plplot_h ${CMAKE_CURRENT_BINARY_DIR}/plplot_h + COMMAND ${OCAML} ${CMAKE_CURRENT_SOURCE_DIR}/touchup.ml + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/plplot_h.inc ${CMAKE_CURRENT_BINARY_DIR}/generated_plplot_h.inc + COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/plplot_h.inc + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/plplot_h + ${CMAKE_CURRENT_SOURCE_DIR}/touchup.ml + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + add_custom_target(generate_plplot_h.inc + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/generated_plplot_h.inc + ) + endif(GENERATE_PLPLOT_H_INC) + #Detailed CMake logic to build ocaml bindings for PLplot. set(camlidl_GENERATED_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.h Modified: trunk/cmake/modules/ocaml.cmake =================================================================== --- trunk/cmake/modules/ocaml.cmake 2009-09-20 20:26:41 UTC (rev 10441) +++ trunk/cmake/modules/ocaml.cmake 2009-09-20 22:08:21 UTC (rev 10442) @@ -101,3 +101,46 @@ ) endif(ENABLE_ocaml) + +if(ENABLE_ocaml) + option(GENERATE_PLPLOT_H_INC "Generate generated_plplot_h.inc" OFF) + + if(GENERATE_PLPLOT_H_INC) + find_program(OCAML ocaml) + if (OCAML) + message(STATUS "OCAML = ${OCAML}") + else (OCAML) + message(STATUS "WARNING:" + "ocaml not found. Disabling generation of generated_plplot_h.inc") + set(GENERATE_PLPLOT_H_INC OFF CACHE BOOL "Generate generated_plplot_h.inc" FORCE) + endif (OCAML) + endif(GENERATE_PLPLOT_H_INC) + + # Test for availability of topfind and pcre (and unix). + if(GENERATE_PLPLOT_H_INC) + set(text +"#use \"topfind\";; +#require \"unix\";; +#require \"pcre\";; +" + ) + file(WRITE ${CMAKE_BINARY_DIR}/test_ocaml.ml ${text}) + # For some reason the return code is not set if an error occurs + # with test_ocaml.ml so look for any stdout or stderr output as a sign + # of an error condition. + execute_process( + COMMAND ${OCAML} test_ocaml.ml + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + OUTPUT_VARIABLE output + ERROR_VARIABLE error + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_STRIP_TRAILING_WHITESPACE + ) + if(output OR error) + message(STATUS "WARNING:" + "One or all of topfind, unix, or pcre components of ocaml are not installed. Disabling generation of generated_plplot_h.inc") + set(GENERATE_PLPLOT_H_INC OFF CACHE BOOL "Generate generated_plplot_h.inc" FORCE) + endif(output OR error) + + endif(GENERATE_PLPLOT_H_INC) +endif(ENABLE_ocaml) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |