PageRenderTime 46ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_9_6/src/CMakeLists.txt

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