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