PageRenderTime 69ms CodeModel.GetById 40ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/v5_9_7/bindings/f95/CMakeLists.txt

#
CMake | 240 lines | 163 code | 25 blank | 52 comment | 14 complexity | 20e9a8d61c48543ff78ff9bd58a6df7d 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. if(STATIC_OPTS)
  98. set(plplotf95opts${LIB_TAG}_LIB_SRCS
  99. configurable.f90
  100. )
  101. set(plplotf95${LIB_TAG}_LIB_SRCS
  102. strutil.f90
  103. sfstubsf95.f90
  104. )
  105. else(STATIC_OPTS)
  106. set(plplotf95${LIB_TAG}_LIB_SRCS
  107. strutil.f90
  108. configurable.f90
  109. sfstubsf95.f90
  110. )
  111. endif(STATIC_OPTS)
  112. if(WIN32 AND BUILD_SHARED_LIBS AND NOT MINGW AND NOT CYGWIN)
  113. SET(plplotf95${LIB_TAG}_LIB_SRCS ${plplotf95${LIB_TAG}_LIB_SRCS} plplotf95${DEFFILE}.def)
  114. endif(WIN32 AND BUILD_SHARED_LIBS AND NOT MINGW AND NOT CYGWIN)
  115. add_library(plplotf95${LIB_TAG} ${plplotf95${LIB_TAG}_LIB_SRCS})
  116. if(STATIC_OPTS)
  117. add_library(plplotf95opts${LIB_TAG} STATIC ${plplotf95opts${LIB_TAG}_LIB_SRCS})
  118. target_link_libraries(plplotf95${LIB_TAG} plplotf95c${LIB_TAG})
  119. target_link_libraries(plplotf95opts${LIB_TAG} plplotf95${LIB_TAG} plplotf95c${LIB_TAG})
  120. else(STATIC_OPTS)
  121. target_link_libraries(plplotf95${LIB_TAG} plplotf95c${LIB_TAG})
  122. endif(STATIC_OPTS)
  123. if(USE_RPATH)
  124. set_target_properties(plplotf95${LIB_TAG}
  125. PROPERTIES
  126. SOVERSION ${plplotf95_SOVERSION}
  127. VERSION ${plplotf95_VERSION}
  128. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  129. INSTALL_NAME_DIR "${LIB_DIR}"
  130. )
  131. else(USE_RPATH)
  132. set_target_properties(plplotf95${LIB_TAG}
  133. PROPERTIES
  134. SOVERSION ${plplotf95_SOVERSION}
  135. VERSION ${plplotf95_VERSION}
  136. INSTALL_NAME_DIR "${LIB_DIR}"
  137. )
  138. endif(USE_RPATH)
  139. # Set the path and the suffix for the (shared) libraries
  140. if(CYGWIN)
  141. if(BUILD_SHARED_LIBS)
  142. set(SHLIB_DIR "${BIN_DIR}")
  143. endif(BUILD_SHARED_LIBS)
  144. set(VERSION_SUFFIX "-${plplotf95_VERSION}")
  145. else(CYGWIN)
  146. set(VERSION_SUFFIX "")
  147. endif(CYGWIN)
  148. install(TARGETS plplotf95${LIB_TAG}
  149. EXPORT export_plplot
  150. ARCHIVE DESTINATION ${LIB_DIR}
  151. LIBRARY DESTINATION ${LIB_DIR}
  152. RUNTIME DESTINATION ${BIN_DIR}
  153. )
  154. if(STATIC_OPTS)
  155. install(TARGETS plplotf95opts${LIB_TAG}
  156. EXPORT export_plplot
  157. ARCHIVE DESTINATION ${LIB_DIR}
  158. LIBRARY DESTINATION ${LIB_DIR}
  159. RUNTIME DESTINATION ${BIN_DIR}
  160. )
  161. endif(STATIC_OPTS)
  162. # For CMake-2.6.0 and above, the module files are created by
  163. # default during the library build in the bindings/f95 directory.
  164. install(
  165. FILES
  166. ${CMAKE_BINARY_DIR}/bindings/f95/plplot.mod
  167. ${CMAKE_BINARY_DIR}/bindings/f95/plplotp.mod
  168. ${CMAKE_BINARY_DIR}/bindings/f95/plplot_flt.mod
  169. DESTINATION ${F95_MOD_DIR}
  170. )
  171. # Configure pkg-config *.pc file corresponding to libplplotf95${LIB_TAG}
  172. if(PKG_CONFIG_EXECUTABLE)
  173. if(LIB_TAG)
  174. set(PC_PRECISION "double")
  175. else(LIB_TAG)
  176. set(PC_PRECISION "single")
  177. endif(LIB_TAG)
  178. # Each list element must consist of a colon-separated string with the
  179. # following fields which are parsed out in the foreach loop below and
  180. # used to configure the corresponding pkg-config *.pc file.
  181. # BINDING - ENABLE_${BINDING} keeps track of whether a
  182. # binding has been enabled (ON) or not (OFF).
  183. # Also, ${BINDING} used to determine PC_FILE_SUFFIX
  184. # which helps to determine name of configured
  185. # *.pc file.
  186. # PC_SHORT_NAME - Used in *.pc NAME: field
  187. # PC_LONG_NAME - Used in *.pc Description: field
  188. # PC_LIBRARY_NAME - Used in *.pc Libs: field
  189. # Also used to determine PC_LINK_FLAGS and
  190. # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
  191. # fields.
  192. set(PC_DATA "f95:F95:F95 bindings, :plplotf95${LIB_TAG}${VERSION_SUFFIX}")
  193. string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
  194. set(PC_FILE_SUFFIX "-${BINDING}")
  195. set(PC_REQUIRES "plplot${LIB_TAG}")
  196. string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
  197. string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
  198. string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
  199. set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
  200. set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
  201. set(PC_LINK_FLAGS
  202. "-l${PC_LIBRARY_NAME} -lplplotf95c${LIB_TAG}${VERSION_SUFFIX} ${PC_LINK_FLAGS}"
  203. )
  204. set(PC_COMPILE_FLAGS "-I${F95_MOD_DIR} ${PC_COMPILE_FLAGS}")
  205. set(PC_CONFIGURED_FILE
  206. ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
  207. )
  208. configure_file(
  209. ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
  210. ${PC_CONFIGURED_FILE}
  211. @ONLY
  212. )
  213. install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
  214. endif(PKG_CONFIG_EXECUTABLE)
  215. endif(ENABLE_f95)