PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/bindings/tcl/CMakeLists.txt

#
CMake | 409 lines | 305 code | 42 blank | 62 comment | 14 complexity | 565bac668646f03d6cc8032605e8940d 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. if(NON_TRANSITIVE)
  202. # empty list ==> non-transitive linking for everything that links to
  203. # libtclmatrixd and libplplottcltkd in the shared libraries case.
  204. target_link_libraries(tclmatrix${LIB_TAG} LINK_INTERFACE_LIBRARIES)
  205. target_link_libraries(plplottcltk${LIB_TAG} LINK_INTERFACE_LIBRARIES)
  206. # This configures the pkg-config method to use non-transitive linking.
  207. set(PC_REQUIRES_TAG "Requires.private")
  208. else(NON_TRANSITIVE)
  209. # This configures the pkg-config method to use transitive linking
  210. set(PC_REQUIRES_TAG "Requires")
  211. endif(NON_TRANSITIVE)
  212. #message(STATUS
  213. #"plplottcltk${LIB_TAG}_link_libraries =
  214. #${plplottcltk${LIB_TAG}_link_libraries}"
  215. #)
  216. target_link_libraries(
  217. plplottcltk${LIB_TAG}
  218. ${plplottcltk${LIB_TAG}_link_libraries}
  219. )
  220. if(USE_RPATH)
  221. get_target_property(LIB_INSTALL_RPATH plplot${LIB_TAG} INSTALL_RPATH)
  222. set_target_properties(plplottcltk${LIB_TAG}
  223. PROPERTIES
  224. SOVERSION ${plplottcltk_SOVERSION}
  225. VERSION ${plplottcltk_VERSION}
  226. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  227. INSTALL_NAME_DIR "${LIB_DIR}"
  228. )
  229. else(USE_RPATH)
  230. set_target_properties(plplottcltk${LIB_TAG}
  231. PROPERTIES
  232. SOVERSION ${plplottcltk_SOVERSION}
  233. VERSION ${plplottcltk_VERSION}
  234. INSTALL_NAME_DIR "${LIB_DIR}"
  235. )
  236. endif(USE_RPATH)
  237. install(TARGETS plplottcltk${LIB_TAG}
  238. EXPORT export_plplot
  239. ARCHIVE DESTINATION ${LIB_DIR}
  240. LIBRARY DESTINATION ${LIB_DIR}
  241. RUNTIME DESTINATION ${BIN_DIR}
  242. )
  243. set(plplottcltk${LIB_TAG}_INSTALLED_HEADERS
  244. pltcl.h
  245. )
  246. install(
  247. FILES ${plplottcltk${LIB_TAG}_INSTALLED_HEADERS}
  248. DESTINATION ${INCLUDE_DIR}
  249. )
  250. # end plplottcltk
  251. # Generate plplot.tcl and tclIndex in build tree. At least the first one
  252. # is always needed for build-tree tests of tcl examples.
  253. add_custom_command(
  254. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/plplot.tcl
  255. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  256. ${CMAKE_SOURCE_DIR}/bindings/tk/plplot.tcl
  257. ${CMAKE_CURRENT_BINARY_DIR}/plplot.tcl
  258. DEPENDS
  259. ${CMAKE_SOURCE_DIR}/bindings/tk/plplot.tcl
  260. )
  261. # _target suffix to avoid nameclash with filename plplot.tcl. This
  262. # nameclash screwed up ../tk/configuration which had a non-generated file
  263. # of the same name which was a dependency of a custom target.
  264. add_custom_target(plplot.tcl_target ALL
  265. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/plplot.tcl
  266. )
  267. set_property(GLOBAL PROPERTY
  268. FILES_plplot.tcl_target ${CMAKE_CURRENT_BINARY_DIR}/plplot.tcl
  269. )
  270. # A Tcl expert should insert the file depends here.
  271. add_custom_command(
  272. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/tclIndex
  273. COMMAND ${TCL_TCLSH} ${MKTCLINDEX} ${MKTCLINDEX_ARGS}
  274. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  275. )
  276. add_custom_target(tclIndex_tcl ALL
  277. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tclIndex
  278. )
  279. set_property(GLOBAL PROPERTY
  280. FILES_tclIndex_tcl ${CMAKE_CURRENT_BINARY_DIR}/tclIndex
  281. )
  282. # I don't think this is necessary, but I am not sure of the file
  283. # depends of the custom_command associated with tclIndex_tcl and
  284. # serializing these targets doesn't slow down parallel builds very
  285. # much.
  286. add_dependencies(tclIndex_tcl plplot.tcl_target)
  287. if(NOT ENABLE_tk)
  288. # Only install these two files if the equivalent files are not going to
  289. # be installed by the action of ../tk/CMakeLists.txt
  290. install(
  291. FILES ${CMAKE_CURRENT_BINARY_DIR}/plplot.tcl
  292. DESTINATION ${TCL_DIR}
  293. )
  294. install(
  295. FILES ${CMAKE_CURRENT_BINARY_DIR}/tclIndex
  296. DESTINATION ${TCL_DIR}
  297. )
  298. endif(NOT ENABLE_tk)
  299. set(LIB_HARDDIR ${LIB_DIR})
  300. get_target_property(
  301. DLNAME_LIBPLPLOTTCLTK
  302. plplottcltk${LIB_TAG}
  303. LOCATION
  304. )
  305. get_filename_component(
  306. DLNAME_LIBPLPLOTTCLTK
  307. ${DLNAME_LIBPLPLOTTCLTK}
  308. NAME
  309. )
  310. string(REPLACE "plplottcltkd" "plplottcltk"
  311. DLNAME_LIBPLPLOTTCLTK
  312. ${DLNAME_LIBPLPLOTTCLTK}
  313. )
  314. string(REPLACE "plplottcltk" "plplottcltkd"
  315. DLNAME_LIBPLPLOTTCLTKD
  316. ${DLNAME_LIBPLPLOTTCLTK}
  317. )
  318. configure_file(
  319. ${CMAKE_CURRENT_SOURCE_DIR}/pkgIndex.tcl.in
  320. ${CMAKE_CURRENT_BINARY_DIR}/pkgIndex.tcl
  321. @ONLY
  322. )
  323. # Configure pkg-config *.pc file corresponding to libplplottcltk${LIB_TAG}
  324. if(PKG_CONFIG_EXECUTABLE)
  325. if(LIB_TAG)
  326. set(PC_PRECISION "double")
  327. else(LIB_TAG)
  328. set(PC_PRECISION "single")
  329. endif(LIB_TAG)
  330. # Each list element must consist of a colon-separated string with the
  331. # following fields which are parsed out in the foreach loop below and
  332. # used to configure the corresponding pkg-config *.pc file.
  333. # BINDING - ENABLE_${BINDING} keeps track of whether a
  334. # binding has been enabled (ON) or not (OFF).
  335. # Also, ${BINDING} used to determine PC_FILE_SUFFIX
  336. # which helps to determine name of configured
  337. # *.pc file.
  338. # PC_SHORT_NAME - Used in *.pc NAME: field
  339. # PC_LONG_NAME - Used in *.pc Description: field
  340. # PC_LIBRARY_NAME - Used in *.pc Libs: field
  341. # Also used to determine PC_LINK_FLAGS and
  342. # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
  343. # fields.
  344. set(PC_DATA "tcl:Tcl/Tk:Tcl/Tk bindings, :plplottcltk${LIB_TAG}")
  345. string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
  346. set(PC_FILE_SUFFIX "-${BINDING}")
  347. set(PC_REQUIRES "plplot${LIB_TAG}")
  348. string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
  349. string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
  350. string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
  351. set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
  352. set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
  353. if(NON_TRANSITIVE)
  354. set(PC_LINK_FLAGS "-lplplot${LIB_TAG} ${PC_LINK_FLAGS}")
  355. endif(NON_TRANSITIVE)
  356. set(PC_LINK_FLAGS "-l${PC_LIBRARY_NAME} ${PC_LINK_FLAGS}")
  357. set(PC_CONFIGURED_FILE
  358. ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
  359. )
  360. configure_file(
  361. ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
  362. ${PC_CONFIGURED_FILE}
  363. @ONLY
  364. )
  365. install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
  366. endif(PKG_CONFIG_EXECUTABLE)
  367. endif(ENABLE_tcl)