PageRenderTime 57ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_9_6/bindings/f95/CMakeLists.txt

#
CMake | 238 lines | 161 code | 25 blank | 52 comment | 14 complexity | 54f3bddb8ba3324e0c3fa1c6ab0731c2 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_SOURCE_DIR}/lib/qsastime
  25. ${CMAKE_BINARY_DIR}
  26. ${CMAKE_BINARY_DIR}/include
  27. ${CMAKE_CURRENT_SOURCE_DIR}
  28. ${CMAKE_CURRENT_BINARY_DIR}
  29. )
  30. # Configure the Fortran include file that specifies the kind of
  31. # floating-point (single vs double) PLplot supports.
  32. if(PL_DOUBLE)
  33. set(ONE_IN_DEFAULT_PRECISION "1.0d0")
  34. else(PL_DOUBLE)
  35. set(ONE_IN_DEFAULT_PRECISION "1.0")
  36. endif(PL_DOUBLE)
  37. configure_file(
  38. ${CMAKE_CURRENT_SOURCE_DIR}/plflt.inc.in
  39. ${CMAKE_CURRENT_BINARY_DIR}/plflt.inc
  40. @ONLY
  41. )
  42. ## Build C part of F95 bindings
  43. if(WIN32)
  44. # Set the flags for the C compiler. The C stubs need to have the
  45. # correct case and calling convention for the Fortran compiler
  46. IF(TARGET_FORTRAN MATCHES "IVF")
  47. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DIVF")
  48. ELSEIF(TARGET_FORTRAN MATCHES "CVF")
  49. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DCVF")
  50. ENDIF(TARGET_FORTRAN MATCHES "IVF")
  51. endif(WIN32)
  52. set(plplotf95c${LIB_TAG}_LIB_SRCS
  53. sc3d.c
  54. sccont.c
  55. scstubs.c
  56. )
  57. if(BUILD_SHARED_LIBS)
  58. SET_SOURCE_FILES_PROPERTIES(${plplotf95c${LIB_TAG}_LIB_SRCS}
  59. PROPERTIES COMPILE_FLAGS "-DUSINGDLL" )
  60. endif(BUILD_SHARED_LIBS)
  61. add_library(plplotf95c${LIB_TAG} ${plplotf95c${LIB_TAG}_LIB_SRCS})
  62. target_link_libraries(plplotf95c${LIB_TAG} plplot${LIB_TAG})
  63. if(USE_RPATH)
  64. get_target_property(LIB_INSTALL_RPATH plplot${LIB_TAG} INSTALL_RPATH)
  65. set_target_properties(plplotf95c${LIB_TAG}
  66. PROPERTIES
  67. SOVERSION ${plplotf95_SOVERSION}
  68. VERSION ${plplotf95_VERSION}
  69. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  70. INSTALL_NAME_DIR "${LIB_DIR}"
  71. )
  72. else(USE_RPATH)
  73. set_target_properties(plplotf95c${LIB_TAG}
  74. PROPERTIES
  75. SOVERSION ${plplotf95_SOVERSION}
  76. VERSION ${plplotf95_VERSION}
  77. INSTALL_NAME_DIR "${LIB_DIR}"
  78. )
  79. endif(USE_RPATH)
  80. install(TARGETS plplotf95c${LIB_TAG}
  81. EXPORT export_plplot
  82. ARCHIVE DESTINATION ${LIB_DIR}
  83. LIBRARY DESTINATION ${LIB_DIR}
  84. RUNTIME DESTINATION ${BIN_DIR}
  85. )
  86. # Build fortran part of F95 bindings.
  87. # Notes:
  88. # configurable.f90 is actually not currently configurable.
  89. # The CMake Fortran dependency scanner finds the Fortran include
  90. # file, sfstub.h, and the configured Fortran include file,
  91. # ${CMAKE_CURRENT_BINARY_DIR}/plflt.inc, and also deals properly with
  92. # the dependencies on those files. Therefore, there is no need to
  93. # include those files in the SRCS list or do anything special with
  94. # their dependencies.
  95. if(STATIC_OPTS)
  96. set(plplotf95opts${LIB_TAG}_LIB_SRCS
  97. configurable.f90
  98. )
  99. set(plplotf95${LIB_TAG}_LIB_SRCS
  100. strutil.f90
  101. sfstubsf95.f90
  102. )
  103. else(STATIC_OPTS)
  104. set(plplotf95${LIB_TAG}_LIB_SRCS
  105. strutil.f90
  106. configurable.f90
  107. sfstubsf95.f90
  108. )
  109. endif(STATIC_OPTS)
  110. if(WIN32 AND BUILD_SHARED_LIBS AND NOT MINGW AND NOT CYGWIN)
  111. SET(plplotf95${LIB_TAG}_LIB_SRCS ${plplotf95${LIB_TAG}_LIB_SRCS} plplotf95.def)
  112. endif(WIN32 AND BUILD_SHARED_LIBS AND NOT MINGW AND NOT CYGWIN)
  113. add_library(plplotf95${LIB_TAG} ${plplotf95${LIB_TAG}_LIB_SRCS})
  114. if(STATIC_OPTS)
  115. add_library(plplotf95opts${LIB_TAG} STATIC ${plplotf95opts${LIB_TAG}_LIB_SRCS})
  116. target_link_libraries(plplotf95${LIB_TAG} plplotf95c${LIB_TAG})
  117. target_link_libraries(plplotf95opts${LIB_TAG} plplotf95${LIB_TAG} plplotf95c${LIB_TAG})
  118. else(STATIC_OPTS)
  119. target_link_libraries(plplotf95${LIB_TAG} plplotf95c${LIB_TAG})
  120. endif(STATIC_OPTS)
  121. if(USE_RPATH)
  122. set_target_properties(plplotf95${LIB_TAG}
  123. PROPERTIES
  124. SOVERSION ${plplotf95_SOVERSION}
  125. VERSION ${plplotf95_VERSION}
  126. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  127. INSTALL_NAME_DIR "${LIB_DIR}"
  128. )
  129. else(USE_RPATH)
  130. set_target_properties(plplotf95${LIB_TAG}
  131. PROPERTIES
  132. SOVERSION ${plplotf95_SOVERSION}
  133. VERSION ${plplotf95_VERSION}
  134. INSTALL_NAME_DIR "${LIB_DIR}"
  135. )
  136. endif(USE_RPATH)
  137. # Set the path and the suffix for the (shared) libraries
  138. if(CYGWIN)
  139. if(BUILD_SHARED_LIBS)
  140. set(SHLIB_DIR "${BIN_DIR}")
  141. endif(BUILD_SHARED_LIBS)
  142. set(VERSION_SUFFIX "-${plplotf95_VERSION}")
  143. else(CYGWIN)
  144. set(VERSION_SUFFIX "")
  145. endif(CYGWIN)
  146. install(TARGETS plplotf95${LIB_TAG}
  147. EXPORT export_plplot
  148. ARCHIVE DESTINATION ${LIB_DIR}
  149. LIBRARY DESTINATION ${LIB_DIR}
  150. RUNTIME DESTINATION ${BIN_DIR}
  151. )
  152. if(STATIC_OPTS)
  153. install(TARGETS plplotf95opts${LIB_TAG}
  154. EXPORT export_plplot
  155. ARCHIVE DESTINATION ${LIB_DIR}
  156. LIBRARY DESTINATION ${LIB_DIR}
  157. RUNTIME DESTINATION ${BIN_DIR}
  158. )
  159. endif(STATIC_OPTS)
  160. # For CMake-2.6.0 and above, the module files are created by
  161. # default during the library build in the bindings/f95 directory.
  162. install(
  163. FILES
  164. ${CMAKE_BINARY_DIR}/bindings/f95/plplot.mod
  165. ${CMAKE_BINARY_DIR}/bindings/f95/plplotp.mod
  166. ${CMAKE_BINARY_DIR}/bindings/f95/plplot_flt.mod
  167. DESTINATION ${F95_MOD_DIR}
  168. )
  169. # Configure pkg-config *.pc file corresponding to libplplotf95${LIB_TAG}
  170. if(PKG_CONFIG_EXECUTABLE)
  171. if(LIB_TAG)
  172. set(PC_PRECISION "double")
  173. else(LIB_TAG)
  174. set(PC_PRECISION "single")
  175. endif(LIB_TAG)
  176. # Each list element must consist of a colon-separated string with the
  177. # following fields which are parsed out in the foreach loop below and
  178. # used to configure the corresponding pkg-config *.pc file.
  179. # BINDING - ENABLE_${BINDING} keeps track of whether a
  180. # binding has been enabled (ON) or not (OFF).
  181. # Also, ${BINDING} used to determine PC_FILE_SUFFIX
  182. # which helps to determine name of configured
  183. # *.pc file.
  184. # PC_SHORT_NAME - Used in *.pc NAME: field
  185. # PC_LONG_NAME - Used in *.pc Description: field
  186. # PC_LIBRARY_NAME - Used in *.pc Libs: field
  187. # Also used to determine PC_LINK_FLAGS and
  188. # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
  189. # fields.
  190. set(PC_DATA "f95:F95:F95 bindings, :plplotf95${LIB_TAG}${VERSION_SUFFIX}")
  191. string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
  192. set(PC_FILE_SUFFIX "-${BINDING}")
  193. set(PC_REQUIRES "plplot${LIB_TAG}")
  194. string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
  195. string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
  196. string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
  197. set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
  198. set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
  199. set(PC_LINK_FLAGS
  200. "-l${PC_LIBRARY_NAME} -lplplotf95c${LIB_TAG}${VERSION_SUFFIX} ${PC_LINK_FLAGS}"
  201. )
  202. set(PC_COMPILE_FLAGS "-I${F95_MOD_DIR} ${PC_COMPILE_FLAGS}")
  203. set(PC_CONFIGURED_FILE
  204. ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
  205. )
  206. configure_file(
  207. ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
  208. ${PC_CONFIGURED_FILE}
  209. @ONLY
  210. )
  211. install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
  212. endif(PKG_CONFIG_EXECUTABLE)
  213. endif(ENABLE_f95)