PageRenderTime 38ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_7_3/bindings/f95/CMakeLists.txt

#
CMake | 164 lines | 99 code | 22 blank | 43 comment | 4 complexity | 18cda4fd5063e3ef22a9918286db89f2 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. get_target_property(LIB_INSTALL_RPATH plplot${LIB_TAG} INSTALL_RPATH)
  49. set_target_properties(plplotf95c${LIB_TAG}
  50. PROPERTIES
  51. SOVERSION ${plplotf95_SOVERSION}
  52. VERSION ${plplotf95_VERSION}
  53. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  54. INSTALL_NAME_DIR "${LIB_DIR}"
  55. )
  56. install(TARGETS plplotf95c${LIB_TAG}
  57. ARCHIVE DESTINATION ${LIB_DIR}
  58. LIBRARY DESTINATION ${LIB_DIR}
  59. RUNTIME DESTINATION ${BIN_DIR}
  60. )
  61. ## Build fortran part of F95 bindings
  62. set(plplotf95${LIB_TAG}_LIB_SRCS
  63. strutil.f90
  64. configurable.f90
  65. sfstubsf95.f90
  66. sfstubs.h
  67. )
  68. if(WIN32 AND BUILD_SHARED_LIBS)
  69. SET(plplotf95${LIB_TAG}_LIB_SRCS ${plplotf95${LIB_TAG}_LIB_SRCS} plplotf95.def)
  70. SET_SOURCE_FILES_PROPERTIES(${plplotf95c${LIB_TAG}_LIB_SRCS}
  71. PROPERTIES COMPILE_FLAGS "-DMAKINGPLDLL" )
  72. endif(WIN32 AND BUILD_SHARED_LIBS)
  73. # Explicitly include dependencies for sfstubsf95.f90
  74. include(AddFileDependencies)
  75. add_file_dependencies(sfstubsf95.f90 ${CMAKE_CURRENT_BINARY_DIR}/plflt.inc)
  76. add_library(plplotf95${LIB_TAG} ${plplotf95${LIB_TAG}_LIB_SRCS})
  77. target_link_libraries(plplotf95${LIB_TAG} plplotf95c${LIB_TAG})
  78. set_target_properties(plplotf95${LIB_TAG}
  79. PROPERTIES
  80. SOVERSION ${plplotf95_SOVERSION}
  81. VERSION ${plplotf95_VERSION}
  82. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  83. INSTALL_NAME_DIR "${LIB_DIR}"
  84. )
  85. install(TARGETS plplotf95${LIB_TAG}
  86. ARCHIVE DESTINATION ${LIB_DIR}
  87. LIBRARY DESTINATION ${LIB_DIR}
  88. RUNTIME DESTINATION ${BIN_DIR}
  89. )
  90. # Yuk! All Makefiles are run from the top level build directory and
  91. # so the f90 .mod files end up there rather than in the bindings/f95
  92. # directory. Ifort and pgf90 both have a -module command line option to
  93. # override this location, but I'm not sure how portable that?
  94. install(
  95. FILES ${CMAKE_BINARY_DIR}/plplot.mod ${CMAKE_BINARY_DIR}/plplotp.mod ${CMAKE_BINARY_DIR}/plplot_flt.mod
  96. DESTINATION ${F95_MOD_DIR}
  97. )
  98. # Configure pkg-config *.pc file corresponding to libplplotf95${LIB_TAG}
  99. if(PKGCONFIG_EXECUTABLE)
  100. if(LIB_TAG)
  101. set(PC_PRECISION "double")
  102. else(LIB_TAG)
  103. set(PC_PRECISION "single")
  104. endif(LIB_TAG)
  105. # Each list element must consist of a colon-separated string with the
  106. # following fields which are parsed out in the foreach loop below and
  107. # used to configure the corresponding pkg-config *.pc file.
  108. # BINDING - ENABLE_${BINDING} keeps track of whether a
  109. # binding has been enabled (ON) or not (OFF).
  110. # Also, ${BINDING} used to determine PC_FILE_SUFFIX
  111. # which helps to determine name of configured
  112. # *.pc file.
  113. # PC_SHORT_NAME - Used in *.pc NAME: field
  114. # PC_LONG_NAME - Used in *.pc Description: field
  115. # PC_LIBRARY_NAME - Used in *.pc Libs: field
  116. # Also used to determine PC_LINK_FLAGS and
  117. # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
  118. # fields.
  119. set(PC_DATA "f95:F95:F95 bindings, :plplotf95${LIB_TAG}")
  120. string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
  121. set(PC_FILE_SUFFIX "-${BINDING}")
  122. set(PC_REQUIRES "plplot${LIB_TAG}")
  123. string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
  124. string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
  125. string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
  126. set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
  127. set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
  128. set(PC_LINK_FLAGS
  129. "-l${PC_LIBRARY_NAME} -lplplotf95c${LIB_TAG} ${PC_LINK_FLAGS}"
  130. )
  131. set(PC_COMPILE_FLAGS "-I${F95_MOD_DIR} ${PC_COMPILE_FLAGS}")
  132. set(PC_CONFIGURED_FILE
  133. ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
  134. )
  135. configure_file(
  136. ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
  137. ${PC_CONFIGURED_FILE}
  138. @ONLY
  139. )
  140. install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
  141. endif(PKGCONFIG_EXECUTABLE)
  142. endif(ENABLE_f95)