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

/tags/v5_9_4/bindings/f95/CMakeLists.txt

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