PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/branches/hbabcock/src/CMakeLists.txt

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