UsewxWidgets.cmake 3.2 KB

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