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

/tags/v5_9_8/bindings/f95/CMakeLists.txt

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