PageRenderTime 57ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_9_8/bindings/tcl/CMakeLists.txt

#
CMake | 394 lines | 295 code | 41 blank | 58 comment | 12 complexity | 89f2593b389618d38f3cd4d96ea592de MD5 | raw file
Possible License(s): LGPL-2.0, BSD-3-Clause-No-Nuclear-License-2014, Apache-2.0, GPL-2.0
  1. # bindings/tcl/CMakeLists.txt
  2. ### Process this file with cmake to produce Makefile
  3. ###
  4. # Copyright (C) 2006 Alan W. Irwin
  5. #
  6. # This file is part of PLplot.
  7. #
  8. # PLplot is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU Library General Public License as published
  10. # by the Free Software Foundation; version 2 of the License.
  11. #
  12. # PLplot is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Library General Public License
  18. # along with PLplot; if not, write to the Free Software
  19. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. if(ENABLE_tcl)
  21. # Check consistency of plplot_parameters.h.
  22. add_custom_target(
  23. check_tcl_parameters
  24. COMMAND ${CMAKE_COMMAND} -E remove -f
  25. ${CMAKE_CURRENT_BINARY_DIR}/plplot_parameters.h_compare
  26. COMMAND
  27. sed -f ${CMAKE_CURRENT_SOURCE_DIR}/global_defines.sed <
  28. ${CMAKE_SOURCE_DIR}/bindings/swig-support/plplotcapi.i >
  29. ${CMAKE_CURRENT_BINARY_DIR}/plplot_parameters.h_compare
  30. COMMAND
  31. ${CMAKE_COMMAND} -E echo "Check that plplot_parameters.h is consistent with the #defines in bindings/swig-support/plplotcapi.i"
  32. COMMAND
  33. cmp ${CMAKE_CURRENT_SOURCE_DIR}/plplot_parameters.h
  34. ${CMAKE_CURRENT_BINARY_DIR}/plplot_parameters.h_compare
  35. )
  36. # tclmatrix
  37. set(tclmatrix${LIB_TAG}_LIB_SRCS
  38. tclMatrix.c
  39. matrixInit.c
  40. )
  41. include_directories(
  42. ${TCL_INCLUDE_PATH}
  43. ${CMAKE_SOURCE_DIR}/include
  44. ${CMAKE_SOURCE_DIR}/lib/qsastime
  45. ${CMAKE_CURRENT_SOURCE_DIR}
  46. ${CMAKE_BINARY_DIR}
  47. ${CMAKE_BINARY_DIR}/include
  48. )
  49. set(
  50. libplplottcltk${LIB_TAG}_COMPILE_FLAGS
  51. "-I${TCL_INCLUDE_PATH}"
  52. )
  53. if(BUILD_SHARED_LIBS)
  54. SET_SOURCE_FILES_PROPERTIES(${tclmatrix${LIB_TAG}_LIB_SRCS}
  55. PROPERTIES COMPILE_FLAGS "-DUSINGDLL" )
  56. endif(BUILD_SHARED_LIBS)
  57. add_library(tclmatrix${LIB_TAG} ${tclmatrix${LIB_TAG}_LIB_SRCS})
  58. target_link_libraries(tclmatrix${LIB_TAG} ${TCL_LIBRARY})
  59. if(USE_RPATH)
  60. set(LIB_INSTALL_RPATH ${LIB_DIR})
  61. set_target_properties(tclmatrix${LIB_TAG}
  62. PROPERTIES
  63. SOVERSION ${tclmatrix_SOVERSION}
  64. VERSION ${tclmatrix_VERSION}
  65. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  66. INSTALL_NAME_DIR "${LIB_DIR}"
  67. )
  68. else(USE_RPATH)
  69. set_target_properties(tclmatrix${LIB_TAG}
  70. PROPERTIES
  71. SOVERSION ${tclmatrix_SOVERSION}
  72. VERSION ${tclmatrix_VERSION}
  73. INSTALL_NAME_DIR "${LIB_DIR}"
  74. )
  75. endif(USE_RPATH)
  76. install(TARGETS tclmatrix${LIB_TAG}
  77. EXPORT export_plplot
  78. ARCHIVE DESTINATION ${LIB_DIR}
  79. LIBRARY DESTINATION ${LIB_DIR}
  80. RUNTIME DESTINATION ${BIN_DIR}
  81. )
  82. set(tclmatrix${LIB_TAG}_INSTALLED_HEADERS
  83. tclMatrix.h
  84. )
  85. install(
  86. FILES ${tclmatrix${LIB_TAG}_INSTALLED_HEADERS}
  87. DESTINATION ${INCLUDE_DIR}
  88. )
  89. # end tclmatrix
  90. # plplottcltk
  91. set(
  92. tclgenfiles
  93. ${CMAKE_CURRENT_BINARY_DIR}/tclgen.h
  94. ${CMAKE_CURRENT_BINARY_DIR}/tclgen_s.h
  95. ${CMAKE_CURRENT_BINARY_DIR}/tclgen.c
  96. )
  97. add_custom_command(
  98. OUTPUT ${tclgenfiles}
  99. COMMAND ${TCL_TCLSH}
  100. ${CMAKE_CURRENT_SOURCE_DIR}/pltclgen.tcl ${CMAKE_CURRENT_SOURCE_DIR}
  101. DEPENDS
  102. ${CMAKE_CURRENT_SOURCE_DIR}/pltclgen.tcl
  103. ${CMAKE_CURRENT_SOURCE_DIR}/plapi.tpl
  104. ${CMAKE_CURRENT_SOURCE_DIR}/tclcmd.tpl
  105. )
  106. include_directories(${CMAKE_CURRENT_BINARY_DIR})
  107. set_source_files_properties(
  108. tclAPI.c
  109. PROPERTIES OBJECT_DEPENDS "${tclgenfiles}"
  110. )
  111. set(plplottcltk${LIB_TAG}_LIB_SRCS
  112. tclAPI.c
  113. tclMain.c
  114. )
  115. if(BUILD_SHARED_LIBS)
  116. set_source_files_properties(${plplottcltk${LIB_TAG}_LIB_SRCS}
  117. PROPERTIES COMPILE_FLAGS "-DUSINGDLL"
  118. )
  119. endif(BUILD_SHARED_LIBS)
  120. set(
  121. plplottcltk${LIB_TAG}_link_libraries
  122. tclmatrix${LIB_TAG}
  123. plplot${LIB_TAG}
  124. ${TCL_LIBRARY}
  125. )
  126. set(
  127. libplplottcltk${LIB_TAG}_LINK_FLAGS
  128. -ltclmatrix${LIB_TAG}
  129. ${TCL_LIBRARY}
  130. )
  131. if(ENABLE_itcl)
  132. include_directories(${ITCL_INCLUDE_PATH})
  133. set(
  134. libplplottcltk${LIB_TAG}_COMPILE_FLAGS
  135. "${libplplottcltk${LIB_TAG}_COMPILE_FLAGS} -I${ITCL_INCLUDE_PATH}"
  136. )
  137. set(plplottcltk${LIB_TAG}_link_libraries
  138. ${plplottcltk${LIB_TAG}_link_libraries}
  139. ${ITCL_LIBRARY}
  140. )
  141. set(
  142. libplplottcltk${LIB_TAG}_LINK_FLAGS
  143. ${libplplottcltk${LIB_TAG}_LINK_FLAGS}
  144. ${ITCL_LIBRARY}
  145. )
  146. endif(ENABLE_itcl)
  147. if(ENABLE_tk)
  148. set(plplottcltk${LIB_TAG}_LIB_SRCS
  149. ${plplottcltk${LIB_TAG}_LIB_SRCS}
  150. ${CMAKE_SOURCE_DIR}/bindings/tk/Pltk_Init.c
  151. ${CMAKE_SOURCE_DIR}/bindings/tk/plframe.c
  152. ${CMAKE_SOURCE_DIR}/bindings/tk/plr.c
  153. ${CMAKE_SOURCE_DIR}/bindings/tk/tcpip.c
  154. ${CMAKE_SOURCE_DIR}/bindings/tk/tkMain.c
  155. )
  156. include_directories(${TK_INCLUDE_PATH})
  157. # Transform TK_INCLUDE_PATH (which is a list) to blank-delimited flag form.
  158. string(REGEX REPLACE ";" " -I" TKLIB_COMPILE_FLAGS "-I${TK_INCLUDE_PATH}")
  159. set(
  160. libplplottcltk${LIB_TAG}_COMPILE_FLAGS
  161. "${libplplottcltk${LIB_TAG}_COMPILE_FLAGS} ${TKLIB_COMPILE_FLAGS}"
  162. )
  163. if(BUILD_SHARED_LIBS)
  164. set_source_files_properties(${plplottcltk${LIB_TAG}_LIB_SRCS}
  165. PROPERTIES COMPILE_FLAGS "-DUSINGDLL"
  166. )
  167. endif(BUILD_SHARED_LIBS)
  168. set(plplottcltk${LIB_TAG}_link_libraries
  169. ${plplottcltk${LIB_TAG}_link_libraries}
  170. ${TK_LIBRARY}
  171. )
  172. set(
  173. libplplottcltk${LIB_TAG}_LINK_FLAGS
  174. ${libplplottcltk${LIB_TAG}_LINK_FLAGS}
  175. ${TK_LIBRARY}
  176. )
  177. if(ENABLE_itk)
  178. include_directories(${ITK_INCLUDE_PATH})
  179. set(
  180. libplplottcltk${LIB_TAG}_COMPILE_FLAGS
  181. "${libplplottcltk${LIB_TAG}_COMPILE_FLAGS} -I${ITK_INCLUDE_PATH}"
  182. )
  183. set(plplottcltk${LIB_TAG}_link_libraries
  184. ${plplottcltk${LIB_TAG}_link_libraries}
  185. ${ITK_LIBRARY}
  186. )
  187. set(
  188. libplplottcltk${LIB_TAG}_LINK_FLAGS
  189. ${libplplottcltk${LIB_TAG}_LINK_FLAGS}
  190. ${ITK_LIBRARY}
  191. )
  192. endif(ENABLE_itk)
  193. endif(ENABLE_tk)
  194. # Transform "${libplplottcltk${LIB_TAG}_LINK_FLAGS}" string to the
  195. # standard pkg-config form.
  196. pkg_config_link_flags(
  197. libplplottcltk${LIB_TAG}_LINK_FLAGS
  198. "${libplplottcltk${LIB_TAG}_LINK_FLAGS}"
  199. )
  200. add_library(plplottcltk${LIB_TAG} ${plplottcltk${LIB_TAG}_LIB_SRCS})
  201. #message(STATUS
  202. #"plplottcltk${LIB_TAG}_link_libraries =
  203. #${plplottcltk${LIB_TAG}_link_libraries}"
  204. #)
  205. target_link_libraries(
  206. plplottcltk${LIB_TAG}
  207. ${plplottcltk${LIB_TAG}_link_libraries}
  208. )
  209. if(USE_RPATH)
  210. get_target_property(LIB_INSTALL_RPATH plplot${LIB_TAG} INSTALL_RPATH)
  211. set_target_properties(plplottcltk${LIB_TAG}
  212. PROPERTIES
  213. SOVERSION ${plplottcltk_SOVERSION}
  214. VERSION ${plplottcltk_VERSION}
  215. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  216. INSTALL_NAME_DIR "${LIB_DIR}"
  217. )
  218. else(USE_RPATH)
  219. set_target_properties(plplottcltk${LIB_TAG}
  220. PROPERTIES
  221. SOVERSION ${plplottcltk_SOVERSION}
  222. VERSION ${plplottcltk_VERSION}
  223. INSTALL_NAME_DIR "${LIB_DIR}"
  224. )
  225. endif(USE_RPATH)
  226. install(TARGETS plplottcltk${LIB_TAG}
  227. EXPORT export_plplot
  228. ARCHIVE DESTINATION ${LIB_DIR}
  229. LIBRARY DESTINATION ${LIB_DIR}
  230. RUNTIME DESTINATION ${BIN_DIR}
  231. )
  232. set(plplottcltk${LIB_TAG}_INSTALLED_HEADERS
  233. pltcl.h
  234. )
  235. install(
  236. FILES ${plplottcltk${LIB_TAG}_INSTALLED_HEADERS}
  237. DESTINATION ${INCLUDE_DIR}
  238. )
  239. # end plplottcltk
  240. # Generate plplot.tcl and tclIndex in build tree. At least the first one
  241. # is always needed for build-tree tests of tcl examples.
  242. add_custom_command(
  243. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/plplot.tcl
  244. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  245. ${CMAKE_SOURCE_DIR}/bindings/tk/plplot.tcl
  246. ${CMAKE_CURRENT_BINARY_DIR}/plplot.tcl
  247. DEPENDS
  248. ${CMAKE_SOURCE_DIR}/bindings/tk/plplot.tcl
  249. )
  250. # _target suffix to avoid nameclash with filename plplot.tcl. This
  251. # nameclash screwed up ../tk/configuration which had a non-generated file
  252. # of the same name which was a dependency of a custom target.
  253. add_custom_target(plplot.tcl_target ALL
  254. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/plplot.tcl
  255. )
  256. set_property(GLOBAL PROPERTY
  257. FILES_plplot.tcl_target ${CMAKE_CURRENT_BINARY_DIR}/plplot.tcl
  258. )
  259. # A Tcl expert should insert the file depends here.
  260. add_custom_command(
  261. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/tclIndex
  262. COMMAND ${TCL_TCLSH} ${MKTCLINDEX} ${MKTCLINDEX_ARGS}
  263. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  264. )
  265. add_custom_target(tclIndex_tcl ALL
  266. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tclIndex
  267. )
  268. set_property(GLOBAL PROPERTY
  269. FILES_tclIndex_tcl ${CMAKE_CURRENT_BINARY_DIR}/tclIndex
  270. )
  271. # I don't think this is necessary, but I am not sure of the file
  272. # depends of the custom_command associated with tclIndex_tcl and
  273. # serializing these targets doesn't slow down parallel builds very
  274. # much.
  275. add_dependencies(tclIndex_tcl plplot.tcl_target)
  276. if(NOT ENABLE_tk)
  277. # Only install these two files if the equivalent files are not going to
  278. # be installed by the action of ../tk/CMakeLists.txt
  279. install(
  280. FILES ${CMAKE_CURRENT_BINARY_DIR}/plplot.tcl
  281. DESTINATION ${TCL_DIR}
  282. )
  283. install(
  284. FILES ${CMAKE_CURRENT_BINARY_DIR}/tclIndex
  285. DESTINATION ${TCL_DIR}
  286. )
  287. endif(NOT ENABLE_tk)
  288. set(LIB_HARDDIR ${LIB_DIR})
  289. get_target_property(
  290. DLNAME_LIBPLPLOTTCLTK
  291. plplottcltk${LIB_TAG}
  292. LOCATION
  293. )
  294. get_filename_component(
  295. DLNAME_LIBPLPLOTTCLTK
  296. ${DLNAME_LIBPLPLOTTCLTK}
  297. NAME
  298. )
  299. string(REPLACE "plplottcltkd" "plplottcltk"
  300. DLNAME_LIBPLPLOTTCLTK
  301. ${DLNAME_LIBPLPLOTTCLTK}
  302. )
  303. string(REPLACE "plplottcltk" "plplottcltkd"
  304. DLNAME_LIBPLPLOTTCLTKD
  305. ${DLNAME_LIBPLPLOTTCLTK}
  306. )
  307. configure_file(
  308. ${CMAKE_CURRENT_SOURCE_DIR}/pkgIndex.tcl.in
  309. ${CMAKE_CURRENT_BINARY_DIR}/pkgIndex.tcl
  310. @ONLY
  311. )
  312. # Configure pkg-config *.pc file corresponding to libplplottcltk${LIB_TAG}
  313. if(PKG_CONFIG_EXECUTABLE)
  314. if(LIB_TAG)
  315. set(PC_PRECISION "double")
  316. else(LIB_TAG)
  317. set(PC_PRECISION "single")
  318. endif(LIB_TAG)
  319. # Each list element must consist of a colon-separated string with the
  320. # following fields which are parsed out in the foreach loop below and
  321. # used to configure the corresponding pkg-config *.pc file.
  322. # BINDING - ENABLE_${BINDING} keeps track of whether a
  323. # binding has been enabled (ON) or not (OFF).
  324. # Also, ${BINDING} used to determine PC_FILE_SUFFIX
  325. # which helps to determine name of configured
  326. # *.pc file.
  327. # PC_SHORT_NAME - Used in *.pc NAME: field
  328. # PC_LONG_NAME - Used in *.pc Description: field
  329. # PC_LIBRARY_NAME - Used in *.pc Libs: field
  330. # Also used to determine PC_LINK_FLAGS and
  331. # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
  332. # fields.
  333. set(PC_DATA "tcl:Tcl/Tk:Tcl/Tk bindings, :plplottcltk${LIB_TAG}")
  334. string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
  335. set(PC_FILE_SUFFIX "-${BINDING}")
  336. set(PC_REQUIRES "plplot${LIB_TAG}")
  337. string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
  338. string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
  339. string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
  340. set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
  341. set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
  342. set(PC_LINK_FLAGS "-l${PC_LIBRARY_NAME} ${PC_LINK_FLAGS}")
  343. set(PC_CONFIGURED_FILE
  344. ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
  345. )
  346. configure_file(
  347. ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
  348. ${PC_CONFIGURED_FILE}
  349. @ONLY
  350. )
  351. install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
  352. endif(PKG_CONFIG_EXECUTABLE)
  353. endif(ENABLE_tcl)