PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/v5_9_5/examples/c/CMakeLists.txt

#
CMake | 219 lines | 163 code | 19 blank | 37 comment | 16 complexity | a7cb5a5c9cff4cd74241a8380e7c3381 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. remove_definitions("-DHAVE_CONFIG_H")
  105. include_directories(
  106. ${CMAKE_SOURCE_DIR}/include
  107. ${CMAKE_BINARY_DIR}/include
  108. ${CMAKE_SOURCE_DIR}/lib/qsastime
  109. )
  110. else(CORE_BUILD)
  111. include_directories(${INCLUDE_DIR})
  112. endif(CORE_BUILD)
  113. set_property(GLOBAL PROPERTY TARGETS_examples_c)
  114. foreach(STRING_INDEX ${c_STRING_INDICES})
  115. if(CORE_BUILD AND BUILD_SHARED_LIBS)
  116. SET_SOURCE_FILES_PROPERTIES(x${STRING_INDEX}c.c
  117. PROPERTIES COMPILE_FLAGS "-DUSINGDLL" )
  118. endif(CORE_BUILD AND BUILD_SHARED_LIBS)
  119. add_executable(x${STRING_INDEX}c x${STRING_INDEX}c.c)
  120. target_link_libraries(x${STRING_INDEX}c plplot${LIB_TAG} ${MATH_LIB})
  121. set_property(GLOBAL APPEND PROPERTY TARGETS_examples_c x${STRING_INDEX}c)
  122. endforeach(STRING_INDEX ${c_STRING_INDICES})
  123. # Build simple test routines which nothing else depends on.
  124. add_executable(test_plend test_plend.c)
  125. target_link_libraries(test_plend plplot${LIB_TAG} ${MATH_LIB})
  126. if(PKG_CONFIG_EXECUTABLE)
  127. if(ENABLE_gnome2)
  128. # plplotcanvas_demo.c and plplotcanvas_animation.c both
  129. # contain "#include <gtk/gtk.h>" which occurs in the
  130. # /usr/include/gtk-2.0 directory. They also contain
  131. # "#include <plplotcanvas.h>". These issues are both taken care of
  132. # by the libgnomeprintui-2.2 pkg-config module.
  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. pkg_check_pkgconfig(gthread-2.0 includedir libdir linkflags2 cflags2 version2 _GTHREAD_2.0)
  148. if(linkflags2)
  149. # Requires blank-delimited list.
  150. string(REGEX REPLACE ";" " " GTHREAD_2.0_COMPILE_FLAGS "${cflags2}")
  151. set(GTHREAD_2.0_LINK_FLAGS "${linkflags2}")
  152. set_source_files_properties(
  153. plplotcanvas_animation.c
  154. PROPERTIES COMPILE_FLAGS "${GNOMEPRINTUI_COMPILE_FLAGS} ${GTHREAD_2.0_COMPILE_FLAGS}"
  155. )
  156. add_executable(plplotcanvas_animation plplotcanvas_animation.c)
  157. target_link_libraries(plplotcanvas_animation ${GNOMEPRINTUI_LINK_FLAGS} ${GTHREAD_2.0_LINK_FLAGS} plplotgnome2${LIB_TAG} ${MATH_LIB})
  158. else(linkflags2)
  159. message(STATUS "WARNING: gthread-2.0 not found. plplotcanvas_animation not built")
  160. endif(linkflags2)
  161. else(linkflags1)
  162. message(STATUS "WARNING: libgnomeprintui-2.2 not found. plplotcanvas_demo and plplotcanvas_animation not built.")
  163. endif(linkflags1)
  164. endif(ENABLE_gnome2)
  165. if(PLD_xcairo)
  166. pkg_check_pkgconfig(gtk+-x11-2.0 includedir libdir linkflags3 cflags3 version3 _GTK_X11)
  167. if(linkflags3)
  168. # Requires blank-delimited list.
  169. string(REGEX REPLACE ";" " " GTK_X11_COMPILE_FLAGS "${cflags3}")
  170. set(GTK_X11_LINK_FLAGS "${linkflags3}")
  171. set_source_files_properties(
  172. extXdrawable_demo.c
  173. PROPERTIES COMPILE_FLAGS "${GTK_X11_COMPILE_FLAGS}"
  174. )
  175. add_executable(extXdrawable_demo extXdrawable_demo.c)
  176. target_link_libraries(extXdrawable_demo ${GTK_X11_LINK_FLAGS} plplot${LIB_TAG})
  177. else(linkflags3)
  178. message(STATUS "WARNING: gtk+-x11-2.0 not found. extXdrawable_demo not built.")
  179. endif(linkflags3)
  180. endif(PLD_xcairo)
  181. if(PLD_extcairo)
  182. pkg_check_pkgconfig(cairo includedir libdir linkflags4 cflags4 version4 _CAIRO)
  183. if(linkflags4)
  184. # Requires blank-delimited list.
  185. string(REGEX REPLACE ";" " " CAIRO_COMPILE_FLAGS "${cflags4}")
  186. set(CAIRO_LINK_FLAGS "${linkflags4}")
  187. set_source_files_properties(
  188. ext-cairo-test.c
  189. PROPERTIES COMPILE_FLAGS "${CAIRO_COMPILE_FLAGS}"
  190. )
  191. add_executable(ext-cairo-test ext-cairo-test.c)
  192. target_link_libraries(ext-cairo-test ${CAIRO_LINK_FLAGS} plplot${LIB_TAG})
  193. else(linkflags4)
  194. message(STATUS "WARNING: cairo not found. ext-cairo-test not built.")
  195. endif(linkflags4)
  196. endif(PLD_extcairo)
  197. else(PKG_CONFIG_EXECUTABLE)
  198. message(STATUS "WARNING: pkg-config not found so plplotcanvas_demo, plplotcanvas_animation, extXdrawable_demo, and ext-cairo-test not built.")
  199. endif(PKG_CONFIG_EXECUTABLE)
  200. endif(BUILD_TEST)