PageRenderTime 47ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_9_7/bindings/tcl/CMakeLists.txt

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