PageRenderTime 56ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/v5_7_3/bindings/tcl/CMakeLists.txt

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