PageRenderTime 61ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_9_4/src/CMakeLists.txt

#
CMake | 379 lines | 296 code | 26 blank | 57 comment | 32 complexity | 9105c68b43b70314dfd27f3c5a6c6593 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. # qt device driver code within libplplot has some symbols that need to be
  145. # visible for qt_example in installed examples/c++ directory to link
  146. # properly.
  147. if(BUILD_SHARED_LIBS AND SOURCE_ROOT_NAME STREQUAL "qt")
  148. set(${SOURCE_ROOT_NAME}_COMPILE_FLAGS "${${SOURCE_ROOT_NAME}_COMPILE_FLAGS} -DUSINGDLL")
  149. endif(BUILD_SHARED_LIBS AND SOURCE_ROOT_NAME STREQUAL "qt")
  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})
  176. endif(ENABLE_DYNDRIVERS)
  177. include_directories(
  178. ${CMAKE_SOURCE_DIR}/include
  179. ${CMAKE_SOURCE_DIR}/lib/qsastime
  180. ${CMAKE_BINARY_DIR}
  181. ${CMAKE_BINARY_DIR}/include
  182. )
  183. add_library(plplot${LIB_TAG} ${plplot${LIB_TAG}_LIB_SRCS})
  184. add_dependencies(plplot${LIB_TAG} plhershey-unicode.h_built)
  185. set(LIB_INSTALL_RPATH ${LIB_DIR})
  186. if(ENABLE_DYNDRIVERS)
  187. set(libplplot${LIB_TAG}_LINK_LIBRARIES ${LTDL_LIBRARIES})
  188. #message("libplplot${LIB_TAG}_LINK_LIBRARIES = ${libplplot${LIB_TAG}_LINK_LIBRARIES}")
  189. #message("libplplot${LIB_TAG}_RPATH = ${libplplot${LIB_TAG}_RPATH}")
  190. set(LIB_INSTALL_RPATH ${LIB_INSTALL_RPATH} ${libplplot${LIB_TAG}_RPATH})
  191. else(ENABLE_DYNDRIVERS)
  192. set(libplplot${LIB_TAG}_LINK_LIBRARIES ${DRIVERS_LINK_FLAGS})
  193. set(LIB_INSTALL_RPATH ${LIB_INSTALL_RPATH} ${DRIVERS_RPATH})
  194. endif(ENABLE_DYNDRIVERS)
  195. #message("LIB_INSTALL_RPATH = ${LIB_INSTALL_RPATH}")
  196. if(MATH_LIB)
  197. set(
  198. libplplot${LIB_TAG}_LINK_LIBRARIES
  199. ${libplplot${LIB_TAG}_LINK_LIBRARIES}
  200. ${MATH_LIB}
  201. )
  202. endif(MATH_LIB)
  203. # Transform "${libplplot${LIB_TAG}_LINK_LIBRARIES}" string to the
  204. # standard pkg-config form.
  205. pkg_config_link_flags(
  206. libplplot${LIB_TAG}_LINK_FLAGS
  207. "${libplplot${LIB_TAG}_LINK_LIBRARIES}"
  208. )
  209. if(WITH_CSA)
  210. set(
  211. libplplot${LIB_TAG}_LINK_LIBRARIES
  212. ${libplplot${LIB_TAG}_LINK_LIBRARIES}
  213. csirocsa
  214. )
  215. set(
  216. libplplot${LIB_TAG}_LINK_FLAGS
  217. "${libplplot${LIB_TAG}_LINK_FLAGS} -lcsirocsa"
  218. )
  219. endif(WITH_CSA)
  220. if(HAVE_QHULL)
  221. set(
  222. libplplot${LIB_TAG}_LINK_LIBRARIES
  223. ${libplplot${LIB_TAG}_LINK_LIBRARIES}
  224. csironn
  225. )
  226. set(
  227. libplplot${LIB_TAG}_LINK_FLAGS
  228. "${libplplot${LIB_TAG}_LINK_FLAGS} -lcsironn -lqhull"
  229. )
  230. include_directories(
  231. ${QHULL_INCLUDE_DIRS}
  232. )
  233. endif(HAVE_QHULL)
  234. if(NOT ENABLE_DYNDRIVERS AND PLD_cgm)
  235. list(APPEND libplplot${LIB_TAG}_LINK_LIBRARIES nistcd)
  236. set(
  237. libplplot${LIB_TAG}_LINK_FLAGS
  238. "${libplplot${LIB_TAG}_LINK_FLAGS} -lnistcd"
  239. )
  240. include_directories(${CMAKE_SOURCE_DIR}/lib/nistcd)
  241. endif(NOT ENABLE_DYNDRIVERS AND PLD_cgm)
  242. set(
  243. libplplot${LIB_TAG}_LINK_LIBRARIES
  244. ${libplplot${LIB_TAG}_LINK_LIBRARIES}
  245. qsastime
  246. )
  247. set(
  248. libplplot${LIB_TAG}_LINK_FLAGS
  249. "${libplplot${LIB_TAG}_LINK_FLAGS} -lqsastime"
  250. )
  251. if(WITH_FREETYPE)
  252. get_source_file_property(PLFREETYPE_COMPILE_PROPS plfreetype.c COMPILE_FLAGS)
  253. # Deal with NOTFOUND case.
  254. if(NOT PLFREETYPE_COMPILE_PROPS)
  255. set(PLFREETYPE_COMPILE_PROPS)
  256. endif(NOT PLFREETYPE_COMPILE_PROPS)
  257. set_source_files_properties(plfreetype.c PROPERTIES COMPILE_FLAGS "${PLFREETYPE_COMPILE_PROPS} -I${FREETYPE_INCLUDE_DIR}")
  258. set(
  259. libplplot${LIB_TAG}_LINK_LIBRARIES
  260. ${libplplot${LIB_TAG}_LINK_LIBRARIES}
  261. ${FREETYPE_LIBRARIES}
  262. )
  263. # Convert to -L... -l... form.
  264. string(REGEX REPLACE "(/[^ ]*)/lib([^ ]*)\\.so" "-L\\1 -l\\2"
  265. _FREETYPE_LINK_FLAGS
  266. ${FREETYPE_LIBRARIES}
  267. )
  268. string(REGEX REPLACE "(/[^ ]*)/lib([^ ]*)\\.so" "-L\\1 -l\\2"
  269. FREETYPE_LINK_FLAGS
  270. ${_FREETYPE_LINK_FLAGS}
  271. )
  272. set(
  273. libplplot${LIB_TAG}_LINK_FLAGS
  274. "${libplplot${LIB_TAG}_LINK_FLAGS} ${FREETYPE_LINK_FLAGS}"
  275. )
  276. endif(WITH_FREETYPE)
  277. #message(STATUS
  278. #"libplplot${LIB_TAG}_LINK_LIBRARIES = ${libplplot${LIB_TAG}_LINK_LIBRARIES}"
  279. #)
  280. target_link_libraries(
  281. plplot${LIB_TAG}
  282. ${libplplot${LIB_TAG}_LINK_LIBRARIES}
  283. )
  284. if(USE_RPATH)
  285. set_target_properties(
  286. plplot${LIB_TAG}
  287. PROPERTIES
  288. SOVERSION ${plplot_SOVERSION}
  289. VERSION ${plplot_VERSION}
  290. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  291. INSTALL_NAME_DIR "${LIB_DIR}"
  292. )
  293. else(USE_RPATH)
  294. set_target_properties(
  295. plplot${LIB_TAG}
  296. PROPERTIES
  297. SOVERSION ${plplot_SOVERSION}
  298. VERSION ${plplot_VERSION}
  299. INSTALL_NAME_DIR "${LIB_DIR}"
  300. )
  301. endif(USE_RPATH)
  302. install(TARGETS plplot${LIB_TAG}
  303. ARCHIVE DESTINATION ${LIB_DIR}
  304. LIBRARY DESTINATION ${LIB_DIR}
  305. RUNTIME DESTINATION ${BIN_DIR}
  306. )
  307. #message("libplplot${LIB_TAG}_LINK_FLAGS = ${libplplot${LIB_TAG}_LINK_FLAGS}")
  308. string(REGEX REPLACE ";" " "
  309. libplplot${LIB_TAG}_COMPILE_FLAGS
  310. "${libplplot${LIB_TAG}_COMPILE_FLAGS}"
  311. )
  312. #message("libplplot${LIB_TAG}_COMPILE_FLAGS = ${libplplot${LIB_TAG}_COMPILE_FLAGS}")
  313. # Configure pkg-config *.pc file corresponding to libplplot${LIB_TAG}
  314. if(PKG_CONFIG_EXECUTABLE)
  315. if(LIB_TAG)
  316. set(PC_PRECISION "double")
  317. else(LIB_TAG)
  318. set(PC_PRECISION "single")
  319. endif(LIB_TAG)
  320. # Each list element must consist of a colon-separated string with the
  321. # following fields which are parsed out in the foreach loop below and
  322. # used to configure the corresponding pkg-config *.pc file.
  323. # BINDING - ENABLE_${BINDING} keeps track of whether a
  324. # binding has been enabled (ON) or not (OFF).
  325. # Also, ${BINDING} used to determine PC_FILE_SUFFIX
  326. # which helps to determine name of configured
  327. # *.pc file.
  328. # PC_SHORT_NAME - Used in *.pc NAME: field
  329. # PC_LONG_NAME - Used in *.pc Description: field
  330. # PC_LIBRARY_NAME - Used in *.pc Libs: field
  331. # Also used to determine PC_LINK_FLAGS and
  332. # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
  333. # fields.
  334. set(PC_DATA "c:::plplot${LIB_TAG}")
  335. string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
  336. set(PC_FILE_SUFFIX "")
  337. set(PC_REQUIRES "")
  338. string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
  339. string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
  340. string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
  341. set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
  342. set(PC_LINK_FLAGS "-l${PC_LIBRARY_NAME} ${PC_LINK_FLAGS}")
  343. set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
  344. set(PC_CONFIGURED_FILE
  345. ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
  346. )
  347. configure_file(
  348. ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
  349. ${PC_CONFIGURED_FILE}
  350. @ONLY
  351. )
  352. install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
  353. endif(PKG_CONFIG_EXECUTABLE)