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

/trunk/bindings/wxwidgets/CMakeLists.txt

#
CMake | 186 lines | 122 code | 19 blank | 45 comment | 8 complexity | 93b7a1bee34189186de7d59c495068ab MD5 | raw file
Possible License(s): LGPL-2.0, BSD-3-Clause-No-Nuclear-License-2014, Apache-2.0, GPL-2.0
  1. # bindings/wxwidgets/CMakeLists.txt
  2. ### Process this file with cmake to produce Makefile
  3. ###
  4. # Copyright (C) 2007 Werner Smekal
  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_wxwidgets)
  21. set(plplotwxwidgets${LIB_TAG}_LIB_SRCS
  22. wxPLplotstream.cpp
  23. wxPLplotwindow.cpp
  24. )
  25. # configure header file - we need to make sure, that the user of the bindings
  26. # can't set the wrong options (use freetype/agg)
  27. CONFIGURE_FILE(
  28. ${CMAKE_CURRENT_SOURCE_DIR}/wxPLplotstream.h.in
  29. ${CMAKE_CURRENT_BINARY_DIR}/wxPLplotstream.h
  30. )
  31. set(plplotwxwidgets${LIB_TAG}_INSTALLED_HEADERS
  32. ${CMAKE_CURRENT_BINARY_DIR}/wxPLplotstream.h
  33. wxPLplotwindow.h
  34. )
  35. # Set the include path
  36. include_directories(
  37. ${CMAKE_SOURCE_DIR}/include
  38. ${CMAKE_SOURCE_DIR}/lib/qsastime
  39. ${CMAKE_SOURCE_DIR}/bindings/c++
  40. ${CMAKE_BINARY_DIR}
  41. ${CMAKE_BINARY_DIR}/include
  42. ${CMAKE_CURRENT_BINARY_DIR}
  43. )
  44. # Create plplotwxwidgets[d] library
  45. add_library(plplotwxwidgets${LIB_TAG} ${plplotwxwidgets${LIB_TAG}_LIB_SRCS})
  46. if(NON_TRANSITIVE)
  47. # empty list ==> non-transitive linking for everything that links to
  48. # libplplotwxwidgetsd in the shared libraries case.
  49. target_link_libraries(plplotwxwidgets${LIB_TAG} LINK_INTERFACE_LIBRARIES)
  50. # This configures the pkg-config method to use non-transitive linking.
  51. set(PC_REQUIRES_TAG "Requires.private")
  52. else(NON_TRANSITIVE)
  53. # This configures the pkg-config method to use transitive linking
  54. set(PC_REQUIRES_TAG "Requires")
  55. endif(NON_TRANSITIVE)
  56. if(BUILD_SHARED_LIBS)
  57. SET_SOURCE_FILES_PROPERTIES(${plplotwxwidgets${LIB_TAG}_LIB_SRCS}
  58. PROPERTIES COMPILE_FLAGS "-DUSINGDLL" )
  59. endif(BUILD_SHARED_LIBS)
  60. INCLUDE_DIRECTORIES( ${wxWidgets_INCLUDE_DIRS} )
  61. IF(wxWidgets_DEFINITIONS)
  62. SET_PROPERTY(DIRECTORY APPEND
  63. PROPERTY COMPILE_DEFINITIONS ${wxWidgets_DEFINITIONS})
  64. ENDIF(wxWidgets_DEFINITIONS)
  65. IF(wxWidgets_DEFINITIONS_DEBUG)
  66. SET_PROPERTY(DIRECTORY APPEND
  67. PROPERTY COMPILE_DEFINITIONS_DEBUG ${wxWidgets_DEFINITIONS_DEBUG})
  68. ENDIF(wxWidgets_DEFINITIONS_DEBUG)
  69. target_link_libraries(
  70. plplotwxwidgets${LIB_TAG}
  71. plplotcxx${LIB_TAG}
  72. ${wxwidgets_LINK_FLAGS}
  73. )
  74. if(USE_RPATH)
  75. get_target_property(LIB_INSTALL_RPATH plplot${LIB_TAG} INSTALL_RPATH)
  76. set_target_properties(plplotwxwidgets${LIB_TAG}
  77. PROPERTIES
  78. SOVERSION ${plplotwxwidgets_SOVERSION}
  79. VERSION ${plplotwxwidgets_VERSION}
  80. INSTALL_RPATH "${LIB_INSTALL_RPATH}"
  81. INSTALL_NAME_DIR "${LIB_DIR}"
  82. )
  83. else(USE_RPATH)
  84. set_target_properties(plplotwxwidgets${LIB_TAG}
  85. PROPERTIES
  86. SOVERSION ${plplotwxwidgets_SOVERSION}
  87. VERSION ${plplotwxwidgets_VERSION}
  88. INSTALL_NAME_DIR "${LIB_DIR}"
  89. )
  90. endif(USE_RPATH)
  91. # Install library in lib/
  92. install(TARGETS plplotwxwidgets${LIB_TAG}
  93. EXPORT export_plplot
  94. ARCHIVE DESTINATION ${LIB_DIR}
  95. LIBRARY DESTINATION ${LIB_DIR}
  96. RUNTIME DESTINATION ${BIN_DIR}
  97. )
  98. install(FILES
  99. ${plplotwxwidgets${LIB_TAG}_INSTALLED_HEADERS}
  100. DESTINATION ${INCLUDE_DIR}
  101. )
  102. # Configure pkg-config *.pc file corresponding to libplplotwxwidgets${LIB_TAG}
  103. if(PKG_CONFIG_EXECUTABLE)
  104. if(LIB_TAG)
  105. set(PC_PRECISION "double")
  106. else(LIB_TAG)
  107. set(PC_PRECISION "single")
  108. endif(LIB_TAG)
  109. # Determine libplplotwxwidgets${LIB_TAG}_COMPILE_FLAGS
  110. set(wxWidgets_DEFINITIONS_all "${wxWidgets_DEFINITIONS}")
  111. if(wxWidgets_DEFINITIONS_DEBUG)
  112. set(wxWidgets_DEFINITIONS_all "${wxWidgets_DEFINITIONS};${wxWidgets_DEFINITIONS_DEBUG}")
  113. endif(wxWidgets_DEFINITIONS_DEBUG)
  114. STRING(REGEX REPLACE ";" " -D"
  115. libplplotwxwidgets${LIB_TAG}_COMPILE_FLAGS
  116. "-D${wxWidgets_DEFINITIONS_all}"
  117. )
  118. STRING(REGEX REPLACE ";" " -I"
  119. wxWidgets_IFLAGS
  120. "-I${wxWidgets_INCLUDE_DIRS}"
  121. )
  122. set(libplplotwxwidgets${LIB_TAG}_COMPILE_FLAGS
  123. "${libplplotwxwidgets${LIB_TAG}_COMPILE_FLAGS} ${wxWidgets_IFLAGS}"
  124. )
  125. # Determine libplplotwxwidgets${LIB_TAG}_LINK_FLAGS
  126. pkg_config_link_flags(
  127. libplplotwxwidgets${LIB_TAG}_LINK_FLAGS
  128. "${wxwidgets_LINK_FLAGS}"
  129. )
  130. # Each list element must consist of a colon-separated string with the
  131. # following fields which are parsed out in the foreach loop below and
  132. # used to configure the corresponding pkg-config *.pc file.
  133. # BINDING - ENABLE_${BINDING} keeps track of whether a
  134. # binding has been enabled (ON) or not (OFF).
  135. # Also, ${BINDING} used to determine PC_FILE_SUFFIX
  136. # which helps to determine name of configured
  137. # *.pc file.
  138. # PC_SHORT_NAME - Used in *.pc NAME: field
  139. # PC_LONG_NAME - Used in *.pc Description: field
  140. # PC_LIBRARY_NAME - Used in *.pc Libs: field
  141. # Also used to determine PC_LINK_FLAGS and
  142. # PC_COMPILE_FLAGS used in *.pc Libs: and Cflags:
  143. # fields.
  144. set(PC_DATA "wxwidgets:wxWidgets:wxWidgets bindings, :plplotwxwidgets${LIB_TAG}")
  145. string(REGEX REPLACE "^(.*):.*:.*:.*$" "\\1" BINDING ${PC_DATA})
  146. set(PC_FILE_SUFFIX "-${BINDING}")
  147. set(PC_REQUIRES "plplot${LIB_TAG}-c++")
  148. string(REGEX REPLACE "^.*:(.*):.*:.*$" "\\1" PC_SHORT_NAME ${PC_DATA})
  149. string(REGEX REPLACE "^.*:.*:(.*):.*$" "\\1" PC_LONG_NAME ${PC_DATA})
  150. string(REGEX REPLACE "^.*:.*:.*:(.*)$" "\\1" PC_LIBRARY_NAME ${PC_DATA})
  151. set(PC_LINK_FLAGS "${lib${PC_LIBRARY_NAME}_LINK_FLAGS}")
  152. set(PC_COMPILE_FLAGS "${lib${PC_LIBRARY_NAME}_COMPILE_FLAGS}")
  153. if(NON_TRANSITIVE)
  154. set(PC_LINK_FLAGS "-lplplot${LIB_TAG} -lplplotcxx${LIB_TAG} ${PC_LINK_FLAGS}")
  155. endif(NON_TRANSITIVE)
  156. set(PC_LINK_FLAGS "-l${PC_LIBRARY_NAME} ${PC_LINK_FLAGS}")
  157. set(PC_CONFIGURED_FILE
  158. ${CMAKE_BINARY_DIR}/pkgcfg/plplot${LIB_TAG}${PC_FILE_SUFFIX}.pc
  159. )
  160. configure_file(
  161. ${CMAKE_SOURCE_DIR}/pkgcfg/plplot-template.pc.cmake
  162. ${PC_CONFIGURED_FILE}
  163. @ONLY
  164. )
  165. install(FILES ${PC_CONFIGURED_FILE} DESTINATION ${PKG_CONFIG_DIR})
  166. endif(PKG_CONFIG_EXECUTABLE)
  167. endif(ENABLE_wxwidgets)