PageRenderTime 60ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_9_5/bindings/f95/CMakeLists.txt

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