UsewxWidgets.cmake 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # - Convenience include for using wxWidgets library
  2. # Finds if wxWidgets is installed
  3. # and set the appropriate libs, incdirs, flags etc.
  4. # INCLUDE_DIRECTORIES, LINK_DIRECTORIES and ADD_DEFINITIONS
  5. # are called.
  6. #
  7. # USAGE
  8. # SET( wxWidgets_USE_LIBS gl xml xrc ) # optionally: more than wx std libs
  9. # FIND_PACKAGE(wxWidgets REQUIRED)
  10. # INCLUDE( ${xWidgets_USE_FILE} )
  11. # ... add your targets here, e.g. ADD_EXECUTABLE/ ADD_LIBRARY ...
  12. # TARGET_LINK_LIBRARIERS( <yourWxDependantTarget> ${wxWidgets_LIBRARIES})
  13. #
  14. # DEPRECATED
  15. # LINK_LIBRARIES is not called in favor of adding dependencies per target.
  16. #
  17. # AUTHOR
  18. # Jan Woetzel <jw -at- mip.informatik.uni-kiel.de>
  19. #=============================================================================
  20. # Copyright 2004-2009 Kitware, Inc.
  21. # Copyright 2006 Jan Woetzel
  22. #
  23. # Distributed under the OSI-approved BSD License (the "License");
  24. # see accompanying file Copyright.txt for details.
  25. #
  26. # This software is distributed WITHOUT ANY WARRANTY; without even the
  27. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  28. # See the License for more information.
  29. #=============================================================================
  30. # (To distributed this file outside of CMake, substitute the full
  31. # License text for the above reference.)
  32. # debug message and logging.
  33. # comment these out for distribution
  34. IF (NOT LOGFILE )
  35. # SET(LOGFILE "${PROJECT_BINARY_DIR}/CMakeOutput.log")
  36. ENDIF (NOT LOGFILE )
  37. MACRO(MSG _MSG)
  38. # FILE(APPEND ${LOGFILE} "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}\n")
  39. # MESSAGE(STATUS "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}")
  40. ENDMACRO(MSG)
  41. MSG("wxWidgets_FOUND=${wxWidgets_FOUND}")
  42. IF (wxWidgets_FOUND)
  43. IF (wxWidgets_INCLUDE_DIRS)
  44. IF(wxWidgets_INCLUDE_DIRS_NO_SYSTEM)
  45. INCLUDE_DIRECTORIES(${wxWidgets_INCLUDE_DIRS})
  46. ELSE(wxWidgets_INCLUDE_DIRS_NO_SYSTEM)
  47. INCLUDE_DIRECTORIES(SYSTEM ${wxWidgets_INCLUDE_DIRS})
  48. ENDIF(wxWidgets_INCLUDE_DIRS_NO_SYSTEM)
  49. MSG("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS}")
  50. ENDIF(wxWidgets_INCLUDE_DIRS)
  51. IF (wxWidgets_LIBRARY_DIRS)
  52. LINK_DIRECTORIES(${wxWidgets_LIBRARY_DIRS})
  53. MSG("wxWidgets_LIBRARY_DIRS=${wxWidgets_LIBRARY_DIRS}")
  54. ENDIF(wxWidgets_LIBRARY_DIRS)
  55. IF (wxWidgets_DEFINITIONS)
  56. SET_PROPERTY(DIRECTORY APPEND
  57. PROPERTY COMPILE_DEFINITIONS ${wxWidgets_DEFINITIONS})
  58. MSG("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS}")
  59. ENDIF(wxWidgets_DEFINITIONS)
  60. IF (wxWidgets_DEFINITIONS_DEBUG)
  61. SET_PROPERTY(DIRECTORY APPEND
  62. PROPERTY COMPILE_DEFINITIONS_DEBUG ${wxWidgets_DEFINITIONS_DEBUG})
  63. MSG("wxWidgets_DEFINITIONS_DEBUG=${wxWidgets_DEFINITIONS_DEBUG}")
  64. ENDIF(wxWidgets_DEFINITIONS_DEBUG)
  65. IF (wxWidgets_CXX_FLAGS)
  66. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${wxWidgets_CXX_FLAGS}")
  67. MSG("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}")
  68. ENDIF(wxWidgets_CXX_FLAGS)
  69. # DEPRECATED JW
  70. # just for backward compatibility: add deps to all targets
  71. # library projects better use advanced FIND_PACKAGE(wxWidgets) directly.
  72. #IF(wxWidgets_LIBRARIES)
  73. # LINK_LIBRARIES(${wxWidgets_LIBRARIES})
  74. # # BUG: str too long: MSG("wxWidgets_LIBRARIES=${wxWidgets_LIBRARIES}")
  75. # IF(LOGFILE)
  76. # FILE(APPEND ${LOGFILE} "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${wxWidgets_LIBRARIES}\n")
  77. # ENDIF(LOGFILE)
  78. #ENDIF(wxWidgets_LIBRARIES)
  79. ELSE (wxWidgets_FOUND)
  80. MESSAGE("wxWidgets requested but not found.")
  81. ENDIF(wxWidgets_FOUND)