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

/tags/v5_9_1/bindings/tcl/CMakeLists.txt

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