PageRenderTime 61ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/CMakeLists.txt

#
CMake | 278 lines | 161 code | 32 blank | 85 comment | 17 complexity | fd95172a1e28f7577452dea00cefab63 MD5 | raw file
Possible License(s): LGPL-2.0, BSD-3-Clause-No-Nuclear-License-2014, Apache-2.0, GPL-2.0
  1. # Top-level 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. # Recommended way to do user overrides of C-related variables, is given at
  22. # http://public.kitware.com/pipermail/cmake/2006-July/010334.html.
  23. # See also, CMakeCInformation.cmake. There are also C++, and Fortran-specific
  24. # overrides that can be done. However, I prefer putting overrides in just
  25. # one file so I use the overall variable CMAKE_USER_MAKE_RULES_OVERRIDE
  26. # instead.
  27. set(
  28. CMAKE_USER_MAKE_RULES_OVERRIDE
  29. ${CMAKE_SOURCE_DIR}/cmake/UserOverride.cmake
  30. )
  31. # It is a fatal error if no working C compiler is available to build
  32. # the PLplot core C library and core C examples. All other compilers
  33. # required by our bindings are optional in that if no working compiler
  34. # of the kind needed is available, the associated bindings and
  35. # examples are disabled.
  36. project(plplot C)
  37. message(STATUS "CMake version = ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}")
  38. message(STATUS "CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}")
  39. if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  40. # We prefer to support only the latest CMake version because it
  41. # tends to be more free of issues and more consistent with recent
  42. # software releases of software that PLplot depends on than earlier versions.
  43. # However, as a special concession to our modern (not enterprise or
  44. # LTS) Linux distro users so they can avoid a download of recent CMake,
  45. # we allow them to use the system version of
  46. # CMake which at this time (2011-10) is typically 2.8.2 or later.
  47. cmake_minimum_required(VERSION 2.8.2 FATAL_ERROR)
  48. else(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  49. # For non-Linux platforms we prefer to support only the most recent
  50. # CMake version since that tends to be most free of issues and most
  51. # consistent with releases of software that PLplot depends on. The
  52. # most recently released CMake is 2.8.6 at this time (2011-10).
  53. cmake_minimum_required(VERSION 2.8.6 FATAL_ERROR)
  54. endif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  55. #foreach(policy RANGE 0 9)
  56. # cmake_policy(GET CMP000${policy} policy_result)
  57. # message(STATUS "Policy CMP000${policy} is ${policy_result}")
  58. #endforeach(policy RANGE 0 9)
  59. set(PACKAGE plplot)
  60. # Locations where PLplot cmake build system first looks for cmake modules.
  61. set(CMAKE_MODULE_PATH
  62. ${PROJECT_SOURCE_DIR}/cmake/modules
  63. ${PROJECT_SOURCE_DIR}/cmake/modules/language_support/cmake
  64. ${PROJECT_SOURCE_DIR}/cmake/modules/language_support/cmake-2.8
  65. )
  66. # We need the path to the MinGW/Borland compiler in order to find
  67. # the import libraries for system libraries.
  68. if(MINGW)
  69. get_filename_component(MINGWBINPATH ${CMAKE_C_COMPILER} PATH)
  70. set(MINGWLIBPATH ${MINGWBINPATH}/../lib
  71. CACHE FILEPATH
  72. DOCSTRING "Path to MinGW import libraries")
  73. endif(MINGW)
  74. if(BORLAND)
  75. get_filename_component(BORLANDBINPATH ${CMAKE_C_COMPILER} PATH)
  76. set(BORLANDLIBPATH ${BORLANDBINPATH}/../Lib/PSDK
  77. CACHE FILEPATH
  78. DOCSTRING "Path to Borland import libraries")
  79. endif(BORLAND)
  80. # Version data that need modification for each release.
  81. include(plplot_version)
  82. # parameters to control overall cmake behaviour.
  83. # Configure PLplot component variables....
  84. include(plplot)
  85. # Use configured variables to process configurable top-level files.
  86. # This CMake-configured template file is processed further by sed for
  87. # abi-compliance-checker.
  88. configure_file(
  89. ${CMAKE_CURRENT_SOURCE_DIR}/abi-compliance-checker.xml.template.in
  90. ${CMAKE_CURRENT_BINARY_DIR}/abi-compliance-checker.xml.template
  91. @ONLY
  92. )
  93. configure_file(
  94. ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
  95. ${CMAKE_CURRENT_BINARY_DIR}/config.h
  96. )
  97. # Allow access to the generated config.h for this build.
  98. add_definitions("-DHAVE_CONFIG_H")
  99. # Install top-level files
  100. # Enable testing framework for examples
  101. if(BUILD_TEST)
  102. include(CTest)
  103. endif(BUILD_TEST)
  104. # Disable warnings about deprecated functions (Visual C++ 2005)
  105. if(MSVC_VERSION GREATER 1399)
  106. add_definitions("/D_CRT_SECURE_NO_DEPRECATE")
  107. endif(MSVC_VERSION GREATER 1399)
  108. # in windows all created dlls are gathered in the dll directory
  109. # if you add this directory to your PATH all shared libraries are available
  110. if(BUILD_SHARED_LIBS AND WIN32 AND NOT CYGWIN)
  111. set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/dll)
  112. endif(BUILD_SHARED_LIBS AND WIN32 AND NOT CYGWIN)
  113. # Borland Compiler must compile in ANSII mode
  114. if(BORLAND)
  115. add_definitions(-A)
  116. endif(BORLAND)
  117. set(top_level_DOCFILES
  118. ABOUT
  119. AUTHORS
  120. COPYING.LIB
  121. ChangeLog.release
  122. Copyright
  123. FAQ
  124. NEWS
  125. PROBLEMS
  126. README
  127. README.release
  128. README.testing
  129. )
  130. install(FILES ${top_level_DOCFILES} DESTINATION ${DOC_DIR})
  131. # Process other directories including using configured variables to
  132. # process configurable files in those directories.
  133. # N.B. Order is important here at the cmake stage because targets must
  134. # be processed by cmake in a specific order e.g., due to get_target_property
  135. # invocations. Note, this order has nothing to do with the order which make
  136. # processes these subdirectories at build time. That build-time order
  137. # is determined by the dependencies between targets and also by file
  138. # dependencies that are established by the cmake configuration files.
  139. add_subdirectory(fonts)
  140. add_subdirectory(lib)
  141. add_subdirectory(include)
  142. add_subdirectory(src)
  143. add_subdirectory(data)
  144. add_subdirectory(bindings)
  145. add_subdirectory(drivers)
  146. add_subdirectory(utils)
  147. add_subdirectory(examples)
  148. add_subdirectory(plplot_test)
  149. add_subdirectory(scripts)
  150. add_subdirectory(doc)
  151. add_subdirectory(www)
  152. add_subdirectory(pkgcfg)
  153. summary()
  154. if(PREBUILD_DIST)
  155. # Pre-build everything required for a distribution tarball and copy it to
  156. # the source tree (if build tree is different from source tree).
  157. # List of targets that must be (pre-)built.
  158. set(DIST_TARGETS)
  159. if(ENABLE_octave)
  160. list(APPEND DIST_TARGETS make_documentation)
  161. endif(ENABLE_octave)
  162. if(BUILD_PRINT)
  163. list(APPEND DIST_TARGETS print)
  164. endif(BUILD_PRINT)
  165. if(BUILD_INFO)
  166. list(APPEND DIST_TARGETS info)
  167. endif(BUILD_INFO)
  168. if(BUILD_MAN)
  169. list(APPEND DIST_TARGETS man)
  170. endif(BUILD_MAN)
  171. if(BUILD_HTML)
  172. list(APPEND DIST_TARGETS html)
  173. endif(BUILD_HTML)
  174. if(BUILD_DOX_DOC)
  175. list(APPEND DIST_TARGETS build_doxygen)
  176. endif(BUILD_DOX_DOC)
  177. if(CMAKE_BINARY_DIR STREQUAL "${CMAKE_SOURCE_DIR}")
  178. add_custom_target(prebuild_dist)
  179. else(CMAKE_BINARY_DIR STREQUAL "${CMAKE_SOURCE_DIR}")
  180. # copy prebuilds back to source tree.
  181. # N.B. copy_directory quietly creates an empty directory with no
  182. # error condition if the source directory does not exist.
  183. add_custom_target(
  184. prebuild_dist
  185. COMMAND ${CMAKE_COMMAND} -E remove_directory
  186. ${CMAKE_SOURCE_DIR}/bindings/octave/plplot_octave_txt
  187. COMMAND ${CMAKE_COMMAND} -E copy_directory
  188. ${CMAKE_BINARY_DIR}/bindings/octave/plplot_octave_txt
  189. ${CMAKE_SOURCE_DIR}/bindings/octave/plplot_octave_txt
  190. COMMAND ${CMAKE_COMMAND} -E remove_directory
  191. ${CMAKE_SOURCE_DIR}/doc/doxygen
  192. COMMAND ${CMAKE_COMMAND} -E copy_directory
  193. ${CMAKE_BINARY_DIR}/doc/doxygen
  194. ${CMAKE_SOURCE_DIR}/doc/doxygen
  195. COMMAND cp
  196. `cat static_built_files ${INFO_MANIFEST} ${MAN_MANIFEST} ${HTML_MANIFEST}`
  197. ${CMAKE_SOURCE_DIR}/doc/docbook/src
  198. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/doc/docbook/src
  199. )
  200. endif(CMAKE_BINARY_DIR STREQUAL "${CMAKE_SOURCE_DIR}")
  201. add_dependencies(prebuild_dist ${DIST_TARGETS})
  202. endif(PREBUILD_DIST)
  203. #
  204. # Packing stuff
  205. #
  206. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Scientific Plotting Library PLplot")
  207. set(CPACK_PACKAGE_VENDOR "PLplot development team")
  208. set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README)
  209. set(CPACK_SET_DESTDIR ON)
  210. if(WIN32)
  211. set(CPACK_GENERATOR ZIP)
  212. else(WIN32)
  213. set(CPACK_GENERATOR TGZ)
  214. endif(WIN32)
  215. set(
  216. CPACK_SOURCE_PACKAGE_FILE_NAME
  217. "plplot-${VERSION}"
  218. CACHE INTERNAL "tarball basename"
  219. )
  220. set(CPACK_SOURCE_GENERATOR TGZ)
  221. # The following components are regex's to match anywhere (unless anchored)
  222. # in absolute path + filename to find files or directories to be excluded
  223. # from source tarball.
  224. set(CPACK_SOURCE_IGNORE_FILES
  225. "\\\\#*\\\\#$"
  226. "~$"
  227. "\\\\.cvsignore$"
  228. "^${PROJECT_SOURCE_DIR}.*/\\\\.svn/"
  229. "^${PROJECT_SOURCE_DIR}/old/"
  230. "^${PROJECT_SOURCE_DIR}/sys/mac"
  231. "^${PROJECT_SOURCE_DIR}/sys/os2"
  232. "^${PROJECT_SOURCE_DIR}/sys/unix"
  233. "^${PROJECT_SOURCE_DIR}/sys/dos/msc"
  234. "^${PROJECT_SOURCE_DIR}/sys/dos/bcc"
  235. "^${PROJECT_SOURCE_DIR}/sys/dos/emx"
  236. "^${PROJECT_SOURCE_DIR}/sys/win-tk"
  237. "^${PROJECT_SOURCE_DIR}/sys/win32"
  238. "^${PROJECT_SOURCE_DIR}/debian"
  239. )
  240. #message("CPACK_SOURCE_IGNORE_FILES = ${CPACK_SOURCE_IGNORE_FILES}")
  241. include(CPack)
  242. # Path to native build for executables required in the build process.
  243. # This is only required for cross compiling
  244. if(CMAKE_CROSSCOMPILING)
  245. set(CMAKE_NATIVE_BINARY_DIR NATIVEDIR-NOTFOUND CACHE FILEPATH "Point to the native build directory")
  246. endif(CMAKE_CROSSCOMPILING)