PageRenderTime 55ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_9_7/src/CMakeLists.txt

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