PageRenderTime 51ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_9_5/src/CMakeLists.txt

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