UsewxWidgets.cmake 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #.rst:
  2. # UsewxWidgets
  3. # ------------
  4. #
  5. # Convenience include for using wxWidgets library.
  6. #
  7. # Determines if wxWidgets was FOUND and sets the appropriate libs,
  8. # incdirs, flags, etc. INCLUDE_DIRECTORIES and LINK_DIRECTORIES are
  9. # called.
  10. #
  11. # USAGE
  12. #
  13. # ::
  14. #
  15. # # Note that for MinGW users the order of libs is important!
  16. # find_package(wxWidgets REQUIRED net gl core base)
  17. # include(${wxWidgets_USE_FILE})
  18. # # and for each of your dependent executable/library targets:
  19. # target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
  20. #
  21. #
  22. #
  23. # DEPRECATED
  24. #
  25. # ::
  26. #
  27. # LINK_LIBRARIES is not called in favor of adding dependencies per target.
  28. #
  29. #
  30. #
  31. # AUTHOR
  32. #
  33. # ::
  34. #
  35. # Jan Woetzel <jw -at- mip.informatik.uni-kiel.de>
  36. #=============================================================================
  37. # Copyright 2004-2009 Kitware, Inc.
  38. # Copyright 2006 Jan Woetzel
  39. #
  40. # Distributed under the OSI-approved BSD License (the "License");
  41. # see accompanying file Copyright.txt for details.
  42. #
  43. # This software is distributed WITHOUT ANY WARRANTY; without even the
  44. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  45. # See the License for more information.
  46. #=============================================================================
  47. # (To distribute this file outside of CMake, substitute the full
  48. # License text for the above reference.)
  49. # debug message and logging.
  50. # comment these out for distribution
  51. if (NOT LOGFILE )
  52. # set(LOGFILE "${PROJECT_BINARY_DIR}/CMakeOutput.log")
  53. endif ()
  54. macro(MSG _MSG)
  55. # file(APPEND ${LOGFILE} "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}\n")
  56. # message(STATUS "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}")
  57. endmacro()
  58. MSG("wxWidgets_FOUND=${wxWidgets_FOUND}")
  59. if (wxWidgets_FOUND)
  60. if (wxWidgets_INCLUDE_DIRS)
  61. if(wxWidgets_INCLUDE_DIRS_NO_SYSTEM)
  62. include_directories(${wxWidgets_INCLUDE_DIRS})
  63. else()
  64. include_directories(SYSTEM ${wxWidgets_INCLUDE_DIRS})
  65. endif()
  66. MSG("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS}")
  67. endif()
  68. if (wxWidgets_LIBRARY_DIRS)
  69. link_directories(${wxWidgets_LIBRARY_DIRS})
  70. MSG("wxWidgets_LIBRARY_DIRS=${wxWidgets_LIBRARY_DIRS}")
  71. endif()
  72. if (wxWidgets_DEFINITIONS)
  73. set_property(DIRECTORY APPEND
  74. PROPERTY COMPILE_DEFINITIONS ${wxWidgets_DEFINITIONS})
  75. MSG("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS}")
  76. endif()
  77. if (wxWidgets_DEFINITIONS_DEBUG)
  78. set_property(DIRECTORY APPEND
  79. PROPERTY COMPILE_DEFINITIONS_DEBUG ${wxWidgets_DEFINITIONS_DEBUG})
  80. MSG("wxWidgets_DEFINITIONS_DEBUG=${wxWidgets_DEFINITIONS_DEBUG}")
  81. endif()
  82. if (wxWidgets_CXX_FLAGS)
  83. # Flags are expected to be a string here, not a list.
  84. string(REPLACE ";" " " wxWidgets_CXX_FLAGS_str "${wxWidgets_CXX_FLAGS}")
  85. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${wxWidgets_CXX_FLAGS_str}")
  86. MSG("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS_str}")
  87. unset(wxWidgets_CXX_FLAGS_str)
  88. endif()
  89. # DEPRECATED JW
  90. # just for backward compatibility: add deps to all targets
  91. # library projects better use advanced find_package(wxWidgets) directly.
  92. #if(wxWidgets_LIBRARIES)
  93. # link_libraries(${wxWidgets_LIBRARIES})
  94. # # BUG: str too long: MSG("wxWidgets_LIBRARIES=${wxWidgets_LIBRARIES}")
  95. # if(LOGFILE)
  96. # file(APPEND ${LOGFILE} "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${wxWidgets_LIBRARIES}\n")
  97. # endif()
  98. #endif()
  99. else ()
  100. message("wxWidgets requested but not found.")
  101. endif()