PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_8_0_RC1/bindings/f95/CMakeLists.txt

#
CMake | 182 lines | 117 code | 22 blank | 43 comment | 6 complexity | 0cdc553ffa6e063a900e0c601f8903af 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. install(TARGETS plplotf95${LIB_TAG}
  104. ARCHIVE DESTINATION ${LIB_DIR}
  105. LIBRARY DESTINATION ${LIB_DIR}
  106. RUNTIME DESTINATION ${BIN_DIR}
  107. )
  108. # Yuk! All Makefiles are run from the top level build directory and
  109. # so the f90 .mod files end up there rather than in the bindings/f95
  110. # directory. Ifort and pgf90 both have a -module command line option to
  111. # override this location, but I'm not sure how portable that?
  112. install(
  113. FILES ${CMAKE_BINARY_DIR}/plplot.mod ${CMAKE_BINARY_DIR}/plplotp.mod ${CMAKE_BINARY_DIR}/plplot_flt.mod
  114. DESTINATION ${F95_MOD_DIR}
  115. )
  116. # Configure pkg-config *.pc file corresponding to libplplotf95${LIB_TAG}
  117. if(PKG_CONFIG_EXECUTABLE)
  118. if(LIB_TAG)
  119. set(PC_PRECISION "double")
  120. else(LIB_TAG)
  121. set(PC_PRECISION "single")
  122. endif(LIB_TAG)
  123. # Each list element must consist of a colon-separated string with the
  124. # following fields which are parsed out in the foreach loop below and
  125. # used to configure the corresponding pkg-config *.pc file.
  126. # BINDING - ENABLE_${BINDING} keeps track of whether a
  127. # binding has been enabled (ON) or not (OFF).
  128. # Also, ${BINDING} used to determine PC_FILE_SUFFIX
  129. # which helps to determine name of configured
  130. # *.pc file.
  131. # PC_SHORT_NAME - Used in *.pc NAME: field
  132. # PC_LONG_NAME - Used in *.pc Description: field
  133. # PC_LIBRARY_NAME - Used in *.pc Libs: field
  134. # Also used to determine PC_LINK_FLAGS and
  135. # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
  136. # fields.
  137. set(PC_DATA "f95:F95:F95 bindings, :plplotf95${LIB_TAG}")
  138. string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
  139. set(PC_FILE_SUFFIX "-${BINDING}")
  140. set(PC_REQUIRES "plplot${LIB_TAG}")
  141. string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
  142. string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
  143. string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
  144. set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
  145. set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
  146. set(PC_LINK_FLAGS
  147. "-l${PC_LIBRARY_NAME} -lplplotf95c${LIB_TAG} ${PC_LINK_FLAGS}"
  148. )
  149. set(PC_COMPILE_FLAGS "-I${F95_MOD_DIR} ${PC_COMPILE_FLAGS}")
  150. set(PC_CONFIGURED_FILE
  151. ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
  152. )
  153. configure_file(
  154. ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
  155. ${PC_CONFIGURED_FILE}
  156. @ONLY
  157. )
  158. install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
  159. endif(PKG_CONFIG_EXECUTABLE)
  160. endif(ENABLE_f95)