1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
|
# -*- mode: cmake -*-
# bindings/ocaml/plcairo/CMakeLists.txt
### Process this file with cmake to produce Makefile
#
#
# Copyright (C) 2008 Andrew Ross
# Copyright (C) 2009 Alan W. Irwin
# Copyright (C) 2009 Hezekiah M. Carty
#
# This file is part of PLplot.
#
# PLplot is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as published
# by the Free Software Foundation; version 2 of the License.
#
# PLplot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with PLplot; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
if(ENABLE_ocaml AND OCAML_HAS_CAIRO)
# locations of plplot.cma and plplot.cmxa
set(PATH_TO_PLPLOT_CMA ${CMAKE_BINARY_DIR}/bindings/ocaml)
set(PATH_TO_PLPLOT_CMXA ${CMAKE_BINARY_DIR}/bindings/ocaml)
# ocamlc -c compiles *.c into *.o.
# ocamlmklib links *.o into *.so and *.a
string(REGEX REPLACE " " ";" CAIRO_LINK_FLAGS_LIST "${CAIRO_LINK_FLAGS}")
#message(STATUS "DEBUG: CAIRO_LINK_FLAGS_LIST = ${CAIRO_LINK_FLAGS_LIST}")
add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/plcairo_impl.o
${CMAKE_CURRENT_BINARY_DIR}/dllplcairo_stubs.so
${CMAKE_CURRENT_BINARY_DIR}/libplcairo_stubs.a
COMMAND ${OCAMLC} -ccopt "${CAIRO_COMPILE_FLAGS}" -cclib "${CAIRO_LINK_FLAGS}" -ccopt -I${CMAKE_SOURCE_DIR}/include -ccopt -I${CMAKE_BINARY_DIR}/include -ccopt -I${CMAKE_SOURCE_DIR}/lib/qsastime -ccopt -I${CMAKE_BINARY_DIR} -ccopt -DPLPLOT_HAVE_CONFIG_H -c ${CMAKE_CURRENT_SOURCE_DIR}/plcairo_impl.c
COMMAND ${OCAMLMKLIB} -o plcairo_stubs ${CAIRO_LINK_FLAGS_LIST} -L${CMAKE_BINARY_DIR}/src -lplplot${LIB_TAG} ${CMAKE_CURRENT_BINARY_DIR}/plcairo_impl.o
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/plcairo_impl.c
plplot${LIB_TAG}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(target_lib_plcairo_stubs
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/dllplcairo_stubs.so
${CMAKE_CURRENT_BINARY_DIR}/libplcairo_stubs.a
)
# ocamlfind ocamlc -c compiles *.mli into *.cmi
add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/plcairo.mli
${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmi
# ocamlc *.mli source file must be in ${CMAKE_CURRENT_BINARY_DIR}.
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/plcairo.mli ${CMAKE_CURRENT_BINARY_DIR}/plcairo.mli
COMMAND ${OCAMLFIND} ocamlc -package cairo -c ${CMAKE_CURRENT_BINARY_DIR}/plcairo.mli
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/plcairo.mli
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(target_plcairo_cmi
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmi
)
# ocamlfind ocamlc -c compiles *.ml into *.cmo and simultaneously
# checks against *.cmi produced from *.mli above.
add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmo
${CMAKE_CURRENT_BINARY_DIR}/plcairo.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}/plcairo.ml ${CMAKE_CURRENT_BINARY_DIR}/plcairo.ml
COMMAND ${OCAMLFIND} ocamlc -package cairo -I ${PATH_TO_PLPLOT_CMA} plplot.cma -c ${CMAKE_CURRENT_BINARY_DIR}/plcairo.ml
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/plcairo.ml
${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmi
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(target_plcairo_cmo
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmo
)
# ocamlc -a -custom builds a *.cma library from *.cmo
add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/plcairo.cma
COMMAND ${OCAMLC} -a -custom -o ${CMAKE_CURRENT_BINARY_DIR}/plcairo.cma -I ${PATH_TO_PLPLOT_CMA} plplot.cma ${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmo -dllib -lplcairo_stubs -ccopt -L${CMAKE_CURRENT_BINARY_DIR} -cclib -lplcairo_stubs -ccopt -L${CMAKE_BINARY_DIR}/src -cclib -lplplot${LIB_TAG} -dllpath ${CMAKE_BINARY_DIR}/src
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmo
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(target_plcairo_cma
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/plcairo.cma
)
# 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_plcairo_cmi target_lib_plcairo_stubs target_plplot_cma)
add_dependencies(target_plcairo_cmo target_plcairo_cmi)
add_dependencies(target_plcairo_cma target_plcairo_cmo)
add_custom_target(plcairo_ocaml ALL)
if(OCAMLOPT)
# ocamlfind ocamlopt compiles *.ml into *.o and *.cmx and simultaneously
# checks against *.cmi produced from *.mli above.
add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmx
${CMAKE_CURRENT_BINARY_DIR}/plcairo.o
${CMAKE_CURRENT_BINARY_DIR}/plcairo.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}/plcairo.ml ${CMAKE_CURRENT_BINARY_DIR}/plcairo.ml
COMMAND ${OCAMLFIND} ocamlopt -package cairo -I ${PATH_TO_PLPLOT_CMXA} -c ${CMAKE_CURRENT_BINARY_DIR}/plcairo.ml
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/plcairo.ml
${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmi
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(target_plcairo_cmx
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmx
)
# ocamlopt -a builds the libraries *.cmxa and *.a respectively from
# the *.cmx and *.o files. The plplot_stubs library also plays
# a role.
add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmxa
${CMAKE_CURRENT_BINARY_DIR}/plcairo.a
COMMAND ${OCAMLOPT} -a -o ${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmxa -I ${PATH_TO_PLPLOT_CMXA} ${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmx -ccopt -L${CMAKE_CURRENT_BINARY_DIR} -cclib -lplcairo_stubs -ccopt -L${CMAKE_BINARY_DIR}/src -cclib -lplplot${LIB_TAG}
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmx
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(target_plcairo_cmxa
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmxa
)
# Must serialize these targets against highest dependency ocamlc
# target, target_plplot_cma, because of common custom commands in
# their file-dependency chains which would be screwed up in a
# parallel build without this serialization.
add_dependencies(target_plcairo_cmx target_plcairo_cma target_plplot_cmxa)
add_dependencies(target_plcairo_cmxa target_plcairo_cmx)
add_dependencies(plcairo_ocaml target_plcairo_cmxa)
# Need to keep track of file dependencies since this is a custom target.
set_property(GLOBAL PROPERTY FILES_plcairo_ocaml
${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmxa
${CMAKE_CURRENT_BINARY_DIR}/plcairo.a
)
else (OCAMLOPT)
add_dependencies(plcairo_ocaml target_plcairo_cma)
# Need to keep track of file dependencies since this is a custom target.
set_property(GLOBAL PROPERTY FILES_plcairo_ocaml
${CMAKE_CURRENT_BINARY_DIR}/plcairo.cma
)
endif(OCAMLOPT)
if(OCAMLFIND AND OCAMLDOC)
# Build OCaml API reference documentation
set(OCAMLDOC_FILE_LIST
Plcairo.html
index.html
index_attributes.html
index_class_types.html
index_classes.html
index_exceptions.html
index_methods.html
index_module_types.html
index_modules.html
index_types.html
index_values.html
style.css
type_Plcairo.html
)
set(OCAMLDOC_FILES)
foreach(html_file ${OCAMLDOC_FILE_LIST})
list(APPEND OCAMLDOC_FILES ${CMAKE_CURRENT_BINARY_DIR}/${html_file})
endforeach(html_file ${OCAMLDOC_FILE_LIST})
# ocamldoc builds the module's documentation using specially formatted
# comments in the source file. Source can be a .ml or a .mli.
add_custom_command(
OUTPUT ${OCAMLDOC_FILES}
COMMAND ${OCAMLFIND} doc -package cairo -html ${CMAKE_CURRENT_SOURCE_DIR}/plcairo.mli
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/plcairo.mli
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(target_build_ocaml_plcairo_doc DEPENDS ${OCAMLDOC_FILES})
# associated custom command has common file depends with custom command
# that is associated with target_plplot_cmi. Therefore must serialize
# the two custom targets.
add_dependencies(target_plcairo_cmi target_build_ocaml_plcairo_doc)
endif(OCAMLFIND AND OCAMLDOC)
# 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_plcairo_cmi target_lib_plcairo_stubs)
# ocamlc used regardless
add_dependencies(target_plcairo_cmo target_plcairo_cmi)
add_dependencies(target_plcairo_cma target_plcairo_cmo)
# ocamlopt only used if OCAMLOPT is true.
if(OCAMLOPT)
add_dependencies(target_plcairo_cmx target_plcairo_cmi)
add_dependencies(target_plcairo_cmxa target_plcairo_cmx)
endif(OCAMLOPT)
# Basic build done, now trying to finish up by adapting bits
# and pieces of old build procedure below.
# Configure the META file
configure_file(META.in ${CMAKE_CURRENT_BINARY_DIR}/META)
add_custom_target(plplot_ocaml_plcairo ALL)
if (OCAMLOPT)
add_dependencies(plplot_ocaml_plcairo target_plcairo_cma target_plcairo_cmxa)
else (OCAMLOPT)
add_dependencies(plplot_ocaml_plcairo target_plcairo_cma)
endif (OCAMLOPT)
set(OCAML_FULL_INSTALL_FILES
${CMAKE_CURRENT_BINARY_DIR}/plcairo.cma
${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmi
${CMAKE_CURRENT_BINARY_DIR}/libplcairo_stubs.a
${CMAKE_CURRENT_BINARY_DIR}/plcairo.mli
)
if (OCAMLOPT)
set(OCAML_FULL_INSTALL_FILES
${OCAML_FULL_INSTALL_FILES}
${CMAKE_CURRENT_BINARY_DIR}/plcairo.cmxa
${CMAKE_CURRENT_BINARY_DIR}/plcairo.a
)
endif (OCAMLOPT)
# Most files go in the plcairo subdirectory
install(FILES ${OCAML_FULL_INSTALL_FILES} ${CMAKE_CURRENT_BINARY_DIR}/META
DESTINATION ${OCAML_INSTALL_DIR}/plcairo
)
# Shared library stubs go in stublibs. Use SO_PERMISSIONS to
# be consistent with permissions used for shared objects created
# by the add_library command.
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/dllplcairo_stubs.so
DESTINATION ${OCAML_INSTALL_DIR}/stublibs
PERMISSIONS ${SO_PERMISSIONS}
)
endif(ENABLE_ocaml AND OCAML_HAS_CAIRO)
|