PageRenderTime 1155ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_9_5/bindings/tcl/CMakeLists.txt

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