PageRenderTime 1ms CodeModel.GetById 96ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/v5_9_3/src/CMakeLists.txt

#
CMake | 372 lines | 293 code | 25 blank | 54 comment | 31 complexity | dc319da1d175b40703c142a355d00563 MD5 | raw file
  1# src/CMakeLists.txt for PLplot
  2###
  3### Process this file with cmake to produce Makefile
  4###
  5# Copyright (C) 2006 Alan W. Irwin
  6#
  7# This file is part of PLplot.
  8#
  9# PLplot is free software; you can redistribute it and/or modify
 10# it under the terms of the GNU Library General Public License as published
 11# by the Free Software Foundation; version 2 of the License.
 12#
 13# PLplot is distributed in the hope that it will be useful,
 14# but WITHOUT ANY WARRANTY; without even the implied warranty of
 15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16# GNU Library General Public License for more details.
 17#
 18# You should have received a copy of the GNU Library General Public License
 19# along with PLplot; if not, write to the Free Software
 20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 21
 22set(plplot${LIB_TAG}_LIB_SRCS
 23pdfutils.c
 24plargs.c
 25plbox.c
 26plcont.c
 27plcore.c
 28plctrl.c
 29plcvt.c
 30pldeprecated.c
 31pldtik.c
 32plfill.c
 33plfreetype.c
 34plhist.c
 35plimage.c
 36plline.c
 37plmap.c
 38plot3d.c
 39plpage.c
 40plsdef.c
 41plshade.c
 42plstdio.c
 43plstripc.c
 44plsym.c
 45pltick.c
 46plvpor.c
 47plwind.c
 48plbuf.c
 49plgridd.c
 50plvect.c
 51mt19937ar.c
 52pltime.c
 53)
 54if(LTDL_WIN32)
 55  set(plplot${LIB_TAG}_LIB_SRCS ${plplot${LIB_TAG}_LIB_SRCS} ltdl_win32.c)
 56endif(LTDL_WIN32)
 57
 58if(BUILD_SHARED_LIBS)
 59  SET_SOURCE_FILES_PROPERTIES(${plplot${LIB_TAG}_LIB_SRCS}
 60      PROPERTIES COMPILE_FLAGS "-DUSINGDLL" )
 61endif(BUILD_SHARED_LIBS)
 62
 63if(ENABLE_DYNDRIVERS)
 64  get_source_file_property(PLCORE_COMPILE_PROPS plcore.c COMPILE_FLAGS)
 65  # Deal with NOTFOUND case.
 66  if(NOT PLCORE_COMPILE_PROPS)
 67    set(PLCORE_COMPILE_PROPS)
 68  endif(NOT PLCORE_COMPILE_PROPS)
 69  set_source_files_properties(
 70  plcore.c
 71  PROPERTIES COMPILE_FLAGS "${PLCORE_COMPILE_PROPS} -I${LTDL_INCLUDE_DIR}"
 72  )
 73else(ENABLE_DYNDRIVERS)
 74  if(ENABLE_tcl)
 75    set(
 76    tclgenfiles
 77    ${CMAKE_BINARY_DIR}/bindings/tcl/tclgen.h
 78    ${CMAKE_BINARY_DIR}/bindings/tcl/tclgen_s.h
 79    ${CMAKE_BINARY_DIR}/bindings/tcl/tclgen.c
 80    )
 81
 82    # Only need to set up this special command if either the tk and tkwin
 83    # non-dynamic devices are enabled (see below) since at build time
 84    # this special command is only fired in that case.
 85    add_custom_command(
 86    OUTPUT ${tclgenfiles}
 87    COMMAND ${TCL_TCLSH}
 88    ${CMAKE_SOURCE_DIR}/bindings/tcl/pltclgen.tcl
 89    ${CMAKE_SOURCE_DIR}/bindings/tcl
 90    DEPENDS
 91    ${CMAKE_SOURCE_DIR}/bindings/tcl/pltclgen.tcl
 92    ${CMAKE_SOURCE_DIR}/bindings/tcl/plapi.tpl
 93    ${CMAKE_SOURCE_DIR}/bindings/tcl/tclcmd.tpl
 94    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bindings/tcl
 95    )
 96  endif(ENABLE_tcl)
 97
 98  # Static device drivers must be included in the core PLplot library.
 99  set(DRIVERS_RPATH)
100  foreach(SOURCE_ROOT_NAME ${DRIVERS_LIST})
101    #message("${SOURCE_ROOT_NAME}_SOURCE = ${${SOURCE_ROOT_NAME}_SOURCE}")
102    list(APPEND plplot${LIB_TAG}_LIB_SRCS ${${SOURCE_ROOT_NAME}_SOURCE})
103    if(SOURCE_ROOT_NAME STREQUAL "qt")
104      set(MOC_OPTIONS)
105      if(PLD_bmpqt)
106	list(APPEND MOC_OPTIONS -DPLD_bmpqt)
107      endif(PLD_bmpqt)
108      if(PLD_jpgqt)
109	list(APPEND MOC_OPTIONS -DPLD_jpgqt)
110      endif(PLD_jpgqt)
111      if(PLD_pngqt)
112	list(APPEND MOC_OPTIONS -DPLD_pngqt)
113      endif(PLD_pngqt)
114      if(PLD_ppmqt)
115	list(APPEND MOC_OPTIONS -DPLD_ppmqt)
116      endif(PLD_ppmqt)
117      if(PLD_tiffqt)
118	list(APPEND MOC_OPTIONS -DPLD_tiffqt)
119      endif(PLD_tiffqt)
120      if(PLD_svgqt)
121	list(APPEND MOC_OPTIONS -DPLD_svgqt)
122      endif(PLD_svgqt)
123      if(PLD_epsqt)
124	list(APPEND MOC_OPTIONS -DPLD_epsqt)
125      endif(PLD_epsqt)
126      if(PLD_pdfqt)
127	list(APPEND MOC_OPTIONS -DPLD_pdfqt)
128      endif(PLD_pdfqt)
129      if(PLD_qtwidget)
130	list(APPEND MOC_OPTIONS -DPLD_qtwidget)
131      endif(PLD_qtwidget)
132      if(PLD_extqt)
133	list(APPEND MOC_OPTIONS -DPLD_extqt)
134      endif(PLD_extqt)
135      if(MOC_OPTIONS)
136	qt4_wrap_cpp(
137          QT_MOC_OUTFILES
138          ${CMAKE_SOURCE_DIR}/drivers/qt.h
139          OPTIONS ${MOC_OPTIONS}
140          )
141	# message("QT_MOC_OUTFILES = ${QT_MOC_OUTFILES}")
142	set_source_files_properties(
143          ${QT_MOC_OUTFILES}
144          PROPERTIES GENERATED "ON"
145          )
146	list(APPEND plplot${LIB_TAG}_LIB_SRCS ${QT_MOC_OUTFILES})
147      endif(MOC_OPTIONS)
148    endif(SOURCE_ROOT_NAME STREQUAL "qt")
149
150    if(${SOURCE_ROOT_NAME}_COMPILE_FLAGS)
151      set_source_files_properties(
152      ${${SOURCE_ROOT_NAME}_SOURCE}
153      PROPERTIES COMPILE_FLAGS ${${SOURCE_ROOT_NAME}_COMPILE_FLAGS}
154      )
155      set(libplplot${LIB_TAG}_COMPILE_FLAGS
156      ${libplplot${LIB_TAG}_COMPILE_FLAGS}
157      ${${SOURCE_ROOT_NAME}_COMPILE_FLAGS}
158      )
159      if(SOURCE_ROOT_NAME STREQUAL "tk")
160        set_source_files_properties(
161	${${SOURCE_ROOT_NAME}_SOURCE}
162	PROPERTIES OBJECT_DEPENDS ${tclgenfiles}
163	)
164      endif(SOURCE_ROOT_NAME STREQUAL "tk")
165      if(SOURCE_ROOT_NAME STREQUAL "tkwin")
166        set_source_files_properties(
167	${${SOURCE_ROOT_NAME}_SOURCE}
168	PROPERTIES OBJECT_DEPENDS ${tclgenfiles}
169	)
170      endif(SOURCE_ROOT_NAME STREQUAL "tkwin")
171    endif(${SOURCE_ROOT_NAME}_COMPILE_FLAGS)
172    if(${SOURCE_ROOT_NAME}_RPATH)
173      set(DRIVERS_RPATH ${DRIVERS_RPATH} ${${SOURCE_ROOT_NAME}_RPATH})
174    endif(${SOURCE_ROOT_NAME}_RPATH)
175  endforeach(SOURCE_ROOT_NAME ${DRIVERS_LIST})
176endif(ENABLE_DYNDRIVERS)
177
178include_directories(
179${CMAKE_SOURCE_DIR}/include
180${CMAKE_SOURCE_DIR}/lib/qsastime
181${CMAKE_BINARY_DIR}
182${CMAKE_BINARY_DIR}/include
183)
184add_library(plplot${LIB_TAG} ${plplot${LIB_TAG}_LIB_SRCS})
185add_dependencies(plplot${LIB_TAG} plhershey-unicode.h_built)
186
187set(LIB_INSTALL_RPATH ${LIB_DIR})
188if(ENABLE_DYNDRIVERS)
189  set(libplplot${LIB_TAG}_LINK_LIBRARIES ${LTDL_LIBRARIES})
190  #message("libplplot${LIB_TAG}_LINK_LIBRARIES =  ${libplplot${LIB_TAG}_LINK_LIBRARIES}")
191  #message("libplplot${LIB_TAG}_RPATH = ${libplplot${LIB_TAG}_RPATH}")
192  set(LIB_INSTALL_RPATH ${LIB_INSTALL_RPATH} ${libplplot${LIB_TAG}_RPATH})
193else(ENABLE_DYNDRIVERS)
194  set(libplplot${LIB_TAG}_LINK_LIBRARIES ${DRIVERS_LINK_FLAGS})
195  set(LIB_INSTALL_RPATH ${LIB_INSTALL_RPATH} ${DRIVERS_RPATH})
196endif(ENABLE_DYNDRIVERS)
197#message("LIB_INSTALL_RPATH = ${LIB_INSTALL_RPATH}")
198
199if(MATH_LIB)
200  set(
201  libplplot${LIB_TAG}_LINK_LIBRARIES
202  ${libplplot${LIB_TAG}_LINK_LIBRARIES}
203  ${MATH_LIB}
204  )
205endif(MATH_LIB)
206
207# Transform "${libplplot${LIB_TAG}_LINK_LIBRARIES}" string to the 
208# standard pkg-config form.
209pkg_config_link_flags(
210libplplot${LIB_TAG}_LINK_FLAGS
211"${libplplot${LIB_TAG}_LINK_LIBRARIES}"
212)
213
214if(WITH_CSA)
215  set(
216  libplplot${LIB_TAG}_LINK_LIBRARIES
217  ${libplplot${LIB_TAG}_LINK_LIBRARIES}
218  csirocsa
219  )
220  set(
221  libplplot${LIB_TAG}_LINK_FLAGS
222  "${libplplot${LIB_TAG}_LINK_FLAGS} -lcsirocsa"
223  )
224endif(WITH_CSA)
225
226if(HAVE_QHULL)
227  set(
228  libplplot${LIB_TAG}_LINK_LIBRARIES
229  ${libplplot${LIB_TAG}_LINK_LIBRARIES}
230  csironn
231  )
232  set(
233  libplplot${LIB_TAG}_LINK_FLAGS
234  "${libplplot${LIB_TAG}_LINK_FLAGS} -lcsironn -lqhull"
235  )
236  include_directories(
237    ${QHULL_INCLUDE_DIRS}
238  )
239endif(HAVE_QHULL)
240
241if(NOT ENABLE_DYNDRIVERS AND PLD_cgm)
242  list(APPEND  libplplot${LIB_TAG}_LINK_LIBRARIES nistcd)
243  set(
244  libplplot${LIB_TAG}_LINK_FLAGS
245  "${libplplot${LIB_TAG}_LINK_FLAGS} -lnistcd"
246  )
247  include_directories(${CMAKE_SOURCE_DIR}/lib/nistcd)
248endif(NOT ENABLE_DYNDRIVERS AND PLD_cgm)
249
250set(
251  libplplot${LIB_TAG}_LINK_LIBRARIES
252  ${libplplot${LIB_TAG}_LINK_LIBRARIES}
253  qsastime
254  )
255set(
256  libplplot${LIB_TAG}_LINK_FLAGS
257  "${libplplot${LIB_TAG}_LINK_FLAGS} -lqsastime"
258  )
259
260if(WITH_FREETYPE)
261  get_source_file_property(PLFREETYPE_COMPILE_PROPS plfreetype.c COMPILE_FLAGS)
262  # Deal with NOTFOUND case.
263  if(NOT PLFREETYPE_COMPILE_PROPS)
264    set(PLFREETYPE_COMPILE_PROPS)
265  endif(NOT PLFREETYPE_COMPILE_PROPS)
266  set_source_files_properties(plfreetype.c PROPERTIES COMPILE_FLAGS "${PLFREETYPE_COMPILE_PROPS} -I${FREETYPE_INCLUDE_DIR}")
267  set(
268  libplplot${LIB_TAG}_LINK_LIBRARIES
269  ${libplplot${LIB_TAG}_LINK_LIBRARIES}
270  ${FREETYPE_LIBRARIES}
271  )
272  
273  # Convert to -L... -l... form.
274  string(REGEX REPLACE "(/[^ ]*)/lib([^ ]*)\\.so" "-L\\1 -l\\2"
275  _FREETYPE_LINK_FLAGS
276  ${FREETYPE_LIBRARIES}
277  )
278  string(REGEX REPLACE "(/[^ ]*)/lib([^ ]*)\\.so" "-L\\1 -l\\2"
279  FREETYPE_LINK_FLAGS
280  ${_FREETYPE_LINK_FLAGS}
281  )
282  set(
283  libplplot${LIB_TAG}_LINK_FLAGS
284  "${libplplot${LIB_TAG}_LINK_FLAGS} ${FREETYPE_LINK_FLAGS}"
285  )
286endif(WITH_FREETYPE)
287
288#message(STATUS
289#"libplplot${LIB_TAG}_LINK_LIBRARIES = ${libplplot${LIB_TAG}_LINK_LIBRARIES}"
290#)
291
292target_link_libraries(
293plplot${LIB_TAG}
294${libplplot${LIB_TAG}_LINK_LIBRARIES}
295)
296
297if(USE_RPATH)
298  set_target_properties(
299  plplot${LIB_TAG}
300  PROPERTIES 
301  SOVERSION ${plplot_SOVERSION}
302  VERSION ${plplot_VERSION}
303  INSTALL_RPATH "${LIB_INSTALL_RPATH}"
304  INSTALL_NAME_DIR "${LIB_DIR}"
305  )
306else(USE_RPATH)
307  set_target_properties(
308  plplot${LIB_TAG}
309  PROPERTIES 
310  SOVERSION ${plplot_SOVERSION}
311  VERSION ${plplot_VERSION}
312  INSTALL_NAME_DIR "${LIB_DIR}"
313  )
314endif(USE_RPATH)
315
316install(TARGETS plplot${LIB_TAG}
317ARCHIVE DESTINATION ${LIB_DIR}
318LIBRARY DESTINATION ${LIB_DIR}
319RUNTIME DESTINATION ${BIN_DIR}
320)
321
322#message("libplplot${LIB_TAG}_LINK_FLAGS = ${libplplot${LIB_TAG}_LINK_FLAGS}")
323
324string(REGEX REPLACE ";" " " 
325libplplot${LIB_TAG}_COMPILE_FLAGS
326"${libplplot${LIB_TAG}_COMPILE_FLAGS}"
327)
328#message("libplplot${LIB_TAG}_COMPILE_FLAGS = ${libplplot${LIB_TAG}_COMPILE_FLAGS}")
329
330# Configure pkg-config *.pc file corresponding to libplplot${LIB_TAG}
331if(PKG_CONFIG_EXECUTABLE)
332  if(LIB_TAG)
333    set(PC_PRECISION "double")
334  else(LIB_TAG)
335    set(PC_PRECISION "single")
336  endif(LIB_TAG)
337  # Each list element must consist of a colon-separated string with the
338  # following fields which are parsed out in the foreach loop below and
339  # used to configure the corresponding pkg-config *.pc file.
340  # BINDING 	      	  - ENABLE_${BINDING} keeps track of whether a
341  # 			    binding has been enabled (ON) or not (OFF).
342  #			    Also, ${BINDING} used to determine PC_FILE_SUFFIX
343  #			    which helps to determine name of configured 
344  #			    *.pc file.
345  # PC_SHORT_NAME	  - Used in *.pc NAME: field
346  # PC_LONG_NAME	  - Used in *.pc Description: field
347  # PC_LIBRARY_NAME	  - Used in *.pc Libs: field
348  #                         Also used to determine PC_LINK_FLAGS and
349  #                         PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
350  #			    fields.
351  set(PC_DATA "c:::plplot${LIB_TAG}")
352
353  string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
354  set(PC_FILE_SUFFIX "")
355  set(PC_REQUIRES "")
356  string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
357  string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
358  string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
359  set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
360  set(PC_LINK_FLAGS "-l${PC_LIBRARY_NAME} ${PC_LINK_FLAGS}")
361  set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
362  set(PC_CONFIGURED_FILE
363  ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
364  )
365  configure_file(
366  ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
367  ${PC_CONFIGURED_FILE}
368  @ONLY
369  )
370  install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
371endif(PKG_CONFIG_EXECUTABLE)
372