PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/v5_9_4/bindings/tcl/CMakeLists.txt

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