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

/trunk/bindings/c++/CMakeLists.txt

#
CMake | 129 lines | 78 code | 10 blank | 41 comment | 6 complexity | 00d9a94f4a7ee81c6073c3c54fa170be 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(NON_TRANSITIVE)
  41. # empty list ==> non-transitive linking for everything that links
  42. # to libplplotcxx in the shared libraries case.
  43. target_link_libraries(plplotcxx${LIB_TAG} LINK_INTERFACE_LIBRARIES)
  44. # This configures the pkg-config method to use non-transitive linking.
  45. set(PC_REQUIRES_TAG "Requires.private")
  46. else(NON_TRANSITIVE)
  47. # This configures the pkg-config method to use transitive linking
  48. set(PC_REQUIRES_TAG "Requires")
  49. endif(NON_TRANSITIVE)
  50. if(USE_RPATH)
  51. get_target_property(LIB_INSTALL_RPATH plplot${LIB_TAG} INSTALL_RPATH)
  52. set_target_properties(plplotcxx${LIB_TAG}
  53. PROPERTIES
  54. SOVERSION ${plplotcxx_SOVERSION}
  55. VERSION ${plplotcxx_VERSION}
  56. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  57. INSTALL_NAME_DIR "${LIB_DIR}"
  58. )
  59. else(USE_RPATH)
  60. set_target_properties(plplotcxx${LIB_TAG}
  61. PROPERTIES
  62. SOVERSION ${plplotcxx_SOVERSION}
  63. VERSION ${plplotcxx_VERSION}
  64. INSTALL_NAME_DIR "${LIB_DIR}"
  65. )
  66. endif(USE_RPATH)
  67. # Install library in lib/
  68. install(TARGETS plplotcxx${LIB_TAG}
  69. EXPORT export_plplot
  70. ARCHIVE DESTINATION ${LIB_DIR}
  71. LIBRARY DESTINATION ${LIB_DIR}
  72. RUNTIME DESTINATION ${BIN_DIR}
  73. )
  74. install(FILES
  75. ${plplotcxx${LIB_TAG}_INSTALLED_HEADERS}
  76. DESTINATION ${INCLUDE_DIR}
  77. )
  78. # Configure pkg-config *.pc file corresponding to libplplotcxx${LIB_TAG}
  79. if(PKG_CONFIG_EXECUTABLE)
  80. if(LIB_TAG)
  81. set(PC_PRECISION "double")
  82. else(LIB_TAG)
  83. set(PC_PRECISION "single")
  84. endif(LIB_TAG)
  85. # Each list element must consist of a colon-separated string with the
  86. # following fields which are parsed out in the foreach loop below and
  87. # used to configure the corresponding pkg-config *.pc file.
  88. # BINDING - ENABLE_${BINDING} keeps track of whether a
  89. # binding has been enabled (ON) or not (OFF).
  90. # Also, ${BINDING} used to determine PC_FILE_SUFFIX
  91. # which helps to determine name of configured
  92. # *.pc file.
  93. # PC_SHORT_NAME - Used in *.pc NAME: field
  94. # PC_LONG_NAME - Used in *.pc Description: field
  95. # PC_LIBRARY_NAME - Used in *.pc Libs: field
  96. # Also used to determine PC_LINK_FLAGS and
  97. # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
  98. # fields.
  99. set(PC_DATA "c++:C++:C++ bindings, :plplotcxx${LIB_TAG}")
  100. string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
  101. set(PC_FILE_SUFFIX "-${BINDING}")
  102. set(PC_REQUIRES "plplot${LIB_TAG}")
  103. string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
  104. string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
  105. string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
  106. set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
  107. set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
  108. set(PC_LINK_FLAGS "-l${PC_LIBRARY_NAME} ${PC_LINK_FLAGS}")
  109. set(PC_CONFIGURED_FILE
  110. ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
  111. )
  112. configure_file(
  113. ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
  114. ${PC_CONFIGURED_FILE}
  115. @ONLY
  116. )
  117. install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
  118. endif(PKG_CONFIG_EXECUTABLE)
  119. endif(ENABLE_cxx)