PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/tags/v5_9_2/src/CMakeLists.txt

#
CMake | 306 lines | 232 code | 22 blank | 52 comment | 18 complexity | 841a52c725d1d65907d9e615e090d2d4 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. )
  52. if(LTDL_WIN32)
  53. set(plplot${LIB_TAG}_LIB_SRCS ${plplot${LIB_TAG}_LIB_SRCS} ltdl_win32.c)
  54. endif(LTDL_WIN32)
  55. if(BUILD_SHARED_LIBS)
  56. SET_SOURCE_FILES_PROPERTIES(${plplot${LIB_TAG}_LIB_SRCS}
  57. PROPERTIES COMPILE_FLAGS "-DUSINGDLL" )
  58. endif(BUILD_SHARED_LIBS)
  59. if(ENABLE_DYNDRIVERS)
  60. get_source_file_property(PLCORE_COMPILE_PROPS plcore.c COMPILE_FLAGS)
  61. # Deal with NOTFOUND case.
  62. if(NOT PLCORE_COMPILE_PROPS)
  63. set(PLCORE_COMPILE_PROPS)
  64. endif(NOT PLCORE_COMPILE_PROPS)
  65. set_source_files_properties(
  66. plcore.c
  67. PROPERTIES COMPILE_FLAGS "${PLCORE_COMPILE_PROPS} -I${LTDL_INCLUDE_DIR}"
  68. )
  69. else(ENABLE_DYNDRIVERS)
  70. if(ENABLE_tcl)
  71. set(
  72. tclgenfiles
  73. ${CMAKE_BINARY_DIR}/bindings/tcl/tclgen.h
  74. ${CMAKE_BINARY_DIR}/bindings/tcl/tclgen_s.h
  75. ${CMAKE_BINARY_DIR}/bindings/tcl/tclgen.c
  76. )
  77. # Only need to set up this special command if either the tk and tkwin
  78. # non-dynamic devices are enabled (see below) since at build time
  79. # this special command is only fired in that case.
  80. add_custom_command(
  81. OUTPUT ${tclgenfiles}
  82. COMMAND ${TCL_TCLSH}
  83. ${CMAKE_SOURCE_DIR}/bindings/tcl/pltclgen.tcl
  84. ${CMAKE_SOURCE_DIR}/bindings/tcl
  85. DEPENDS
  86. ${CMAKE_SOURCE_DIR}/bindings/tcl/pltclgen.tcl
  87. ${CMAKE_SOURCE_DIR}/bindings/tcl/plapi.tpl
  88. ${CMAKE_SOURCE_DIR}/bindings/tcl/tclcmd.tpl
  89. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bindings/tcl
  90. )
  91. endif(ENABLE_tcl)
  92. # Static device drivers must be included in the core PLplot library.
  93. set(DRIVERS_RPATH)
  94. foreach(SOURCE_ROOT_NAME ${DRIVERS_LIST})
  95. #message("${SOURCE_ROOT_NAME}_SOURCE = ${${SOURCE_ROOT_NAME}_SOURCE}")
  96. set(plplot${LIB_TAG}_LIB_SRCS
  97. ${plplot${LIB_TAG}_LIB_SRCS}
  98. ${${SOURCE_ROOT_NAME}_SOURCE}
  99. )
  100. if(${SOURCE_ROOT_NAME}_COMPILE_FLAGS)
  101. set_source_files_properties(
  102. ${${SOURCE_ROOT_NAME}_SOURCE}
  103. PROPERTIES COMPILE_FLAGS ${${SOURCE_ROOT_NAME}_COMPILE_FLAGS}
  104. )
  105. set(libplplot${LIB_TAG}_COMPILE_FLAGS
  106. ${libplplot${LIB_TAG}_COMPILE_FLAGS}
  107. ${${SOURCE_ROOT_NAME}_COMPILE_FLAGS}
  108. )
  109. if(SOURCE_ROOT_NAME STREQUAL "tk")
  110. set_source_files_properties(
  111. ${${SOURCE_ROOT_NAME}_SOURCE}
  112. PROPERTIES OBJECT_DEPENDS ${tclgenfiles}
  113. )
  114. endif(SOURCE_ROOT_NAME STREQUAL "tk")
  115. if(SOURCE_ROOT_NAME STREQUAL "tkwin")
  116. set_source_files_properties(
  117. ${${SOURCE_ROOT_NAME}_SOURCE}
  118. PROPERTIES OBJECT_DEPENDS ${tclgenfiles}
  119. )
  120. endif(SOURCE_ROOT_NAME STREQUAL "tkwin")
  121. endif(${SOURCE_ROOT_NAME}_COMPILE_FLAGS)
  122. if(${SOURCE_ROOT_NAME}_RPATH)
  123. set(DRIVERS_RPATH ${DRIVERS_RPATH} ${${SOURCE_ROOT_NAME}_RPATH})
  124. endif(${SOURCE_ROOT_NAME}_RPATH)
  125. endforeach(SOURCE_ROOT_NAME ${DRIVERS_LIST})
  126. endif(ENABLE_DYNDRIVERS)
  127. include_directories(
  128. ${CMAKE_SOURCE_DIR}/include
  129. ${CMAKE_BINARY_DIR}
  130. ${CMAKE_BINARY_DIR}/include
  131. )
  132. add_library(plplot${LIB_TAG} ${plplot${LIB_TAG}_LIB_SRCS})
  133. add_dependencies(plplot${LIB_TAG} plhershey-unicode.h_built)
  134. set(LIB_INSTALL_RPATH ${LIB_DIR})
  135. if(ENABLE_DYNDRIVERS)
  136. set(libplplot${LIB_TAG}_LINK_LIBRARIES ${LTDL_LIBRARIES})
  137. #message("libplplot${LIB_TAG}_LINK_LIBRARIES = ${libplplot${LIB_TAG}_LINK_LIBRARIES}")
  138. #message("libplplot${LIB_TAG}_RPATH = ${libplplot${LIB_TAG}_RPATH}")
  139. set(LIB_INSTALL_RPATH ${LIB_INSTALL_RPATH} ${libplplot${LIB_TAG}_RPATH})
  140. else(ENABLE_DYNDRIVERS)
  141. set(libplplot${LIB_TAG}_LINK_LIBRARIES ${DRIVERS_LINK_FLAGS})
  142. set(LIB_INSTALL_RPATH ${LIB_INSTALL_RPATH} ${DRIVERS_RPATH})
  143. endif(ENABLE_DYNDRIVERS)
  144. if(MATH_LIB)
  145. set(
  146. libplplot${LIB_TAG}_LINK_LIBRARIES
  147. ${libplplot${LIB_TAG}_LINK_LIBRARIES}
  148. ${MATH_LIB}
  149. )
  150. endif(MATH_LIB)
  151. # Transform "${libplplot${LIB_TAG}_LINK_LIBRARIES}" string to the
  152. # standard pkg-config form.
  153. pkg_config_link_flags(
  154. libplplot${LIB_TAG}_LINK_FLAGS
  155. "${libplplot${LIB_TAG}_LINK_LIBRARIES}"
  156. )
  157. if(WITH_CSA)
  158. set(
  159. libplplot${LIB_TAG}_LINK_LIBRARIES
  160. ${libplplot${LIB_TAG}_LINK_LIBRARIES}
  161. csirocsa
  162. )
  163. set(
  164. libplplot${LIB_TAG}_LINK_FLAGS
  165. "${libplplot${LIB_TAG}_LINK_FLAGS} -lcsirocsa"
  166. )
  167. endif(WITH_CSA)
  168. if(HAVE_QHULL)
  169. set(
  170. libplplot${LIB_TAG}_LINK_LIBRARIES
  171. ${libplplot${LIB_TAG}_LINK_LIBRARIES}
  172. csironn
  173. )
  174. set(
  175. libplplot${LIB_TAG}_LINK_FLAGS
  176. "${libplplot${LIB_TAG}_LINK_FLAGS} -lcsironn -lqhull"
  177. )
  178. include_directories(
  179. ${QHULL_INCLUDE_DIRS}
  180. )
  181. endif(HAVE_QHULL)
  182. if(WITH_FREETYPE)
  183. get_source_file_property(PLFREETYPE_COMPILE_PROPS plfreetype.c COMPILE_FLAGS)
  184. # Deal with NOTFOUND case.
  185. if(NOT PLFREETYPE_COMPILE_PROPS)
  186. set(PLFREETYPE_COMPILE_PROPS)
  187. endif(NOT PLFREETYPE_COMPILE_PROPS)
  188. set_source_files_properties(plfreetype.c PROPERTIES COMPILE_FLAGS "${PLFREETYPE_COMPILE_PROPS} -I${FREETYPE_INCLUDE_DIR}")
  189. set(
  190. libplplot${LIB_TAG}_LINK_LIBRARIES
  191. ${libplplot${LIB_TAG}_LINK_LIBRARIES}
  192. ${FREETYPE_LIBRARIES}
  193. )
  194. # Convert to -L... -l... form.
  195. string(REGEX REPLACE "(/[^ ]*)/lib([^ ]*)\\.so" "-L\\1 -l\\2"
  196. _FREETYPE_LINK_FLAGS
  197. ${FREETYPE_LIBRARIES}
  198. )
  199. string(REGEX REPLACE "(/[^ ]*)/lib([^ ]*)\\.so" "-L\\1 -l\\2"
  200. FREETYPE_LINK_FLAGS
  201. ${_FREETYPE_LINK_FLAGS}
  202. )
  203. set(
  204. libplplot${LIB_TAG}_LINK_FLAGS
  205. "${libplplot${LIB_TAG}_LINK_FLAGS} ${FREETYPE_LINK_FLAGS}"
  206. )
  207. endif(WITH_FREETYPE)
  208. #message(STATUS
  209. #"libplplot${LIB_TAG}_LINK_LIBRARIES = ${libplplot${LIB_TAG}_LINK_LIBRARIES}"
  210. #)
  211. target_link_libraries(
  212. plplot${LIB_TAG}
  213. ${libplplot${LIB_TAG}_LINK_LIBRARIES}
  214. )
  215. if(USE_RPATH)
  216. set_target_properties(
  217. plplot${LIB_TAG}
  218. PROPERTIES
  219. SOVERSION ${plplot_SOVERSION}
  220. VERSION ${plplot_VERSION}
  221. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  222. INSTALL_NAME_DIR "${LIB_DIR}"
  223. )
  224. else(USE_RPATH)
  225. set_target_properties(
  226. plplot${LIB_TAG}
  227. PROPERTIES
  228. SOVERSION ${plplot_SOVERSION}
  229. VERSION ${plplot_VERSION}
  230. INSTALL_NAME_DIR "${LIB_DIR}"
  231. )
  232. endif(USE_RPATH)
  233. install(TARGETS plplot${LIB_TAG}
  234. ARCHIVE DESTINATION ${LIB_DIR}
  235. LIBRARY DESTINATION ${LIB_DIR}
  236. RUNTIME DESTINATION ${BIN_DIR}
  237. )
  238. #message("libplplot${LIB_TAG}_LINK_FLAGS = ${libplplot${LIB_TAG}_LINK_FLAGS}")
  239. string(REGEX REPLACE ";" " "
  240. libplplot${LIB_TAG}_COMPILE_FLAGS
  241. "${libplplot${LIB_TAG}_COMPILE_FLAGS}"
  242. )
  243. #message("libplplot${LIB_TAG}_COMPILE_FLAGS = ${libplplot${LIB_TAG}_COMPILE_FLAGS}")
  244. # Configure pkg-config *.pc file corresponding to libplplot${LIB_TAG}
  245. if(PKG_CONFIG_EXECUTABLE)
  246. if(LIB_TAG)
  247. set(PC_PRECISION "double")
  248. else(LIB_TAG)
  249. set(PC_PRECISION "single")
  250. endif(LIB_TAG)
  251. # Each list element must consist of a colon-separated string with the
  252. # following fields which are parsed out in the foreach loop below and
  253. # used to configure the corresponding pkg-config *.pc file.
  254. # BINDING - ENABLE_${BINDING} keeps track of whether a
  255. # binding has been enabled (ON) or not (OFF).
  256. # Also, ${BINDING} used to determine PC_FILE_SUFFIX
  257. # which helps to determine name of configured
  258. # *.pc file.
  259. # PC_SHORT_NAME - Used in *.pc NAME: field
  260. # PC_LONG_NAME - Used in *.pc Description: field
  261. # PC_LIBRARY_NAME - Used in *.pc Libs: field
  262. # Also used to determine PC_LINK_FLAGS and
  263. # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
  264. # fields.
  265. set(PC_DATA "c:::plplot${LIB_TAG}")
  266. string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
  267. set(PC_FILE_SUFFIX "")
  268. set(PC_REQUIRES "")
  269. string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
  270. string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
  271. string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
  272. set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
  273. set(PC_LINK_FLAGS "-l${PC_LIBRARY_NAME} ${PC_LINK_FLAGS}")
  274. set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
  275. set(PC_CONFIGURED_FILE
  276. ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
  277. )
  278. configure_file(
  279. ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
  280. ${PC_CONFIGURED_FILE}
  281. @ONLY
  282. )
  283. install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
  284. endif(PKG_CONFIG_EXECUTABLE)