PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_9_0/bindings/f95/CMakeLists.txt

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