PageRenderTime 55ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/v5_7_1/bindings/tcl/CMakeLists.txt

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