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

/trunk/src/CMakeLists.txt

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