PageRenderTime 58ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_9_2/bindings/tcl/CMakeLists.txt

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