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

/tags/v5_8_0/bindings/f95/CMakeLists.txt

#
CMake | 192 lines | 125 code | 23 blank | 44 comment | 8 complexity | 04207983c6d12b3b4864bcada4592cb3 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. # Build plflt to determine KIND for PLFLT
  30. set(plflt_SRC
  31. plflt.c
  32. )
  33. add_executable(plflt ${plflt_SRC})
  34. add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/plflt.inc
  35. COMMAND ${CMAKE_CURRENT_BINARY_DIR}/plflt
  36. DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/plflt
  37. )
  38. set_source_files_properties(plflt.inc PROPERTIES GENERATED ON)
  39. ## Build C part of F95 bindings
  40. set(plplotf95c${LIB_TAG}_LIB_SRCS
  41. plstubs.h
  42. sc3d.c
  43. sccont.c
  44. scstubs.c
  45. )
  46. add_library(plplotf95c${LIB_TAG} ${plplotf95c${LIB_TAG}_LIB_SRCS})
  47. target_link_libraries(plplotf95c${LIB_TAG} plplot${LIB_TAG})
  48. if(USE_RPATH)
  49. get_target_property(LIB_INSTALL_RPATH plplot${LIB_TAG} INSTALL_RPATH)
  50. set_target_properties(plplotf95c${LIB_TAG}
  51. PROPERTIES
  52. SOVERSION ${plplotf95_SOVERSION}
  53. VERSION ${plplotf95_VERSION}
  54. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  55. INSTALL_NAME_DIR "${LIB_DIR}"
  56. )
  57. else(USE_RPATH)
  58. set_target_properties(plplotf95c${LIB_TAG}
  59. PROPERTIES
  60. SOVERSION ${plplotf95_SOVERSION}
  61. VERSION ${plplotf95_VERSION}
  62. INSTALL_NAME_DIR "${LIB_DIR}"
  63. )
  64. endif(USE_RPATH)
  65. install(TARGETS plplotf95c${LIB_TAG}
  66. ARCHIVE DESTINATION ${LIB_DIR}
  67. LIBRARY DESTINATION ${LIB_DIR}
  68. RUNTIME DESTINATION ${BIN_DIR}
  69. )
  70. ## Build fortran part of F95 bindings
  71. set(plplotf95${LIB_TAG}_LIB_SRCS
  72. strutil.f90
  73. configurable.f90
  74. sfstubsf95.f90
  75. sfstubs.h
  76. )
  77. if(WIN32 AND BUILD_SHARED_LIBS)
  78. SET(plplotf95${LIB_TAG}_LIB_SRCS ${plplotf95${LIB_TAG}_LIB_SRCS} plplotf95.def)
  79. SET_SOURCE_FILES_PROPERTIES(${plplotf95c${LIB_TAG}_LIB_SRCS}
  80. PROPERTIES COMPILE_FLAGS "-DMAKINGPLDLL" )
  81. endif(WIN32 AND BUILD_SHARED_LIBS)
  82. # Explicitly include dependencies for sfstubsf95.f90
  83. include(AddFileDependencies)
  84. add_file_dependencies(sfstubsf95.f90 ${CMAKE_CURRENT_BINARY_DIR}/plflt.inc)
  85. add_library(plplotf95${LIB_TAG} ${plplotf95${LIB_TAG}_LIB_SRCS})
  86. target_link_libraries(plplotf95${LIB_TAG} plplotf95c${LIB_TAG})
  87. if(USE_RPATH)
  88. set_target_properties(plplotf95${LIB_TAG}
  89. PROPERTIES
  90. SOVERSION ${plplotf95_SOVERSION}
  91. VERSION ${plplotf95_VERSION}
  92. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  93. INSTALL_NAME_DIR "${LIB_DIR}"
  94. )
  95. else(USE_RPATH)
  96. set_target_properties(plplotf95${LIB_TAG}
  97. PROPERTIES
  98. SOVERSION ${plplotf95_SOVERSION}
  99. VERSION ${plplotf95_VERSION}
  100. INSTALL_NAME_DIR "${LIB_DIR}"
  101. )
  102. endif(USE_RPATH)
  103. # Set the path and the suffix for the (shared) libraries
  104. if(CYGWIN)
  105. if(BUILD_SHARED_LIBS)
  106. set(SHLIB_DIR "${BIN_DIR}")
  107. endif(BUILD_SHARED_LIBS)
  108. set(VERSION_SUFFIX "-${plplotf95_VERSION}")
  109. else(CYGWIN)
  110. set(VERSION_SUFFIX "")
  111. endif(CYGWIN)
  112. install(TARGETS plplotf95${LIB_TAG}
  113. ARCHIVE DESTINATION ${LIB_DIR}
  114. LIBRARY DESTINATION ${LIB_DIR}
  115. RUNTIME DESTINATION ${BIN_DIR}
  116. )
  117. # Yuk! All Makefiles are run from the top level build directory and
  118. # so the f90 .mod files end up there rather than in the bindings/f95
  119. # directory. Ifort and pgf90 both have a -module command line option to
  120. # override this location, but I'm not sure how portable that?
  121. install(
  122. FILES ${CMAKE_BINARY_DIR}/plplot.mod ${CMAKE_BINARY_DIR}/plplotp.mod ${CMAKE_BINARY_DIR}/plplot_flt.mod
  123. DESTINATION ${F95_MOD_DIR}
  124. )
  125. # Configure pkg-config *.pc file corresponding to libplplotf95${LIB_TAG}
  126. if(PKG_CONFIG_EXECUTABLE)
  127. if(LIB_TAG)
  128. set(PC_PRECISION "double")
  129. else(LIB_TAG)
  130. set(PC_PRECISION "single")
  131. endif(LIB_TAG)
  132. # Each list element must consist of a colon-separated string with the
  133. # following fields which are parsed out in the foreach loop below and
  134. # used to configure the corresponding pkg-config *.pc file.
  135. # BINDING - ENABLE_${BINDING} keeps track of whether a
  136. # binding has been enabled (ON) or not (OFF).
  137. # Also, ${BINDING} used to determine PC_FILE_SUFFIX
  138. # which helps to determine name of configured
  139. # *.pc file.
  140. # PC_SHORT_NAME - Used in *.pc NAME: field
  141. # PC_LONG_NAME - Used in *.pc Description: field
  142. # PC_LIBRARY_NAME - Used in *.pc Libs: field
  143. # Also used to determine PC_LINK_FLAGS and
  144. # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
  145. # fields.
  146. set(PC_DATA "f95:F95:F95 bindings, :plplotf95${LIB_TAG}${VERSION_SUFFIX}")
  147. string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
  148. set(PC_FILE_SUFFIX "-${BINDING}")
  149. set(PC_REQUIRES "plplot${LIB_TAG}")
  150. string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
  151. string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
  152. string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
  153. set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
  154. set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
  155. set(PC_LINK_FLAGS
  156. "-l${PC_LIBRARY_NAME} -lplplotf95c${LIB_TAG}${VERSION_SUFFIX} ${PC_LINK_FLAGS}"
  157. )
  158. set(PC_COMPILE_FLAGS "-I${F95_MOD_DIR} ${PC_COMPILE_FLAGS}")
  159. set(PC_CONFIGURED_FILE
  160. ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
  161. )
  162. configure_file(
  163. ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
  164. ${PC_CONFIGURED_FILE}
  165. @ONLY
  166. )
  167. install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
  168. endif(PKG_CONFIG_EXECUTABLE)
  169. endif(ENABLE_f95)