PageRenderTime 52ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 1ms

/tags/debian/5.9.0-5/bindings/f95/CMakeLists.txt

#
CMake | 214 lines | 143 code | 24 blank | 47 comment | 9 complexity | 130930c22e1e5b0659be85ab37e86011 MD5 | raw file
Possible License(s): LGPL-2.0, BSD-3-Clause-No-Nuclear-License-2014, Apache-2.0, GPL-2.0
  1. # bindings/f95/CMakeLists.txt
  2. ### Process this file with cmake to produce Makefile
  3. ###
  4. # Copyright (C) 2006 Andrew Ross
  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. if(ENABLE_f95)
  21. # Set the include path
  22. include_directories(
  23. ${CMAKE_SOURCE_DIR}/include
  24. ${CMAKE_BINARY_DIR}
  25. ${CMAKE_BINARY_DIR}/include
  26. ${CMAKE_CURRENT_SOURCE_DIR}
  27. ${CMAKE_CURRENT_BINARY_DIR}
  28. )
  29. # Build plflt to determine KIND for PLFLT
  30. set(plflt_SRC
  31. plflt.c
  32. )
  33. add_executable(plflt ${plflt_SRC})
  34. get_target_property(
  35. plflt_LOCATION
  36. plflt
  37. LOCATION
  38. )
  39. add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/plflt.inc
  40. COMMAND ${CMAKE_CURRENT_BINARY_DIR}/plflt
  41. DEPENDS ${plflt_LOCATION}
  42. )
  43. set_source_files_properties(plflt.inc PROPERTIES GENERATED ON)
  44. ## Build C part of F95 bindings
  45. set(plplotf95c${LIB_TAG}_LIB_SRCS
  46. plstubs.h
  47. sc3d.c
  48. sccont.c
  49. scstubs.c
  50. )
  51. add_library(plplotf95c${LIB_TAG} ${plplotf95c${LIB_TAG}_LIB_SRCS})
  52. target_link_libraries(plplotf95c${LIB_TAG} plplot${LIB_TAG})
  53. if(USE_RPATH)
  54. get_target_property(LIB_INSTALL_RPATH plplot${LIB_TAG} INSTALL_RPATH)
  55. set_target_properties(plplotf95c${LIB_TAG}
  56. PROPERTIES
  57. SOVERSION ${plplotf95_SOVERSION}
  58. VERSION ${plplotf95_VERSION}
  59. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  60. INSTALL_NAME_DIR "${LIB_DIR}"
  61. )
  62. else(USE_RPATH)
  63. set_target_properties(plplotf95c${LIB_TAG}
  64. PROPERTIES
  65. SOVERSION ${plplotf95_SOVERSION}
  66. VERSION ${plplotf95_VERSION}
  67. INSTALL_NAME_DIR "${LIB_DIR}"
  68. )
  69. endif(USE_RPATH)
  70. install(TARGETS plplotf95c${LIB_TAG}
  71. ARCHIVE DESTINATION ${LIB_DIR}
  72. LIBRARY DESTINATION ${LIB_DIR}
  73. RUNTIME DESTINATION ${BIN_DIR}
  74. )
  75. ## Build fortran part of F95 bindings
  76. set(plplotf95${LIB_TAG}_LIB_SRCS
  77. strutil.f90
  78. configurable.f90
  79. sfstubsf95.f90
  80. sfstubs.h
  81. )
  82. if(WIN32 AND BUILD_SHARED_LIBS)
  83. SET(plplotf95${LIB_TAG}_LIB_SRCS ${plplotf95${LIB_TAG}_LIB_SRCS} plplotf95.def)
  84. SET_SOURCE_FILES_PROPERTIES(${plplotf95c${LIB_TAG}_LIB_SRCS}
  85. PROPERTIES COMPILE_FLAGS "-DMAKINGPLDLL" )
  86. endif(WIN32 AND BUILD_SHARED_LIBS)
  87. # Explicitly include dependencies for sfstubsf95.f90
  88. include(AddFileDependencies)
  89. add_file_dependencies(sfstubsf95.f90 ${CMAKE_CURRENT_BINARY_DIR}/plflt.inc)
  90. add_library(plplotf95${LIB_TAG} ${plplotf95${LIB_TAG}_LIB_SRCS})
  91. target_link_libraries(plplotf95${LIB_TAG} plplotf95c${LIB_TAG})
  92. if(USE_RPATH)
  93. set_target_properties(plplotf95${LIB_TAG}
  94. PROPERTIES
  95. SOVERSION ${plplotf95_SOVERSION}
  96. VERSION ${plplotf95_VERSION}
  97. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  98. INSTALL_NAME_DIR "${LIB_DIR}"
  99. )
  100. else(USE_RPATH)
  101. set_target_properties(plplotf95${LIB_TAG}
  102. PROPERTIES
  103. SOVERSION ${plplotf95_SOVERSION}
  104. VERSION ${plplotf95_VERSION}
  105. INSTALL_NAME_DIR "${LIB_DIR}"
  106. )
  107. endif(USE_RPATH)
  108. # Set the path and the suffix for the (shared) libraries
  109. if(CYGWIN)
  110. if(BUILD_SHARED_LIBS)
  111. set(SHLIB_DIR "${BIN_DIR}")
  112. endif(BUILD_SHARED_LIBS)
  113. set(VERSION_SUFFIX "-${plplotf95_VERSION}")
  114. else(CYGWIN)
  115. set(VERSION_SUFFIX "")
  116. endif(CYGWIN)
  117. install(TARGETS plplotf95${LIB_TAG}
  118. ARCHIVE DESTINATION ${LIB_DIR}
  119. LIBRARY DESTINATION ${LIB_DIR}
  120. RUNTIME DESTINATION ${BIN_DIR}
  121. )
  122. if(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 4)
  123. # Yuk! All Makefiles are run from the top level build directory and
  124. # so the f90 .mod files end up there rather than in the bindings/f95
  125. # directory. Ifort and pgf90 both have a -module command line option to
  126. # override this location, but I'm not sure how portable that?
  127. install(
  128. FILES
  129. ${CMAKE_BINARY_DIR}/plplot.mod
  130. ${CMAKE_BINARY_DIR}/plplotp.mod
  131. ${CMAKE_BINARY_DIR}/plplot_flt.mod
  132. DESTINATION ${F95_MOD_DIR}
  133. )
  134. else(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 4)
  135. # For the current cvs version of CMake, the module files are created by
  136. # default during the library build in the more logical bindings/f95
  137. # directory.
  138. install(
  139. FILES
  140. ${CMAKE_BINARY_DIR}/bindings/f95/plplot.mod
  141. ${CMAKE_BINARY_DIR}/bindings/f95/plplotp.mod
  142. ${CMAKE_BINARY_DIR}/bindings/f95/plplot_flt.mod
  143. DESTINATION ${F95_MOD_DIR}
  144. )
  145. endif(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 4)
  146. # Configure pkg-config *.pc file corresponding to libplplotf95${LIB_TAG}
  147. if(PKG_CONFIG_EXECUTABLE)
  148. if(LIB_TAG)
  149. set(PC_PRECISION "double")
  150. else(LIB_TAG)
  151. set(PC_PRECISION "single")
  152. endif(LIB_TAG)
  153. # Each list element must consist of a colon-separated string with the
  154. # following fields which are parsed out in the foreach loop below and
  155. # used to configure the corresponding pkg-config *.pc file.
  156. # BINDING - ENABLE_${BINDING} keeps track of whether a
  157. # binding has been enabled (ON) or not (OFF).
  158. # Also, ${BINDING} used to determine PC_FILE_SUFFIX
  159. # which helps to determine name of configured
  160. # *.pc file.
  161. # PC_SHORT_NAME - Used in *.pc NAME: field
  162. # PC_LONG_NAME - Used in *.pc Description: field
  163. # PC_LIBRARY_NAME - Used in *.pc Libs: field
  164. # Also used to determine PC_LINK_FLAGS and
  165. # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
  166. # fields.
  167. set(PC_DATA "f95:F95:F95 bindings, :plplotf95${LIB_TAG}${VERSION_SUFFIX}")
  168. string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
  169. set(PC_FILE_SUFFIX "-${BINDING}")
  170. set(PC_REQUIRES "plplot${LIB_TAG}")
  171. string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
  172. string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
  173. string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
  174. set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
  175. set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
  176. set(PC_LINK_FLAGS
  177. "-l${PC_LIBRARY_NAME} -lplplotf95c${LIB_TAG}${VERSION_SUFFIX} ${PC_LINK_FLAGS}"
  178. )
  179. set(PC_COMPILE_FLAGS "-I${F95_MOD_DIR} ${PC_COMPILE_FLAGS}")
  180. set(PC_CONFIGURED_FILE
  181. ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
  182. )
  183. configure_file(
  184. ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
  185. ${PC_CONFIGURED_FILE}
  186. @ONLY
  187. )
  188. install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
  189. endif(PKG_CONFIG_EXECUTABLE)
  190. endif(ENABLE_f95)