UsewxWidgets.cmake 2.9 KB

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