PageRenderTime 57ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v5_9_5/bindings/c++/CMakeLists.txt

#
CMake | 119 lines | 72 code | 10 blank | 37 comment | 5 complexity | ce8c65dd0071256fc9eacf10c393902e MD5 | raw file
Possible License(s): LGPL-2.0, BSD-3-Clause-No-Nuclear-License-2014, Apache-2.0, GPL-2.0
  1. # bindings/c++/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_cxx)
  21. set(plplotcxx${LIB_TAG}_LIB_SRCS
  22. plstream.cc
  23. )
  24. set(plplotcxx${LIB_TAG}_INSTALLED_HEADERS
  25. plstream.h
  26. )
  27. # Set the include path
  28. include_directories(
  29. ${CMAKE_SOURCE_DIR}/include
  30. ${CMAKE_BINARY_DIR}
  31. ${CMAKE_BINARY_DIR}/include
  32. )
  33. # Create plplotcxx[d] library
  34. add_library(plplotcxx${LIB_TAG} ${plplotcxx${LIB_TAG}_LIB_SRCS})
  35. if(BUILD_SHARED_LIBS)
  36. SET_SOURCE_FILES_PROPERTIES(${plplotcxx${LIB_TAG}_LIB_SRCS}
  37. PROPERTIES COMPILE_FLAGS "-DUSINGDLL" )
  38. endif(BUILD_SHARED_LIBS)
  39. target_link_libraries(plplotcxx${LIB_TAG} plplot${LIB_TAG})
  40. if(USE_RPATH)
  41. get_target_property(LIB_INSTALL_RPATH plplot${LIB_TAG} INSTALL_RPATH)
  42. set_target_properties(plplotcxx${LIB_TAG}
  43. PROPERTIES
  44. SOVERSION ${plplotcxx_SOVERSION}
  45. VERSION ${plplotcxx_VERSION}
  46. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  47. INSTALL_NAME_DIR "${LIB_DIR}"
  48. )
  49. else(USE_RPATH)
  50. set_target_properties(plplotcxx${LIB_TAG}
  51. PROPERTIES
  52. SOVERSION ${plplotcxx_SOVERSION}
  53. VERSION ${plplotcxx_VERSION}
  54. INSTALL_NAME_DIR "${LIB_DIR}"
  55. )
  56. endif(USE_RPATH)
  57. # Install library in lib/
  58. install(TARGETS plplotcxx${LIB_TAG}
  59. EXPORT export_plplot
  60. ARCHIVE DESTINATION ${LIB_DIR}
  61. LIBRARY DESTINATION ${LIB_DIR}
  62. RUNTIME DESTINATION ${BIN_DIR}
  63. )
  64. install(FILES
  65. ${plplotcxx${LIB_TAG}_INSTALLED_HEADERS}
  66. DESTINATION ${INCLUDE_DIR}
  67. )
  68. # Configure pkg-config *.pc file corresponding to libplplotcxx${LIB_TAG}
  69. if(PKG_CONFIG_EXECUTABLE)
  70. if(LIB_TAG)
  71. set(PC_PRECISION "double")
  72. else(LIB_TAG)
  73. set(PC_PRECISION "single")
  74. endif(LIB_TAG)
  75. # Each list element must consist of a colon-separated string with the
  76. # following fields which are parsed out in the foreach loop below and
  77. # used to configure the corresponding pkg-config *.pc file.
  78. # BINDING - ENABLE_${BINDING} keeps track of whether a
  79. # binding has been enabled (ON) or not (OFF).
  80. # Also, ${BINDING} used to determine PC_FILE_SUFFIX
  81. # which helps to determine name of configured
  82. # *.pc file.
  83. # PC_SHORT_NAME - Used in *.pc NAME: field
  84. # PC_LONG_NAME - Used in *.pc Description: field
  85. # PC_LIBRARY_NAME - Used in *.pc Libs: field
  86. # Also used to determine PC_LINK_FLAGS and
  87. # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
  88. # fields.
  89. set(PC_DATA "c++:C++:C++ bindings, :plplotcxx${LIB_TAG}")
  90. string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
  91. set(PC_FILE_SUFFIX "-${BINDING}")
  92. set(PC_REQUIRES "plplot${LIB_TAG}")
  93. string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
  94. string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
  95. string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
  96. set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
  97. set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
  98. set(PC_LINK_FLAGS "-l${PC_LIBRARY_NAME} ${PC_LINK_FLAGS}")
  99. set(PC_CONFIGURED_FILE
  100. ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
  101. )
  102. configure_file(
  103. ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
  104. ${PC_CONFIGURED_FILE}
  105. @ONLY
  106. )
  107. install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
  108. endif(PKG_CONFIG_EXECUTABLE)
  109. endif(ENABLE_cxx)