Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / FindwxWindows.cmake
1 # - Find wxWindows (wxWidgets) installation
2 # This module finds if wxWindows/wxWidgets is installed and determines where
3 # the include files and libraries are. It also determines what the name of
4 # the library is.
5 # Please note this file is DEPRECATED and replaced by FindwxWidgets.cmake.
6 # This code sets the following variables:
7 #
8 #  WXWINDOWS_FOUND     = system has WxWindows
9 #  WXWINDOWS_LIBRARIES = path to the wxWindows libraries
10 #                        on Unix/Linux with additional
11 #                        linker flags from
12 #                        "wx-config --libs"
13 #  CMAKE_WXWINDOWS_CXX_FLAGS  = Compiler flags for wxWindows,
14 #                               essentially "`wx-config --cxxflags`"
15 #                               on Linux
16 #  WXWINDOWS_INCLUDE_DIR      = where to find "wx/wx.h" and "wx/setup.h"
17 #  WXWINDOWS_LINK_DIRECTORIES = link directories, useful for rpath on
18 #                                Unix
19 #  WXWINDOWS_DEFINITIONS      = extra defines
20 #
21 # OPTIONS
22 # If you need OpenGL support please
23 #  set(WXWINDOWS_USE_GL 1)
24 # in your CMakeLists.txt *before* you include this file.
25 #
26 #  HAVE_ISYSTEM      - true required to replace -I by -isystem on g++
27 #
28 # For convenience include Use_wxWindows.cmake in your project's
29 # CMakeLists.txt using include(Use_wxWindows).
30 #
31 # USAGE
32 #  set(WXWINDOWS_USE_GL 1)
33 #  find_package(wxWindows)
34 #
35 # NOTES
36 # wxWidgets 2.6.x is supported for monolithic builds
37 # e.g. compiled  in wx/build/msw dir as:
38 #  nmake -f makefile.vc BUILD=debug SHARED=0 USE_OPENGL=1 MONOLITHIC=1
39 #
40 # DEPRECATED
41 #
42 #  CMAKE_WX_CAN_COMPILE
43 #  WXWINDOWS_LIBRARY
44 #  CMAKE_WX_CXX_FLAGS
45 #  WXWINDOWS_INCLUDE_PATH
46 #
47 # AUTHOR
48 # Jan Woetzel <http://www.mip.informatik.uni-kiel.de/~jw> (07/2003-01/2006)
49
50 #=============================================================================
51 # Copyright 2000-2009 Kitware, Inc.
52 # Copyright 2003-2006 Jan Woetzel
53 #
54 # Distributed under the OSI-approved BSD License (the "License");
55 # see accompanying file Copyright.txt for details.
56 #
57 # This software is distributed WITHOUT ANY WARRANTY; without even the
58 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
59 # See the License for more information.
60 #=============================================================================
61 # (To distribute this file outside of CMake, substitute the full
62 #  License text for the above reference.)
63
64 # ------------------------------------------------------------------
65 #
66 # -removed OPTION for CMAKE_WXWINDOWS_USE_GL. Force the developer to SET it before calling this.
67 # -major update for wx 2.6.2 and monolithic build option. (10/2005)
68 #
69 # STATUS
70 # tested with:
71 #  cmake 1.6.7, Linux (Suse 7.3), wxWindows 2.4.0, gcc 2.95
72 #  cmake 1.6.7, Linux (Suse 8.2), wxWindows 2.4.0, gcc 3.3
73 #  cmake 1.6.7, Linux (Suse 8.2), wxWindows 2.4.1-patch1,  gcc 3.3
74 #  cmake 1.6.7, MS Windows XP home, wxWindows 2.4.1, MS Visual Studio .net 7 2002 (static build)
75 #  cmake 2.0.5 on Windows XP and Suse Linux 9.2
76 #  cmake 2.0.6 on Windows XP and Suse Linux 9.2, wxWidgets 2.6.2 MONOLITHIC build
77 #  cmake 2.2.2 on Windows XP, MS Visual Studio .net 2003 7.1 wxWidgets 2.6.2 MONOLITHIC build
78 #
79 # TODO
80 #  -OPTION for unicode builds
81 #  -further testing of DLL linking under MS WIN32
82 #  -better support for non-monolithic builds
83 #
84
85
86 if(WIN32)
87   set(WIN32_STYLE_FIND 1)
88 endif()
89 if(MINGW)
90   set(WIN32_STYLE_FIND 0)
91   set(UNIX_STYLE_FIND 1)
92 endif()
93 if(UNIX)
94   set(UNIX_STYLE_FIND 1)
95 endif()
96
97
98 if(WIN32_STYLE_FIND)
99
100   ## ######################################################################
101   ##
102   ## Windows specific:
103   ##
104   ## candidates for root/base directory of wxwindows
105   ## should have subdirs include and lib containing include/wx/wx.h
106   ## fix the root dir to avoid mixing of headers/libs from different
107   ## versions/builds:
108
109   ## WX supports monolithic and multiple smaller libs (since 2.5.x), we prefer monolithic for now.
110   ## monolithic = WX is built as a single big library
111   ## e.g. compile on WIN32 as  "nmake -f makefile.vc MONOLITHIC=1 BUILD=debug SHARED=0 USE_OPENGL=1" (JW)
112   option(WXWINDOWS_USE_MONOLITHIC "Use monolithic build of WX??" ON)
113   mark_as_advanced(WXWINDOWS_USE_MONOLITHIC)
114
115   ## GL libs used?
116   option(WXWINDOWS_USE_GL "Use Wx with GL support(glcanvas)?" ON)
117   mark_as_advanced(WXWINDOWS_USE_GL)
118
119
120   ## avoid mixing of headers and libs between multiple installed WX versions,
121   ## select just one tree here:
122   find_path(WXWINDOWS_ROOT_DIR  include/wx/wx.h
123     HINTS
124       ENV WXWIN
125       "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWidgets_is1;Inno Setup: App Path]"  ## WX 2.6.x
126       "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWindows_is1;Inno Setup: App Path]"  ## WX 2.4.x
127     PATHS
128       C:/wxWidgets-2.6.2
129       D:/wxWidgets-2.6.2
130       C:/wxWidgets-2.6.1
131       D:/wxWidgets-2.6.1
132       C:/wxWindows-2.4.2
133       D:/wxWindows-2.4.2
134   )
135   # message("DBG found WXWINDOWS_ROOT_DIR: ${WXWINDOWS_ROOT_DIR}")
136
137
138   ## find libs for combination of static/shared with release/debug
139   ## be careful if you add something here,
140   ## avoid mixing of headers and libs of different wx versions,
141   ## there may be multiple WX versions installed.
142   set (WXWINDOWS_POSSIBLE_LIB_PATHS
143     "${WXWINDOWS_ROOT_DIR}/lib"
144     )
145
146   ## monolithic?
147   if (WXWINDOWS_USE_MONOLITHIC)
148
149     find_library(WXWINDOWS_STATIC_LIBRARY
150       NAMES wx wxmsw wxmsw26
151       PATHS
152       "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
153       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
154       DOC "wxWindows static release build library" )
155
156     find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY
157       NAMES wxd wxmswd wxmsw26d
158       PATHS
159       "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
160       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
161       DOC "wxWindows static debug build library" )
162
163     find_library(WXWINDOWS_SHARED_LIBRARY
164       NAMES wxmsw26 wxmsw262 wxmsw24 wxmsw242 wxmsw241 wxmsw240 wx23_2 wx22_9
165       PATHS
166       "${WXWINDOWS_ROOT_DIR}/lib/vc_dll"
167       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
168       DOC "wxWindows shared release build library" )
169
170     find_library(WXWINDOWS_SHARED_DEBUG_LIBRARY
171       NAMES wxmsw26d wxmsw262d wxmsw24d wxmsw241d wxmsw240d wx23_2d wx22_9d
172       PATHS
173       "${WXWINDOWS_ROOT_DIR}/lib/vc_dll"
174       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
175       DOC "wxWindows shared debug build library " )
176
177
178     ##
179     ## required for WXWINDOWS_USE_GL
180     ## gl lib is always build separate:
181     ##
182     find_library(WXWINDOWS_STATIC_LIBRARY_GL
183       NAMES wx_gl wxmsw_gl wxmsw26_gl
184       PATHS
185       "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
186       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
187       DOC "wxWindows static release build GL library" )
188
189     find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_GL
190       NAMES wxd_gl wxmswd_gl wxmsw26d_gl
191       PATHS
192       "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
193       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
194       DOC "wxWindows static debug build GL library" )
195
196
197     find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_PNG
198       NAMES wxpngd
199       PATHS
200       "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
201       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
202       DOC "wxWindows static debug png library" )
203
204     find_library(WXWINDOWS_STATIC_LIBRARY_PNG
205       NAMES wxpng
206       PATHS
207       "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
208       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
209       DOC "wxWindows static png library" )
210
211     find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_TIFF
212       NAMES wxtiffd
213       PATHS
214       "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
215       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
216       DOC "wxWindows static debug tiff library" )
217
218     find_library(WXWINDOWS_STATIC_LIBRARY_TIFF
219       NAMES wxtiff
220       PATHS
221       "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
222       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
223       DOC "wxWindows static tiff library" )
224
225     find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_JPEG
226       NAMES wxjpegd  wxjpgd
227       PATHS
228       "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
229       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
230       DOC "wxWindows static debug jpeg library" )
231
232     find_library(WXWINDOWS_STATIC_LIBRARY_JPEG
233       NAMES wxjpeg wxjpg
234       PATHS
235       "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
236       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
237       DOC "wxWindows static jpeg library" )
238
239     find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_ZLIB
240       NAMES wxzlibd
241       PATHS
242       "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
243       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
244       DOC "wxWindows static debug zlib library" )
245
246     find_library(WXWINDOWS_STATIC_LIBRARY_ZLIB
247       NAMES wxzlib
248       PATHS
249       "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
250       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
251       DOC "wxWindows static zib library" )
252
253     find_library(WXWINDOWS_STATIC_DEBUG_LIBRARY_REGEX
254       NAMES wxregexd
255       PATHS
256       "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
257       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
258       DOC "wxWindows static debug regex library" )
259
260     find_library(WXWINDOWS_STATIC_LIBRARY_REGEX
261       NAMES wxregex
262       PATHS
263       "${WXWINDOWS_ROOT_DIR}/lib/vc_lib"
264       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
265       DOC "wxWindows static regex library" )
266
267
268
269     ## untested:
270     find_library(WXWINDOWS_SHARED_LIBRARY_GL
271       NAMES wx_gl wxmsw_gl wxmsw26_gl
272       PATHS
273       "${WXWINDOWS_ROOT_DIR}/lib/vc_dll"
274       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
275       DOC "wxWindows shared release build GL library" )
276
277     find_library(WXWINDOWS_SHARED_DEBUG_LIBRARY_GL
278       NAMES wxd_gl wxmswd_gl wxmsw26d_gl
279       PATHS
280       "${WXWINDOWS_ROOT_DIR}/lib/vc_dll"
281       ${WXWINDOWS_POSSIBLE_LIB_PATHS}
282       DOC "wxWindows shared debug build GL library" )
283
284
285   else ()
286     ## WX is built as multiple small pieces libraries instead of monolithic
287
288     ## DEPECATED (jw) replaced by more general WXWINDOWS_USE_MONOLITHIC ON/OFF
289     # option(WXWINDOWS_SEPARATE_LIBS_BUILD "Is wxWindows build with separate libs?" OFF)
290
291     ## HACK: This is very dirty.
292     ## because the libs of a particular version are explicitly listed
293     ## and NOT searched/verified.
294     ## TODO:  Really search for each lib, then decide for
295     ## monolithic x debug x shared x GL (=16 combinations) for at least 18 libs
296     ## -->  about 288 combinations
297     ## thus we need a different approach so solve this correctly ...
298
299     message(STATUS "Warning: You are trying to use wxWidgets without monolithic build (WXWINDOWS_SEPARATE_LIBS_BUILD). This is a HACK, libraries are not verified! (JW).")
300
301     set(WXWINDOWS_STATIC_LIBS ${WXWINDOWS_STATIC_LIBS}
302       wxbase26
303       wxbase26_net
304       wxbase26_odbc
305       wxbase26_xml
306       wxmsw26_adv
307       wxmsw26_core
308       wxmsw26_dbgrid
309       wxmsw26_gl
310       wxmsw26_html
311       wxmsw26_media
312       wxmsw26_qa
313       wxmsw26_xrc
314       wxexpat
315       wxjpeg
316       wxpng
317       wxregex
318       wxtiff
319       wxzlib
320       comctl32
321       rpcrt4
322       wsock32
323       )
324     ## HACK: feed in to optimized / debug libaries if both were FOUND.
325     set(WXWINDOWS_STATIC_DEBUG_LIBS ${WXWINDOWS_STATIC_DEBUG_LIBS}
326       wxbase26d
327       wxbase26d_net
328       wxbase26d_odbc
329       wxbase26d_xml
330       wxmsw26d_adv
331       wxmsw26d_core
332       wxmsw26d_dbgrid
333       wxmsw26d_gl
334       wxmsw26d_html
335       wxmsw26d_media
336       wxmsw26d_qa
337       wxmsw26d_xrc
338       wxexpatd
339       wxjpegd
340       wxpngd
341       wxregexd
342       wxtiffd
343       wxzlibd
344       comctl32
345       rpcrt4
346       wsock32
347       )
348   endif ()
349
350
351   ##
352   ## now we should have found all WX libs available on the system.
353   ## let the user decide which of the available onse to use.
354   ##
355
356   ## if there is at least one shared lib available
357   ## let user choose wether to use shared or static wxwindows libs
358   if(WXWINDOWS_SHARED_LIBRARY OR WXWINDOWS_SHARED_DEBUG_LIBRARY)
359     ## default value OFF because wxWindows MSVS default build is static
360     option(WXWINDOWS_USE_SHARED_LIBS
361       "Use shared versions (dll) of wxWindows libraries?" OFF)
362     mark_as_advanced(WXWINDOWS_USE_SHARED_LIBS)
363   endif()
364
365   ## add system libraries wxwindows always seems to depend on
366   set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
367     comctl32
368     rpcrt4
369     wsock32
370     )
371
372   if (NOT WXWINDOWS_USE_SHARED_LIBS)
373     set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
374       ##  these ones dont seem required, in particular  ctl3d32 is not neccesary (Jan Woetzel 07/2003)
375       #   ctl3d32
376       debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_ZLIB}   optimized ${WXWINDOWS_STATIC_LIBRARY_ZLIB}
377       debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_REGEX}  optimized ${WXWINDOWS_STATIC_LIBRARY_REGEX}
378       debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_PNG}    optimized ${WXWINDOWS_STATIC_LIBRARY_PNG}
379       debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_JPEG}   optimized ${WXWINDOWS_STATIC_LIBRARY_JPEG}
380       debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_TIFF}   optimized ${WXWINDOWS_STATIC_LIBRARY_TIFF}
381       )
382   endif ()
383
384   ## opengl/glu: TODO/FIXME: better use FindOpenGL.cmake here
385   ## assume release versions of glu an dopengl, here.
386   if (WXWINDOWS_USE_GL)
387     set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
388       opengl32
389       glu32 )
390   endif ()
391
392   ##
393   ## select between use of  shared or static wxWindows lib then set libs to use
394   ## for debug and optimized build.  so the user can switch between debug and
395   ## release build e.g. within MS Visual Studio without running cmake with a
396   ## different build directory again.
397   ##
398   ## then add the build specific include dir for wx/setup.h
399   ##
400
401   if(WXWINDOWS_USE_SHARED_LIBS)
402     ##message("DBG wxWindows use shared lib selected.")
403     ## assume that both builds use the same setup(.h) for simplicity
404
405     ## shared: both wx (debug and release) found?
406     ## assume that both builds use the same setup(.h) for simplicity
407     if(WXWINDOWS_SHARED_DEBUG_LIBRARY AND WXWINDOWS_SHARED_LIBRARY)
408       ##message("DBG wx shared: debug and optimized found.")
409       find_path(WXWINDOWS_INCLUDE_DIR_SETUPH  wx/setup.h
410         ${WXWINDOWS_ROOT_DIR}/lib/mswdlld
411         ${WXWINDOWS_ROOT_DIR}/lib/mswdll
412         ${WXWINDOWS_ROOT_DIR}/lib/vc_dll/mswd
413         ${WXWINDOWS_ROOT_DIR}/lib/vc_dll/msw )
414       set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
415         debug     ${WXWINDOWS_SHARED_DEBUG_LIBRARY}
416         optimized ${WXWINDOWS_SHARED_LIBRARY} )
417       if (WXWINDOWS_USE_GL)
418         set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
419           debug     ${WXWINDOWS_SHARED_DEBUG_LIBRARY_GL}
420           optimized ${WXWINDOWS_SHARED_LIBRARY_GL} )
421       endif ()
422     endif()
423
424     ## shared: only debug wx lib found?
425     if(WXWINDOWS_SHARED_DEBUG_LIBRARY)
426       if(NOT WXWINDOWS_SHARED_LIBRARY)
427         ##message("DBG wx shared: debug (but no optimized) found.")
428         find_path(WXWINDOWS_INCLUDE_DIR_SETUPH  wx/setup.h
429           ${WXWINDOWS_ROOT_DIR}/lib/mswdlld
430           ${WXWINDOWS_ROOT_DIR}/lib/vc_dll/mswd  )
431         set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
432           ${WXWINDOWS_SHARED_DEBUG_LIBRARY} )
433         if (WXWINDOWS_USE_GL)
434           set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
435             ${WXWINDOWS_SHARED_DEBUG_LIBRARY_GL} )
436         endif ()
437       endif()
438     endif()
439
440     ## shared: only release wx lib found?
441     if(NOT WXWINDOWS_SHARED_DEBUG_LIBRARY)
442       if(WXWINDOWS_SHARED_LIBRARY)
443         ##message("DBG wx shared: optimized (but no debug) found.")
444         find_path(WXWINDOWS_INCLUDE_DIR_SETUPH  wx/setup.h
445           ${WXWINDOWS_ROOT_DIR}/lib/mswdll
446           ${WXWINDOWS_ROOT_DIR}/lib/vc_dll/msw  )
447         set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
448           ${WXWINDOWS_SHARED_DEBUG_LIBRARY} )
449         if (WXWINDOWS_USE_GL)
450           set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
451             ${WXWINDOWS_SHARED_DEBUG_LIBRARY_GL} )
452         endif ()
453       endif()
454     endif()
455
456     ## shared: none found?
457     if(NOT WXWINDOWS_SHARED_DEBUG_LIBRARY)
458       if(NOT WXWINDOWS_SHARED_LIBRARY)
459         message(STATUS
460           "No shared wxWindows lib found, but WXWINDOWS_USE_SHARED_LIBS=${WXWINDOWS_USE_SHARED_LIBS}.")
461       endif()
462     endif()
463
464     #########################################################################################
465   else()
466
467     ##jw: DEPRECATED if(NOT WXWINDOWS_SEPARATE_LIBS_BUILD)
468
469     ## static: both wx (debug and release) found?
470     ## assume that both builds use the same setup(.h) for simplicity
471     if(WXWINDOWS_STATIC_DEBUG_LIBRARY AND WXWINDOWS_STATIC_LIBRARY)
472       ##message("DBG wx static: debug and optimized found.")
473       find_path(WXWINDOWS_INCLUDE_DIR_SETUPH  wx/setup.h
474         ${WXWINDOWS_ROOT_DIR}/lib/mswd
475         ${WXWINDOWS_ROOT_DIR}/lib/msw
476         ${WXWINDOWS_ROOT_DIR}/lib/vc_lib/mswd
477         ${WXWINDOWS_ROOT_DIR}/lib/vc_lib/msw )
478       set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
479         debug     ${WXWINDOWS_STATIC_DEBUG_LIBRARY}
480         optimized ${WXWINDOWS_STATIC_LIBRARY} )
481       if (WXWINDOWS_USE_GL)
482         set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
483           debug     ${WXWINDOWS_STATIC_DEBUG_LIBRARY_GL}
484           optimized ${WXWINDOWS_STATIC_LIBRARY_GL} )
485       endif ()
486     endif()
487
488     ## static: only debug wx lib found?
489     if(WXWINDOWS_STATIC_DEBUG_LIBRARY)
490       if(NOT WXWINDOWS_STATIC_LIBRARY)
491         ##message("DBG wx static: debug (but no optimized) found.")
492         find_path(WXWINDOWS_INCLUDE_DIR_SETUPH  wx/setup.h
493           ${WXWINDOWS_ROOT_DIR}/lib/mswd
494           ${WXWINDOWS_ROOT_DIR}/lib/vc_lib/mswd  )
495         set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
496           ${WXWINDOWS_STATIC_DEBUG_LIBRARY} )
497         if (WXWINDOWS_USE_GL)
498           set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
499             ${WXWINDOWS_STATIC_DEBUG_LIBRARY_GL} )
500         endif ()
501       endif()
502     endif()
503
504     ## static: only release wx lib found?
505     if(NOT WXWINDOWS_STATIC_DEBUG_LIBRARY)
506       if(WXWINDOWS_STATIC_LIBRARY)
507         ##message("DBG wx static: optimized (but no debug) found.")
508         find_path(WXWINDOWS_INCLUDE_DIR_SETUPH  wx/setup.h
509           ${WXWINDOWS_ROOT_DIR}/lib/msw
510           ${WXWINDOWS_ROOT_DIR}/lib/vc_lib/msw )
511         set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
512           ${WXWINDOWS_STATIC_LIBRARY} )
513         if (WXWINDOWS_USE_GL)
514           set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
515             ${WXWINDOWS_STATIC_LIBRARY_GL} )
516         endif ()
517       endif()
518     endif()
519
520     ## static: none found?
521     if(NOT WXWINDOWS_STATIC_DEBUG_LIBRARY AND NOT WXWINDOWS_SEPARATE_LIBS_BUILD)
522       if(NOT WXWINDOWS_STATIC_LIBRARY)
523         message(STATUS
524           "No static wxWindows lib found, but WXWINDOWS_USE_SHARED_LIBS=${WXWINDOWS_USE_SHARED_LIBS}.")
525       endif()
526     endif()
527   endif()
528
529
530   ## not neccessary in wxWindows 2.4.1 and 2.6.2
531   ## but it may fix a previous bug, see
532   ## http://lists.wxwindows.org/cgi-bin/ezmlm-cgi?8:mss:37574:200305:mpdioeneabobmgjenoap
533   option(WXWINDOWS_SET_DEFINITIONS "Set additional defines for wxWindows" OFF)
534   mark_as_advanced(WXWINDOWS_SET_DEFINITIONS)
535   if (WXWINDOWS_SET_DEFINITIONS)
536     set(WXWINDOWS_DEFINITIONS "-DWINVER=0x400")
537   else ()
538     # clear:
539     set(WXWINDOWS_DEFINITIONS "")
540   endif ()
541
542
543
544   ## Find the include directories for wxwindows
545   ## the first, build specific for wx/setup.h was determined before.
546   ## add inc dir for general for "wx/wx.h"
547   find_path(WXWINDOWS_INCLUDE_DIR  wx/wx.h
548     "${WXWINDOWS_ROOT_DIR}/include" )
549   ## append the build specific include dir for wx/setup.h:
550   if (WXWINDOWS_INCLUDE_DIR_SETUPH)
551     set(WXWINDOWS_INCLUDE_DIR ${WXWINDOWS_INCLUDE_DIR} ${WXWINDOWS_INCLUDE_DIR_SETUPH} )
552   endif ()
553
554
555
556   mark_as_advanced(
557     WXWINDOWS_ROOT_DIR
558     WXWINDOWS_INCLUDE_DIR
559     WXWINDOWS_INCLUDE_DIR_SETUPH
560     WXWINDOWS_STATIC_LIBRARY
561     WXWINDOWS_STATIC_LIBRARY_GL
562     WXWINDOWS_STATIC_DEBUG_LIBRARY
563     WXWINDOWS_STATIC_DEBUG_LIBRARY_GL
564     WXWINDOWS_STATIC_LIBRARY_ZLIB
565     WXWINDOWS_STATIC_DEBUG_LIBRARY_ZLIB
566     WXWINDOWS_STATIC_LIBRARY_REGEX
567     WXWINDOWS_STATIC_DEBUG_LIBRARY_REGEX
568     WXWINDOWS_STATIC_LIBRARY_PNG
569     WXWINDOWS_STATIC_DEBUG_LIBRARY_PNG
570     WXWINDOWS_STATIC_LIBRARY_JPEG
571     WXWINDOWS_STATIC_DEBUG_LIBRARY_JPEG
572     WXWINDOWS_STATIC_DEBUG_LIBRARY_TIFF
573     WXWINDOWS_STATIC_LIBRARY_TIFF
574     WXWINDOWS_SHARED_LIBRARY
575     WXWINDOWS_SHARED_DEBUG_LIBRARY
576     WXWINDOWS_SHARED_LIBRARY_GL
577     WXWINDOWS_SHARED_DEBUG_LIBRARY_GL
578     )
579
580
581 else()
582
583   if (UNIX_STYLE_FIND)
584     ## ######################################################################
585     ##
586     ## UNIX/Linux specific:
587     ##
588     ## use backquoted wx-config to query and set flags and libs:
589     ## 06/2003 Jan Woetzel
590     ##
591
592     option(WXWINDOWS_USE_SHARED_LIBS "Use shared versions (.so) of wxWindows libraries" ON)
593     mark_as_advanced(WXWINDOWS_USE_SHARED_LIBS)
594
595     # JW removed option and force the develper th SET it.
596     # option(WXWINDOWS_USE_GL "use wxWindows with GL support (use additional
597     # --gl-libs for wx-config)?" OFF)
598
599     # wx-config should be in your path anyhow, usually no need to set WXWIN or
600     # search in ../wx or ../../wx
601     find_program(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE wx-config
602       HINTS
603         ENV WXWIN
604         $ENV{WXWIN}/bin
605       PATHS
606       ../wx/bin
607       ../../wx/bin )
608
609     # check wether wx-config was found:
610     if(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE)
611
612       # use shared/static wx lib?
613       # remember: always link shared to use systems GL etc. libs (no static
614       # linking, just link *against* static .a libs)
615       if(WXWINDOWS_USE_SHARED_LIBS)
616         set(WX_CONFIG_ARGS_LIBS "--libs")
617       else()
618         set(WX_CONFIG_ARGS_LIBS "--static --libs")
619       endif()
620
621       # do we need additionial wx GL stuff like GLCanvas ?
622       if(WXWINDOWS_USE_GL)
623         set(WX_CONFIG_ARGS_LIBS "${WX_CONFIG_ARGS_LIBS} --gl-libs" )
624       endif()
625       ##message("DBG: WX_CONFIG_ARGS_LIBS=${WX_CONFIG_ARGS_LIBS}===")
626
627       # set CXXFLAGS to be fed into CMAKE_CXX_FLAGS by the user:
628       if (HAVE_ISYSTEM) # does the compiler support -isystem ?
629               if (NOT APPLE) # -isystem seem sto be unsuppored on Mac
630                 if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX )
631             if (CMAKE_CXX_COMPILER MATCHES g\\+\\+)
632               set(CMAKE_WXWINDOWS_CXX_FLAGS "`${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE} --cxxflags|sed -e s/-I/-isystem/g`")
633             else()
634               set(CMAKE_WXWINDOWS_CXX_FLAGS "`${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE} --cxxflags`")
635             endif()
636                 endif()
637               endif ()
638       endif ()
639       ##message("DBG: for compilation:
640       ##CMAKE_WXWINDOWS_CXX_FLAGS=${CMAKE_WXWINDOWS_CXX_FLAGS}===")
641
642       # keep the back-quoted string for clarity
643       set(WXWINDOWS_LIBRARIES "`${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE} ${WX_CONFIG_ARGS_LIBS}`")
644       ##message("DBG2: for linking:
645       ##WXWINDOWS_LIBRARIES=${WXWINDOWS_LIBRARIES}===")
646
647       # evaluate wx-config output to separate linker flags and linkdirs for
648       # rpath:
649       exec_program(${CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE}
650         ARGS ${WX_CONFIG_ARGS_LIBS}
651         OUTPUT_VARIABLE WX_CONFIG_LIBS )
652
653       ## extract linkdirs (-L) for rpath
654       ## use regular expression to match wildcard equivalent "-L*<endchar>"
655       ## with <endchar> is a space or a semicolon
656       string(REGEX MATCHALL "[-][L]([^ ;])+" WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX "${WX_CONFIG_LIBS}" )
657       # message("DBG  WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX=${WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX}")
658
659       ## remove prefix -L because we need the pure directory for LINK_DIRECTORIES
660       ## replace -L by ; because the separator seems to be lost otherwise (bug or
661       ## feature?)
662       if(WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX)
663         string(REGEX REPLACE "[-][L]" ";" WXWINDOWS_LINK_DIRECTORIES ${WXWINDOWS_LINK_DIRECTORIES_WITH_PREFIX} )
664         # message("DBG  WXWINDOWS_LINK_DIRECTORIES=${WXWINDOWS_LINK_DIRECTORIES}")
665       endif()
666
667
668       ## replace space separated string by semicolon separated vector to make it
669       ## work with LINK_DIRECTORIES
670       separate_arguments(WXWINDOWS_LINK_DIRECTORIES)
671
672       mark_as_advanced(
673         CMAKE_WXWINDOWS_CXX_FLAGS
674         WXWINDOWS_INCLUDE_DIR
675         WXWINDOWS_LIBRARIES
676         CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE
677         )
678
679
680       ## we really need wx-config...
681     else()
682       message(STATUS "Cannot find wx-config anywhere on the system. Please put the file into your path or specify it in CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE.")
683       mark_as_advanced(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE)
684     endif()
685
686
687
688   else()
689     message(STATUS "FindwxWindows.cmake:  Platform unknown/unsupported by FindwxWindows.cmake. It's neither WIN32 nor UNIX")
690   endif()
691 endif()
692
693
694 if(WXWINDOWS_LIBRARIES)
695   if(WXWINDOWS_INCLUDE_DIR OR CMAKE_WXWINDOWS_CXX_FLAGS)
696     ## found all we need.
697     set(WXWINDOWS_FOUND 1)
698
699     ## set deprecated variables for backward compatibility:
700     set(CMAKE_WX_CAN_COMPILE   ${WXWINDOWS_FOUND})
701     set(WXWINDOWS_LIBRARY     ${WXWINDOWS_LIBRARIES})
702     set(WXWINDOWS_INCLUDE_PATH ${WXWINDOWS_INCLUDE_DIR})
703     set(WXWINDOWS_LINK_DIRECTORIES ${WXWINDOWS_LINK_DIRECTORIES})
704     set(CMAKE_WX_CXX_FLAGS     ${CMAKE_WXWINDOWS_CXX_FLAGS})
705
706   endif()
707 endif()