PageRenderTime 51ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 1ms

/tags/v5_7_2/bindings/tcl/CMakeLists.txt

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