PageRenderTime 67ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/v5_9_3/bindings/f95/CMakeLists.txt

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