PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_9_2/bindings/f95/CMakeLists.txt

#
CMake | 231 lines | 151 code | 23 blank | 57 comment | 12 complexity | 045fa0b90be4e746930007238f398c11 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_BINARY_DIR}
  25. ${CMAKE_BINARY_DIR}/include
  26. ${CMAKE_CURRENT_SOURCE_DIR}
  27. ${CMAKE_CURRENT_BINARY_DIR}
  28. )
  29. # Generate the include file that specifies the kind of floating
  30. # point (single vs double) PLplot supports
  31. #
  32. FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/plflt.inc" INC_FILE)
  33. FILE(WRITE "${INC_FILE}"
  34. "! Include file to control the kind of floating point number\n"
  35. "! used by PLplot (single vs double)\n"
  36. "! This file is automatically generated by CMake\n")
  37. if(PL_DOUBLE)
  38. FILE(APPEND "${INC_FILE}"
  39. "integer, parameter :: plflt = kind(1.0d0)\n")
  40. else(PL_DOUBLE)
  41. FILE(APPEND "${INC_FILE}"
  42. "integer, parameter :: plflt = kind(1.0)\n")
  43. endif(PL_DOUBLE)
  44. FILE(APPEND "${INC_FILE}"
  45. "integer, parameter :: plunicode = selected_int_kind(10)\n")
  46. # Mark the include file as being generated
  47. set_source_files_properties(plflt.inc PROPERTIES GENERATED ON)
  48. ## Build C part of F95 bindings
  49. if(WIN32)
  50. # Set the flags for the C compiler. The C stubs need to have the
  51. # correct case and calling convention for the Fortran compiler
  52. IF(TARGET_FORTRAN MATCHES "IVF")
  53. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DIVF")
  54. #
  55. # (AM) This flag make the C compiler create __cdecl style routines.
  56. # This is not the default for Compaq Visual Fortran.
  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. add_library(plplotf95c${LIB_TAG} ${plplotf95c${LIB_TAG}_LIB_SRCS})
  68. target_link_libraries(plplotf95c${LIB_TAG} plplot${LIB_TAG})
  69. if(USE_RPATH)
  70. get_target_property(LIB_INSTALL_RPATH plplot${LIB_TAG} INSTALL_RPATH)
  71. set_target_properties(plplotf95c${LIB_TAG}
  72. PROPERTIES
  73. SOVERSION ${plplotf95_SOVERSION}
  74. VERSION ${plplotf95_VERSION}
  75. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  76. INSTALL_NAME_DIR "${LIB_DIR}"
  77. )
  78. else(USE_RPATH)
  79. set_target_properties(plplotf95c${LIB_TAG}
  80. PROPERTIES
  81. SOVERSION ${plplotf95_SOVERSION}
  82. VERSION ${plplotf95_VERSION}
  83. INSTALL_NAME_DIR "${LIB_DIR}"
  84. )
  85. endif(USE_RPATH)
  86. install(TARGETS plplotf95c${LIB_TAG}
  87. ARCHIVE DESTINATION ${LIB_DIR}
  88. LIBRARY DESTINATION ${LIB_DIR}
  89. RUNTIME DESTINATION ${BIN_DIR}
  90. )
  91. ## Build fortran part of F95 bindings
  92. set(plplotf95${LIB_TAG}_LIB_SRCS
  93. strutil.f90
  94. configurable.f90
  95. sfstubsf95.f90
  96. sfstubs.h
  97. )
  98. if(WIN32 AND BUILD_SHARED_LIBS)
  99. SET(plplotf95${LIB_TAG}_LIB_SRCS ${plplotf95${LIB_TAG}_LIB_SRCS} plplotf95.def)
  100. endif(WIN32 AND BUILD_SHARED_LIBS)
  101. if(BUILD_SHARED_LIBS)
  102. SET_SOURCE_FILES_PROPERTIES(${plplotf95c${LIB_TAG}_LIB_SRCS}
  103. PROPERTIES COMPILE_FLAGS "-DUSINGDLL" )
  104. endif(BUILD_SHARED_LIBS)
  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. if(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 4)
  141. # Yuk! All Makefiles are run from the top level build directory and
  142. # so the f90 .mod files end up there rather than in the bindings/f95
  143. # directory. Ifort and pgf90 both have a -module command line option to
  144. # override this location, but I'm not sure how portable that?
  145. install(
  146. FILES
  147. ${CMAKE_BINARY_DIR}/plplot.mod
  148. ${CMAKE_BINARY_DIR}/plplotp.mod
  149. ${CMAKE_BINARY_DIR}/plplot_flt.mod
  150. DESTINATION ${F95_MOD_DIR}
  151. )
  152. else(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 4)
  153. # For the current cvs version of CMake, the module files are created by
  154. # default during the library build in the more logical bindings/f95
  155. # directory.
  156. install(
  157. FILES
  158. ${CMAKE_BINARY_DIR}/bindings/f95/plplot.mod
  159. ${CMAKE_BINARY_DIR}/bindings/f95/plplotp.mod
  160. ${CMAKE_BINARY_DIR}/bindings/f95/plplot_flt.mod
  161. DESTINATION ${F95_MOD_DIR}
  162. )
  163. endif(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 4)
  164. # Configure pkg-config *.pc file corresponding to libplplotf95${LIB_TAG}
  165. if(PKG_CONFIG_EXECUTABLE)
  166. if(LIB_TAG)
  167. set(PC_PRECISION "double")
  168. else(LIB_TAG)
  169. set(PC_PRECISION "single")
  170. endif(LIB_TAG)
  171. # Each list element must consist of a colon-separated string with the
  172. # following fields which are parsed out in the foreach loop below and
  173. # used to configure the corresponding pkg-config *.pc file.
  174. # BINDING - ENABLE_${BINDING} keeps track of whether a
  175. # binding has been enabled (ON) or not (OFF).
  176. # Also, ${BINDING} used to determine PC_FILE_SUFFIX
  177. # which helps to determine name of configured
  178. # *.pc file.
  179. # PC_SHORT_NAME - Used in *.pc NAME: field
  180. # PC_LONG_NAME - Used in *.pc Description: field
  181. # PC_LIBRARY_NAME - Used in *.pc Libs: field
  182. # Also used to determine PC_LINK_FLAGS and
  183. # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
  184. # fields.
  185. set(PC_DATA "f95:F95:F95 bindings, :plplotf95${LIB_TAG}${VERSION_SUFFIX}")
  186. string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
  187. set(PC_FILE_SUFFIX "-${BINDING}")
  188. set(PC_REQUIRES "plplot${LIB_TAG}")
  189. string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
  190. string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
  191. string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
  192. set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
  193. set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
  194. set(PC_LINK_FLAGS
  195. "-l${PC_LIBRARY_NAME} -lplplotf95c${LIB_TAG}${VERSION_SUFFIX} ${PC_LINK_FLAGS}"
  196. )
  197. set(PC_COMPILE_FLAGS "-I${F95_MOD_DIR} ${PC_COMPILE_FLAGS}")
  198. set(PC_CONFIGURED_FILE
  199. ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
  200. )
  201. configure_file(
  202. ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
  203. ${PC_CONFIGURED_FILE}
  204. @ONLY
  205. )
  206. install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
  207. endif(PKG_CONFIG_EXECUTABLE)
  208. endif(ENABLE_f95)