Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / UsewxWidgets.cmake
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 #=============================================================================
19 # Copyright 2004-2009 Kitware, Inc.
20 # Copyright 2006      Jan Woetzel
21 #
22 # Distributed under the OSI-approved BSD License (the "License");
23 # see accompanying file Copyright.txt for details.
24 #
25 # This software is distributed WITHOUT ANY WARRANTY; without even the
26 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 # See the License for more information.
28 #=============================================================================
29 # (To distribute this file outside of CMake, substitute the full
30 #  License text for the above reference.)
31
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 ()
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()
41
42
43 MSG("wxWidgets_FOUND=${wxWidgets_FOUND}")
44 if   (wxWidgets_FOUND)
45   if   (wxWidgets_INCLUDE_DIRS)
46     if(wxWidgets_INCLUDE_DIRS_NO_SYSTEM)
47       include_directories(${wxWidgets_INCLUDE_DIRS})
48     else()
49       include_directories(SYSTEM ${wxWidgets_INCLUDE_DIRS})
50     endif()
51     MSG("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS}")
52   endif()
53
54   if   (wxWidgets_LIBRARY_DIRS)
55     link_directories(${wxWidgets_LIBRARY_DIRS})
56     MSG("wxWidgets_LIBRARY_DIRS=${wxWidgets_LIBRARY_DIRS}")
57   endif()
58
59   if   (wxWidgets_DEFINITIONS)
60     set_property(DIRECTORY APPEND
61       PROPERTY COMPILE_DEFINITIONS ${wxWidgets_DEFINITIONS})
62     MSG("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS}")
63   endif()
64
65   if   (wxWidgets_DEFINITIONS_DEBUG)
66     set_property(DIRECTORY APPEND
67       PROPERTY COMPILE_DEFINITIONS_DEBUG ${wxWidgets_DEFINITIONS_DEBUG})
68     MSG("wxWidgets_DEFINITIONS_DEBUG=${wxWidgets_DEFINITIONS_DEBUG}")
69   endif()
70
71   if   (wxWidgets_CXX_FLAGS)
72     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${wxWidgets_CXX_FLAGS}")
73     MSG("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}")
74   endif()
75
76   # DEPRECATED JW
77   # just for backward compatibility: add deps to all targets
78   # library projects better use advanced find_package(wxWidgets) directly.
79   #if(wxWidgets_LIBRARIES)
80   #  link_libraries(${wxWidgets_LIBRARIES})
81   #  # BUG: str too long:  MSG("wxWidgets_LIBRARIES=${wxWidgets_LIBRARIES}")
82   #  if(LOGFILE)
83   #    file(APPEND ${LOGFILE} "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}):   ${wxWidgets_LIBRARIES}\n")
84   #  endif()
85   #endif()
86
87 else ()
88   message("wxWidgets requested but not found.")
89 endif()