From: <ai...@us...> - 2009-09-19 20:46:51
|
Revision: 10433 http://plplot.svn.sourceforge.net/plplot/?rev=10433&view=rev Author: airwin Date: 2009-09-19 20:46:45 +0000 (Sat, 19 Sep 2009) Log Message: ----------- Remove old build system for ocaml bindings since new build system appears to be working. Modified Paths: -------------- trunk/bindings/ocaml/CMakeLists.txt trunk/cmake/modules/ocaml.cmake trunk/examples/ocaml/CMakeLists.txt Removed Paths: ------------- trunk/bindings/ocaml/libplplot_stubs.clib trunk/bindings/ocaml/myocamlbuild.ml.cmake Modified: trunk/bindings/ocaml/CMakeLists.txt =================================================================== --- trunk/bindings/ocaml/CMakeLists.txt 2009-09-19 18:49:02 UTC (rev 10432) +++ trunk/bindings/ocaml/CMakeLists.txt 2009-09-19 20:46:45 UTC (rev 10433) @@ -22,362 +22,193 @@ if(ENABLE_ocaml) - if(OCAML_NEW_BUILD) + #Detailed CMake logic to build ocaml bindings for PLplot. + set(camlidl_GENERATED_SOURCE + ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.h + ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.ml + ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.mli + ${CMAKE_CURRENT_BINARY_DIR}/plplot_core_stubs.c + ) - #Detailed CMake logic to build ocaml bindings for PLplot. - set(camlidl_GENERATED_SOURCE - ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.h - ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.ml - ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.mli - ${CMAKE_CURRENT_BINARY_DIR}/plplot_core_stubs.c - ) + add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.idl + ${camlidl_GENERATED_SOURCE} + # camlidl source file must be in ${CMAKE_CURRENT_BINARY_DIR}. + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/plplot_core.idl ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.idl + COMMAND camlidl -header -I ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.idl + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/plplot_core.idl + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.idl - ${camlidl_GENERATED_SOURCE} - # camlidl source file must be in ${CMAKE_CURRENT_BINARY_DIR}. - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/plplot_core.idl ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.idl - COMMAND camlidl -header -I ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.idl - DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/plplot_core.idl - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - ) - - add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/plplot_core_stubs.o - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/plplot_impl.o - ${CMAKE_CURRENT_BINARY_DIR}/dllplplot_stubs.so - ${CMAKE_CURRENT_BINARY_DIR}/libplplot_stubs.a - COMMAND ocamlc -c ${CMAKE_CURRENT_BINARY_DIR}/plplot_core_stubs.c - COMMAND ocamlc -ccopt -I${CMAKE_SOURCE_DIR}/include -ccopt -I${CMAKE_BINARY_DIR}/include -ccopt -I${CMAKE_SOURCE_DIR}/lib/qsastime -c ${CMAKE_CURRENT_SOURCE_DIR}/plplot_impl.c - COMMAND ocamlmklib -o plplot_stubs -L${CAMLIDL_LIB_DIR} -lcamlidl -L${CMAKE_BINARY_DIR}/src -lplplot${LIB_TAG} ${CMAKE_CURRENT_BINARY_DIR}/plplot_core_stubs.o ${CMAKE_CURRENT_BINARY_DIR}/plplot_impl.o - DEPENDS - ${CMAKE_CURRENT_BINARY_DIR}/plplot_core_stubs.c - ${CMAKE_CURRENT_SOURCE_DIR}/plplot_impl.c - plplot${LIB_TAG} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - ) - add_custom_target(target_lib_plplot_stubs - DEPENDS - ${CMAKE_CURRENT_BINARY_DIR}/dllplplot_stubs.so - ${CMAKE_CURRENT_BINARY_DIR}/libplplot_stubs.a - ) - - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmi - ${CMAKE_CURRENT_BINARY_DIR}/plplot.mli - ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmi - COMMAND ocamlc -c ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.mli - # ocamlc *.mli source file must be in ${CMAKE_CURRENT_BINARY_DIR}. - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/plplot.mli ${CMAKE_CURRENT_BINARY_DIR}/plplot.mli - COMMAND ocamlc -c ${CMAKE_CURRENT_BINARY_DIR}/plplot.mli - DEPENDS - ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.mli - ${CMAKE_CURRENT_SOURCE_DIR}/plplot.mli - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - ) - add_custom_target(target_plplot_core_cmi - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmi - ) - - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmo - ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmx - ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.o - ${CMAKE_CURRENT_BINARY_DIR}/plplot.ml - ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmo - ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmx - ${CMAKE_CURRENT_BINARY_DIR}/plplot.o - COMMAND ocamlc -c ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.ml - COMMAND ocamlopt -c ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.ml - # ocamlc and ocamlopt *.ml source file must be in - # ${CMAKE_CURRENT_BINARY_DIR}. - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/plplot.ml ${CMAKE_CURRENT_BINARY_DIR}/plplot.ml - COMMAND ocamlc -c ${CMAKE_CURRENT_BINARY_DIR}/plplot.ml - COMMAND ocamlopt -c ${CMAKE_CURRENT_BINARY_DIR}/plplot.ml - DEPENDS - ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.ml - ${CMAKE_CURRENT_SOURCE_DIR}/plplot.ml - ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmi - ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmi - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - ) - add_custom_target(target_plplot_core_cmo - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmo - ) - - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/plplot.cma - ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmxa - ${CMAKE_CURRENT_BINARY_DIR}/plplot.a - COMMAND ocamlc -a -custom -o ${CMAKE_CURRENT_BINARY_DIR}/plplot.cma ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmo ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmo -dllib -lplplot_stubs -ccopt -L${CMAKE_CURRENT_BINARY_DIR} -cclib -lplplot_stubs -ccopt -L${CAMLIDL_LIB_DIR} -cclib -lcamlidl -ccopt -L${CMAKE_BINARY_DIR}/src -cclib -lplplot${LIB_TAG} -dllpath ${CMAKE_BINARY_DIR}/src - COMMAND ocamlopt -a -o ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmxa ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmx ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmx -ccopt -L${CMAKE_CURRENT_BINARY_DIR} -cclib -lplplot_stubs -ccopt -L${CAMLIDL_LIB_DIR} -cclib -lcamlidl -ccopt -L${CMAKE_BINARY_DIR}/src -cclib -lplplot${LIB_TAG} - DEPENDS - ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmo - ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmo - ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmx - ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmx - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - ) - add_custom_target(target_plplot_cma - DEPENDS - ${CMAKE_CURRENT_BINARY_DIR}/plplot.cma - ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmxa - ) - - # These targets depend on common files in their respective - # file-dependency chains. Therefore, to avoid screwing up parallel - # builds must serialize with target depends. - add_dependencies(target_plplot_core_cmi target_lib_plplot_stubs) - add_dependencies(target_plplot_core_cmo target_plplot_core_cmi) - add_dependencies(target_plplot_cma target_plplot_core_cmo) - - # Basic build done, now trying to finish up by adapting bits - # and pieces of old build procedure below. - - # Configure the META file - # Configure pkg-config *.pc file corresponding to plplot.cma - if(PKG_CONFIG_EXECUTABLE) - if(LIB_TAG) - set(PC_PRECISION "double") - else(LIB_TAG) - set(PC_PRECISION "single") - endif(LIB_TAG) - # Each list element must consist of a colon-separated string with the - # following fields which are parsed out in the foreach loop below and - # used to configure the corresponding pkg-config *.pc file. - # BINDING - ENABLE_${BINDING} keeps track of whether a - # binding has been enabled (ON) or not (OFF). - # Also, ${BINDING} used to determine PC_FILE_SUFFIX - # which helps to determine name of configured - # *.pc file. - # PC_SHORT_NAME - Used in *.pc NAME: field - # PC_LONG_NAME - Used in *.pc Description: field - # PC_LIBRARY_NAME - Used in *.pc Libs: field - # Also used to determine PC_LINK_FLAGS and - # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags: - # fields. - set(PC_DATA "ocaml:::plplot${LIB_TAG}") - - string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA}) - set(PC_FILE_SUFFIX "-${BINDING}") - set(PC_REQUIRES "plplot${LIB_TAG}") - string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA}) - string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA}) - string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA}) - set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}") - set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}") - set(PC_LINK_FLAGS "-l${PC_LIBRARY_NAME} ${PC_LINK_FLAGS}") - set(PC_CONFIGURED_FILE - ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc - ) - configure_file( - ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake - ${PC_CONFIGURED_FILE} - @ONLY - ) - install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR}) - configure_file(META.cmake ${CMAKE_CURRENT_BINARY_DIR}/META) - endif(PKG_CONFIG_EXECUTABLE) - - add_custom_target(plplot_ocaml ALL) - add_dependencies(plplot_ocaml target_plplot_cma) - - # Need to keep track of file dependencies since this is a custom target. - set_property(GLOBAL PROPERTY FILES_plplot_ocaml - ${CMAKE_CURRENT_BINARY_DIR}/plplot.cma - ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmxa - ${CMAKE_CURRENT_BINARY_DIR}/plplot.a - ) - - set(OCAML_FULL_INSTALL_FILES - ${CMAKE_CURRENT_BINARY_DIR}/plplot.cma - ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmxa - ${CMAKE_CURRENT_BINARY_DIR}/plplot.a - ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmi - ${CMAKE_CURRENT_BINARY_DIR}/libplplot_stubs.a - ${CMAKE_CURRENT_BINARY_DIR}/plplot.mli - ) - - # Most files go in the plplot subdirectory - install(FILES ${OCAML_FULL_INSTALL_FILES} ${CMAKE_CURRENT_BINARY_DIR}/META - DESTINATION ${OCAML_INSTALL_DIR}/plplot - ) - - # Shared library stubs go in stublibs - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/dllplplot_stubs.so - DESTINATION ${OCAML_INSTALL_DIR}/stublibs - ) - - else(OCAML_NEW_BUILD) - - set(SOURCE_LIST - libplplot_stubs.clib - plplot_h - plplot_h.inc - plplot_core.idl - plplot_impl.c - plplot.ml - plplot.mli - touchup.ml + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/plplot_core_stubs.o + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/plplot_impl.o + ${CMAKE_CURRENT_BINARY_DIR}/dllplplot_stubs.so + ${CMAKE_CURRENT_BINARY_DIR}/libplplot_stubs.a + COMMAND ocamlc -c ${CMAKE_CURRENT_BINARY_DIR}/plplot_core_stubs.c + COMMAND ocamlc -ccopt -I${CMAKE_SOURCE_DIR}/include -ccopt -I${CMAKE_BINARY_DIR}/include -ccopt -I${CMAKE_SOURCE_DIR}/lib/qsastime -c ${CMAKE_CURRENT_SOURCE_DIR}/plplot_impl.c + COMMAND ocamlmklib -o plplot_stubs -L${CAMLIDL_LIB_DIR} -lcamlidl -L${CMAKE_BINARY_DIR}/src -lplplot${LIB_TAG} ${CMAKE_CURRENT_BINARY_DIR}/plplot_core_stubs.o ${CMAKE_CURRENT_BINARY_DIR}/plplot_impl.o + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/plplot_core_stubs.c + ${CMAKE_CURRENT_SOURCE_DIR}/plplot_impl.c + plplot${LIB_TAG} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) - - set(OCAML_INSTALL_FILES - plplot.cma - plplot.cmxa - plplot.a - plplot.cmi - libplplot_stubs.a - plplot.mli + add_custom_target(target_lib_plplot_stubs + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/dllplplot_stubs.so + ${CMAKE_CURRENT_BINARY_DIR}/libplplot_stubs.a ) - - set(OCAML_FULL_INSTALL_FILES) - foreach(OCAML_FILE ${OCAML_INSTALL_FILES}) - 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 pkg-config *.pc file corresponding to plplot.cma -if(PKG_CONFIG_EXECUTABLE) - if(LIB_TAG) - set(PC_PRECISION "double") - else(LIB_TAG) - set(PC_PRECISION "single") - endif(LIB_TAG) - # Each list element must consist of a colon-separated string with the - # following fields which are parsed out in the foreach loop below and - # used to configure the corresponding pkg-config *.pc file. - # BINDING - ENABLE_${BINDING} keeps track of whether a - # binding has been enabled (ON) or not (OFF). - # Also, ${BINDING} used to determine PC_FILE_SUFFIX - # which helps to determine name of configured - # *.pc file. - # PC_SHORT_NAME - Used in *.pc NAME: field - # PC_LONG_NAME - Used in *.pc Description: field - # PC_LIBRARY_NAME - Used in *.pc Libs: field - # Also used to determine PC_LINK_FLAGS and - # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags: - # fields. - set(PC_DATA "ocaml:::plplot${LIB_TAG}") - string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA}) - set(PC_FILE_SUFFIX "-${BINDING}") - set(PC_REQUIRES "plplot${LIB_TAG}") - string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA}) - string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA}) - string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA}) - set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}") - set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}") - set(PC_LINK_FLAGS "-l${PC_LIBRARY_NAME} ${PC_LINK_FLAGS}") - set(PC_CONFIGURED_FILE - ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc - ) - configure_file( - ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake - ${PC_CONFIGURED_FILE} - @ONLY - ) - install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR}) - configure_file(META.cmake ${CMAKE_CURRENT_BINARY_DIR}/META) -endif(PKG_CONFIG_EXECUTABLE) - - # Configure the file controlling the ocamlbuild process - configure_file(myocamlbuild.ml.cmake ${CMAKE_CURRENT_BINARY_DIR}/myocamlbuild.ml) - # 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 - foreach(SRC_FILE ${SOURCE_LIST}) - add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} - COMMAND ${CMAKE_COMMAND} - -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} - DEPENDS ${CMAKE_CURRENT_SOURCE_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 - - # 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} + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmi + ${CMAKE_CURRENT_BINARY_DIR}/plplot.mli + ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmi + COMMAND ocamlc -c ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.mli + # ocamlc *.mli source file must be in ${CMAKE_CURRENT_BINARY_DIR}. + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/plplot.mli ${CMAKE_CURRENT_BINARY_DIR}/plplot.mli + COMMAND ocamlc -c ${CMAKE_CURRENT_BINARY_DIR}/plplot.mli + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.mli + ${CMAKE_CURRENT_SOURCE_DIR}/plplot.mli WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) - add_custom_target( - plplot_ocaml_bytecode - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.cma + add_custom_target(target_plplot_core_cmi + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmi ) - - # Build native version. + add_custom_command( 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}/plplot_core.cmo + ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmx + ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.o + ${CMAKE_CURRENT_BINARY_DIR}/plplot.ml + ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmo + ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmx + ${CMAKE_CURRENT_BINARY_DIR}/plplot.o + COMMAND ocamlc -c ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.ml + COMMAND ocamlopt -c ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.ml + # ocamlc and ocamlopt *.ml source file must be in + # ${CMAKE_CURRENT_BINARY_DIR}. + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/plplot.ml ${CMAKE_CURRENT_BINARY_DIR}/plplot.ml + COMMAND ocamlc -c ${CMAKE_CURRENT_BINARY_DIR}/plplot.ml + COMMAND ocamlopt -c ${CMAKE_CURRENT_BINARY_DIR}/plplot.ml + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.ml + ${CMAKE_CURRENT_SOURCE_DIR}/plplot.ml + ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmi + ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmi WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) - add_custom_target( - plplot_ocaml_native + add_custom_target(target_plplot_core_cmo + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmo + ) + + add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/plplot.cma + ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmxa + ${CMAKE_CURRENT_BINARY_DIR}/plplot.a + COMMAND ocamlc -a -custom -o ${CMAKE_CURRENT_BINARY_DIR}/plplot.cma ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmo ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmo -dllib -lplplot_stubs -ccopt -L${CMAKE_CURRENT_BINARY_DIR} -cclib -lplplot_stubs -ccopt -L${CAMLIDL_LIB_DIR} -cclib -lcamlidl -ccopt -L${CMAKE_BINARY_DIR}/src -cclib -lplplot${LIB_TAG} -dllpath ${CMAKE_BINARY_DIR}/src + COMMAND ocamlopt -a -o ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmxa ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmx ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmx -ccopt -L${CMAKE_CURRENT_BINARY_DIR} -cclib -lplplot_stubs -ccopt -L${CAMLIDL_LIB_DIR} -cclib -lcamlidl -ccopt -L${CMAKE_BINARY_DIR}/src -cclib -lplplot${LIB_TAG} DEPENDS - ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.cmxa - ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/plplot.a + ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmo + ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmo + ${CMAKE_CURRENT_BINARY_DIR}/plplot_core.cmx + ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmx + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) - # 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(target_plplot_cma + DEPENDS + ${CMAKE_CURRENT_BINARY_DIR}/plplot.cma + ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmxa + ) + # These targets depend on common files in their respective + # file-dependency chains. Therefore, to avoid screwing up parallel + # builds must serialize with target depends. + add_dependencies(target_plplot_core_cmi target_lib_plplot_stubs) + add_dependencies(target_plplot_core_cmo target_plplot_core_cmi) + add_dependencies(target_plplot_cma target_plplot_core_cmo) + + # Basic build done, now trying to finish up by adapting bits + # and pieces of old build procedure below. + + # Configure the META file + # Configure pkg-config *.pc file corresponding to plplot.cma + if(PKG_CONFIG_EXECUTABLE) + if(LIB_TAG) + set(PC_PRECISION "double") + else(LIB_TAG) + set(PC_PRECISION "single") + endif(LIB_TAG) + # Each list element must consist of a colon-separated string with the + # following fields which are parsed out in the foreach loop below and + # used to configure the corresponding pkg-config *.pc file. + # BINDING - ENABLE_${BINDING} keeps track of whether a + # binding has been enabled (ON) or not (OFF). + # Also, ${BINDING} used to determine PC_FILE_SUFFIX + # which helps to determine name of configured + # *.pc file. + # PC_SHORT_NAME - Used in *.pc NAME: field + # PC_LONG_NAME - Used in *.pc Description: field + # PC_LIBRARY_NAME - Used in *.pc Libs: field + # Also used to determine PC_LINK_FLAGS and + # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags: + # fields. + set(PC_DATA "ocaml:::plplot${LIB_TAG}") + + string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA}) + set(PC_FILE_SUFFIX "-${BINDING}") + set(PC_REQUIRES "plplot${LIB_TAG}") + string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA}) + string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA}) + string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA}) + set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}") + set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}") + set(PC_LINK_FLAGS "-l${PC_LIBRARY_NAME} ${PC_LINK_FLAGS}") + set(PC_CONFIGURED_FILE + ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc + ) + configure_file( + ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake + ${PC_CONFIGURED_FILE} + @ONLY + ) + install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR}) + configure_file(META.cmake ${CMAKE_CURRENT_BINARY_DIR}/META) + endif(PKG_CONFIG_EXECUTABLE) + add_custom_target(plplot_ocaml ALL) - add_dependencies(plplot_ocaml plplot_ocaml_native) + add_dependencies(plplot_ocaml target_plplot_cma) # 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 + ${CMAKE_CURRENT_BINARY_DIR}/plplot.cma + ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmxa + ${CMAKE_CURRENT_BINARY_DIR}/plplot.a ) + set(OCAML_FULL_INSTALL_FILES + ${CMAKE_CURRENT_BINARY_DIR}/plplot.cma + ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmxa + ${CMAKE_CURRENT_BINARY_DIR}/plplot.a + ${CMAKE_CURRENT_BINARY_DIR}/plplot.cmi + ${CMAKE_CURRENT_BINARY_DIR}/libplplot_stubs.a + ${CMAKE_CURRENT_BINARY_DIR}/plplot.mli + ) + # Most files go in the plplot subdirectory install(FILES ${OCAML_FULL_INSTALL_FILES} ${CMAKE_CURRENT_BINARY_DIR}/META DESTINATION ${OCAML_INSTALL_DIR}/plplot ) # Shared library stubs go in stublibs - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${OCAML_BUILD_DIR}/dllplplot_stubs.so + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/dllplplot_stubs.so DESTINATION ${OCAML_INSTALL_DIR}/stublibs ) - # 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(OCAML_NEW_BUILD) - endif(ENABLE_ocaml) Deleted: trunk/bindings/ocaml/libplplot_stubs.clib =================================================================== --- trunk/bindings/ocaml/libplplot_stubs.clib 2009-09-19 18:49:02 UTC (rev 10432) +++ trunk/bindings/ocaml/libplplot_stubs.clib 2009-09-19 20:46:45 UTC (rev 10433) @@ -1 +0,0 @@ -plplot_impl.o plplot_core_stubs.o Deleted: trunk/bindings/ocaml/myocamlbuild.ml.cmake =================================================================== --- trunk/bindings/ocaml/myocamlbuild.ml.cmake 2009-09-19 18:49:02 UTC (rev 10432) +++ trunk/bindings/ocaml/myocamlbuild.ml.cmake 2009-09-19 20:46:45 UTC (rev 10433) @@ -1,56 +0,0 @@ -open Ocamlbuild_plugin -open Command - -(* The camlidl command to use (default: first one found in $PATH) *) -let camlidl = S([A"camlidl"; A"-header"]) - -(* Files included in the main idl descriptor *) -let idl_includes = ["plplot_h.inc"] -;; - -dispatch begin function - | After_rules -> - (* Handle *.idl files properly... I think *) - rule "camlidl processing" - ~prods:["%.mli"; "%.ml"; "%_stubs.c"] - ~deps:["%.idl"] - begin fun env _build -> - let idl = env "%.idl" in - let tags = tags_of_pathname idl++"compile"++"camlidl" in - let cmd = Cmd(S[camlidl; T tags; P idl]) in - Seq [cmd] - end; - - (* Include the plplot and camlidl compiler options for ocamlmklib *) - flag ["ocamlmklib"; "c"] - (S[A"-L@BUILD_DIR@/src"; A"-lplplot@LIB_TAG@"; - A"-L@CAMLIDL_LIB_DIR@"; A"-lcamlidl"]); - - (* gcc needs to know where to find the needed #includes *) - flag ["c"; "compile"] - (S[A"-ccopt"; A"-I@SOURCE_DIR@/include"; - A"-ccopt"; A"-I@SOURCE_DIR@/lib/qsastime"; - A"-ccopt"; A"-I@BUILD_DIR@/include"] ); - - (* Custom tag for OCaml bytecode *) - flag ["ocaml"; "link"; "byte"] - (A"-custom"); - - (* Use the proper extras when compiling the OCaml library *) - flag ["ocaml"; "link"; "library"; "byte"] - (S[A"-dllib"; A"-lplplot_stubs"; A"-cclib"; A"-lplplot_stubs"; - A"-cclib"; A"-lplplot@LIB_TAG@"; A"-cclib"; A"-lcamlidl"]); - - flag ["ocaml"; "link"; "library"; "native"] - (S[A"-cclib"; A"-lplplot_stubs"; - A"-cclib"; A"-lplplot@LIB_TAG@"; - A"-cclib"; A"-lcamlidl"]); - - (* Make sure the C pieces and built... *) - dep ["ocaml"; "compile"] ["libplplot_stubs.a"]; - - (* Any camlidl work must be updated if the camlidl inputs are changed *) - dep ["compile"; "camlidl"] idl_includes; - - | _ -> () -end Modified: trunk/cmake/modules/ocaml.cmake =================================================================== --- trunk/cmake/modules/ocaml.cmake 2009-09-19 18:49:02 UTC (rev 10432) +++ trunk/cmake/modules/ocaml.cmake 2009-09-19 20:46:45 UTC (rev 10433) @@ -94,14 +94,6 @@ set(ENABLE_ocaml OFF CACHE BOOL "Enable OCaml bindings" FORCE) endif(CAMLIDL_LIB_DIR) - option(OCAML_NEW_BUILD "Try new detailed OCaml build method?" ON) - - if(NOT OCAML_NEW_BUILD) - # For the old-style build, a subdirectory is required for ocamlbuild - # to use for the build. - set(OCAML_BUILD_DIR _build CACHE PATH "Subdirectory to use for ocamlbuild") - endif(NOT OCAML_NEW_BUILD) - # Installation follows the Debian ocaml policy for want of a better # standard. set(OCAML_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib/ocaml/${OCAML_VERSION} Modified: trunk/examples/ocaml/CMakeLists.txt =================================================================== --- trunk/examples/ocaml/CMakeLists.txt 2009-09-19 18:49:02 UTC (rev 10432) +++ trunk/examples/ocaml/CMakeLists.txt 2009-09-19 20:46:45 UTC (rev 10433) @@ -91,11 +91,7 @@ if(BUILD_TEST) set(ocaml_EXTRA_CLEAN_FILES) if(CORE_BUILD) - if(OCAML_NEW_BUILD) - set(I_OPTION ${CMAKE_BINARY_DIR}/bindings/ocaml) - else(OCAML_NEW_BUILD) - set(I_OPTION ${CMAKE_BINARY_DIR}/bindings/ocaml/${OCAML_BUILD_DIR}) - endif(OCAML_NEW_BUILD) + set(I_OPTION ${CMAKE_BINARY_DIR}/bindings/ocaml) set(ccopt_OPTION "-L ${CMAKE_BINARY_DIR}/src -Wl,-rpath -Wl,${CMAKE_BINARY_DIR}/src ") else(CORE_BUILD) set(I_OPTION ${OCAML_INSTALL_DIR}/plplot) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |