PageRenderTime 53ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_8_0_RC1/bindings/tcl/CMakeLists.txt

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