PageRenderTime 6ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/v5_7_3/bindings/tcl/CMakeLists.txt

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