PageRenderTime 53ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_9_6/examples/c/CMakeLists.txt

#
CMake | 222 lines | 166 code | 19 blank | 37 comment | 20 complexity | 51d4943339e75c422e26f3a9ba38baa5 MD5 | raw file
Possible License(s): LGPL-2.0, BSD-3-Clause-No-Nuclear-License-2014, Apache-2.0, GPL-2.0
  1. # examples/c/CMakeLists.txt
  2. ### Process this file with cmake to produce Makefile
  3. ###
  4. # Copyright (C) 2006, 2007, 2008, 2009 Alan W. Irwin
  5. #
  6. # This file is part of PLplot.
  7. #
  8. # PLplot is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU Library General Public License as published
  10. # by the Free Software Foundation; version 2 of the License.
  11. #
  12. # PLplot is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Library General Public License
  18. # along with PLplot; if not, write to the Free Software
  19. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. # N.B. This file is used for both the core build (which installs the examples
  21. # and optionally [depending on BUILD_TEST} builds them) and the installed
  22. # examples build. The core build has BUILD_TEST OFF or ON at user option
  23. # and CORE_BUILD always ON. The installed examples build always has
  24. # BUILD_TEST ON and CORE_BUILD OFF.
  25. set(c_STRING_INDICES
  26. "01"
  27. "02"
  28. "03"
  29. "04"
  30. "05"
  31. "06"
  32. "07"
  33. "08"
  34. "09"
  35. "10"
  36. "11"
  37. "12"
  38. "13"
  39. "14"
  40. "15"
  41. "16"
  42. "17"
  43. "18"
  44. "19"
  45. "20"
  46. "21"
  47. "22"
  48. "23"
  49. "24"
  50. "25"
  51. "26"
  52. "27"
  53. "28"
  54. "29"
  55. "30"
  56. "31"
  57. "32"
  58. )
  59. if(CORE_BUILD)
  60. set(c_SRCS
  61. plcdemos.h
  62. tutor.c
  63. test_plend.c
  64. )
  65. foreach(STRING_INDEX ${c_STRING_INDICES})
  66. set(c_SRCS ${c_SRCS} x${STRING_INDEX}c.c)
  67. endforeach(STRING_INDEX ${c_STRING_INDICES})
  68. if(PLD_xcairo)
  69. set(extXdrawable_SRC extXdrawable_demo.c)
  70. endif(PLD_xcairo)
  71. if(PLD_extcairo)
  72. set(extcairo_SRC ext-cairo-test.c)
  73. endif(PLD_extcairo)
  74. if(PLD_xcairo OR PLD_extcairo)
  75. set(cairo_DOCS README.cairo)
  76. endif(PLD_xcairo OR PLD_extcairo)
  77. if(ENABLE_gnome2)
  78. set(plplotcanvas_SRCS
  79. plplotcanvas_demo.c
  80. plplotcanvas_animation.c
  81. )
  82. set(plplotcanvas_DOCS
  83. README.plplotcanvas
  84. )
  85. endif(ENABLE_gnome2)
  86. install(FILES ${c_SRCS} ${plplotcanvas_SRCS} ${plplotcanvas_DOCS} ${extXdrawable_SRC} ${extcairo_SRC} ${cairo_DOCS}
  87. DESTINATION ${DATA_DIR}/examples/c
  88. )
  89. install(FILES CMakeLists.txt
  90. DESTINATION ${DATA_DIR}/examples/c
  91. )
  92. set(CC ${CMAKE_C_COMPILER})
  93. configure_file(
  94. ${CMAKE_CURRENT_SOURCE_DIR}/Makefile.examples.in
  95. ${CMAKE_CURRENT_BINARY_DIR}/Makefile.examples
  96. )
  97. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Makefile.examples
  98. DESTINATION ${DATA_DIR}/examples/c
  99. RENAME Makefile
  100. )
  101. endif(CORE_BUILD)
  102. if(BUILD_TEST)
  103. if(CORE_BUILD)
  104. include_directories(
  105. ${CMAKE_SOURCE_DIR}/include
  106. ${CMAKE_BINARY_DIR}/include
  107. ${CMAKE_SOURCE_DIR}/lib/qsastime
  108. )
  109. else(CORE_BUILD)
  110. include_directories(${INCLUDE_DIR})
  111. endif(CORE_BUILD)
  112. set_property(GLOBAL PROPERTY TARGETS_examples_c)
  113. foreach(STRING_INDEX ${c_STRING_INDICES})
  114. if(CORE_BUILD AND BUILD_SHARED_LIBS)
  115. set_source_files_properties(x${STRING_INDEX}c.c
  116. PROPERTIES COMPILE_FLAGS "-DUSINGDLL" )
  117. endif(CORE_BUILD AND BUILD_SHARED_LIBS)
  118. add_executable(x${STRING_INDEX}c x${STRING_INDEX}c.c)
  119. target_link_libraries(x${STRING_INDEX}c plplot${LIB_TAG} ${MATH_LIB})
  120. set_property(GLOBAL APPEND PROPERTY TARGETS_examples_c x${STRING_INDEX}c)
  121. endforeach(STRING_INDEX ${c_STRING_INDICES})
  122. # Build simple test routines which nothing else depends on.
  123. add_executable(test_plend test_plend.c)
  124. target_link_libraries(test_plend plplot${LIB_TAG} ${MATH_LIB})
  125. if(PKG_CONFIG_EXECUTABLE)
  126. if(ENABLE_gnome2)
  127. # plplotcanvas_demo.c and plplotcanvas_animation.c both
  128. # contain "#include <gtk/gtk.h>" which occurs in the
  129. # /usr/include/gtk-2.0 directory. They also contain
  130. # "#include <plplotcanvas.h>". These issues are both taken care of
  131. # by the libgnomeprintui-2.2 pkg-config module.
  132. message(STATUS "Determine compile and link flags for plotcanvas_demo")
  133. pkg_check_pkgconfig(libgnomeprintui-2.2 includedir libdir linkflags1 cflags1 version1 _GNOMEPRINTUI)
  134. if(linkflags1)
  135. # Requires blank-delimited list.
  136. string(REGEX REPLACE ";" " " GNOMEPRINTUI_COMPILE_FLAGS "${cflags1}")
  137. set(GNOMEPRINTUI_LINK_FLAGS "${linkflags1}")
  138. set_source_files_properties(
  139. plplotcanvas_demo.c
  140. PROPERTIES COMPILE_FLAGS "${GNOMEPRINTUI_COMPILE_FLAGS}"
  141. )
  142. add_executable(plplotcanvas_demo plplotcanvas_demo.c)
  143. target_link_libraries(plplotcanvas_demo ${GNOMEPRINTUI_LINK_FLAGS} plplotgnome2${LIB_TAG})
  144. # plplotcanvas_animation.c contains a reference to gthread_init and also
  145. # contains '#include <glib.h>'. Analysis shows both these issues are
  146. # taken care of by the gthread-2.0 pkg-config module.
  147. message(STATUS "Determine compile and link flags for plotcanvas_animation")
  148. pkg_check_pkgconfig(gthread-2.0 includedir libdir linkflags2 cflags2 version2 _GTHREAD_2.0)
  149. if(linkflags2)
  150. # Requires blank-delimited list.
  151. string(REGEX REPLACE ";" " " GTHREAD_2.0_COMPILE_FLAGS "${cflags2}")
  152. set(GTHREAD_2.0_LINK_FLAGS "${linkflags2}")
  153. set_source_files_properties(
  154. plplotcanvas_animation.c
  155. PROPERTIES COMPILE_FLAGS "${GNOMEPRINTUI_COMPILE_FLAGS} ${GTHREAD_2.0_COMPILE_FLAGS}"
  156. )
  157. add_executable(plplotcanvas_animation plplotcanvas_animation.c)
  158. target_link_libraries(plplotcanvas_animation ${GNOMEPRINTUI_LINK_FLAGS} ${GTHREAD_2.0_LINK_FLAGS} plplotgnome2${LIB_TAG} ${MATH_LIB})
  159. else(linkflags2)
  160. message(STATUS "WARNING: gthread-2.0 not found. plplotcanvas_animation not built")
  161. endif(linkflags2)
  162. else(linkflags1)
  163. message(STATUS "WARNING: libgnomeprintui-2.2 not found. plplotcanvas_demo and plplotcanvas_animation not built.")
  164. endif(linkflags1)
  165. endif(ENABLE_gnome2)
  166. if(PLD_xcairo)
  167. message(STATUS "Determine compile and link flags for extXdrawable_demo")
  168. pkg_check_pkgconfig(gtk+-x11-2.0 includedir libdir linkflags3 cflags3 version3 _GTK_X11)
  169. if(linkflags3)
  170. # Requires blank-delimited list.
  171. string(REGEX REPLACE ";" " " GTK_X11_COMPILE_FLAGS "${cflags3}")
  172. set(GTK_X11_LINK_FLAGS "${linkflags3}")
  173. set_source_files_properties(
  174. extXdrawable_demo.c
  175. PROPERTIES COMPILE_FLAGS "${GTK_X11_COMPILE_FLAGS}"
  176. )
  177. add_executable(extXdrawable_demo extXdrawable_demo.c)
  178. target_link_libraries(extXdrawable_demo ${GTK_X11_LINK_FLAGS} plplot${LIB_TAG})
  179. else(linkflags3)
  180. message(STATUS "WARNING: gtk+-x11-2.0 not found. extXdrawable_demo not built.")
  181. endif(linkflags3)
  182. endif(PLD_xcairo)
  183. if(PLD_extcairo)
  184. message(STATUS "Determine compile and link flags for ext-cairo-test")
  185. pkg_check_pkgconfig(cairo includedir libdir linkflags4 cflags4 version4 _CAIRO)
  186. if(linkflags4)
  187. # Requires blank-delimited list.
  188. string(REGEX REPLACE ";" " " CAIRO_COMPILE_FLAGS "${cflags4}")
  189. set(CAIRO_LINK_FLAGS "${linkflags4}")
  190. set_source_files_properties(
  191. ext-cairo-test.c
  192. PROPERTIES COMPILE_FLAGS "${CAIRO_COMPILE_FLAGS}"
  193. )
  194. add_executable(ext-cairo-test ext-cairo-test.c)
  195. target_link_libraries(ext-cairo-test ${CAIRO_LINK_FLAGS} plplot${LIB_TAG})
  196. else(linkflags4)
  197. message(STATUS "WARNING: cairo not found. ext-cairo-test not built.")
  198. endif(linkflags4)
  199. endif(PLD_extcairo)
  200. else(PKG_CONFIG_EXECUTABLE)
  201. message(STATUS "WARNING: pkg-config not found so plplotcanvas_demo, plplotcanvas_animation, extXdrawable_demo, and ext-cairo-test not built.")
  202. endif(PKG_CONFIG_EXECUTABLE)
  203. endif(BUILD_TEST)