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