summaryrefslogtreecommitdiffstats
path: root/Modules/FindQt4.cmake
blob: 7fde561c3c3eb63dd7c464ac70ea4739f293a0c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
########################################################################
#
#       DO NOT CALL THIS DIRECTLY 
#       LET FindQt.cmake deside which FindQtX.cmake to include
#
#       Locates Qt4 include paths and libraries (called by FindQt.cmake)
#
########################################################################

# This module defines
# QT_INCLUDES                   ,list of paths to all include directories of Qt4
#
# macro QT4_WRAP_CPP(outfiles inputfile ... )
# macro QT4_WRAP_UI(outfiles inputfile ... )
# macro QT4_ADD_RESOURCE(outfiles inputfile ... )
#
# QT_INCLUDE_DIR                ,path to "include" of Qt4
# QT_QT_INCLUDE_DIR             ,path to "include/Qt" of Qt4
# QT_QT3SUPPORT_INCLUDE_DIR     ,path to "include/Qt3Support" of Qt
# QT_QTASSISTANT_INCLUDE_DIR    ,path to "include/QtAssistant" of Qt4
# QT_QTCORE_INCLUDE_DIR         ,path to "include/QtCore" of Qt4        
# QT_QTDESIGNER_INCLUDE_DIR     ,path to "include/QtDesigner" of Qt4
# QT_QTGUI_INCLUDE_DIR          ,path to "include/QtGui" of Qt4
# QT_QTMOTIF_INCLUDE_DIR        ,path to "include/QtMotif" of Qt4
# QT_QTNETWORK_INCLUDE_DIR      ,path to "include/QtNetwork" of Qt4
# QT_QTNSPLUGIN_INCLUDE_DIR     ,path to "include/QtNsPlugin" of Qt4
# QT_QTOPENGL_INCLUDE_DIR       ,path to "include/QtOpenGL" of Qt4
# QT_QTSQL_INCLUDE_DIR          ,path to "include/QtSql" of Qt4
# QT_QTXML_INCLUDE_DIR          ,path to "include/QtXml" of Qt4
#
# QT_LIBRARIES                  ,list of path+filename of all optimized libs of Qt4
# QT_LIBRARIES_DEBUG            ,list of path+filename of all debug libs of Qt4
# QT_LIBRARIES_TRYOPTIMIZED     ,list of path+filename of all libs (try optimized, if not found try debug)
# QT_LIBRARIES_TRYDEBUG         ,list of path+filename of all libs (try debug, if not found try optimized)
# QT_LIBRARY_DIR                ,path to "lib" of Qt4
#
# QT_QT3SUPPORT_LIBRARY         ,path+filename for Qt3Support library of Qt4
# QT_QTASSISTANT_LIBRARY        ,path+filename for QtAssistant library of Qt4
# QT_QTCORE_LIBRARY             ,path+filename for QtCore library of Qt4        
# QT_QTDESIGNER_LIBRARY         ,path+filename for QtDesigner library of Qt4
# QT_QTGUI_LIBRARY              ,path+filename for QtGui library of Qt4
# QT_QTMOTIF_LIBRARY            ,path+filename for QtMotif library of Qt4
# QT_QTNETWORK_LIBRARY          ,path+filename for QtNetwork library of Qt4
# QT_QTNSPLUGIN_LIBRARY         ,path+filename for QtNsPlugin library of Qt4
# QT_QTOPENGL_LIBRARY           ,path+filename for QtOpenGL library of Qt4
# QT_QTSQL_LIBRARY              ,path+filename for QtSql library of Qt4
# QT_QTXML_LIBRARY              ,path+filename for QtXml library of Qt4
#
# QT_QT3SUPPORT_LIBRARY_DEBUG   ,path+filename for Qt3Support_debug library of Qt
# QT_QTASSISTANT_LIBRARY_DEBUG  ,path+filename for QtAssistant_debug library of Qt4
# QT_QTCORE_LIBRARY_DEBUG       ,path+filename for QtCore_debug library of Qt4  
# QT_QTDESIGNER_LIBRARY_DEBUG   ,path+filename for QtDesigner_debug library of Qt4
# QT_QTGUI_LIBRARY_DEBUG        ,path+filename for QtGui_debug library of Qt4
# QT_QTMOTIF_LIBRARY_DEBUG      ,path+filename for QtMotif_debug library of Qt4
# QT_QTNETWORK_LIBRARY_DEBUG    ,path+filename for QtNetwork_debug library of Qt4
# QT_QTNSPLUGIN_LIBRARY_DEBUG   ,path+filename for QtNsPlugin_debug library of Qt4
# QT_QTOPENGL_LIBRARY_DEBUG     ,path+filename for QtOpenGL_debug library of Qt4
# QT_QTSQL_LIBRARY_DEBUG        ,path+filename for QtSql_debug library of Qt4
# QT_QTXML_LIBRARY_DEBUG        ,path+filename for QtXml_debug library of Qt4
#
# QT_DEFINITIONS                ,definitions to use when compiling code that uses Qt.
# QT_FOUND                      ,If false, don't try to use Qt (depends on existence of QT_LIBRARY_DIR and QT_INCLUDE_DIR)
#
# also defined, but not for general use are
# QT_MOC_EXECUTABLE             ,where to find the moc tool.
# QT_UIC_EXECUTABLE             ,where to find the uic tool.
# QT_RCC_EXECUTABLE             ,where to find the rcc tool
#
# These are around for backwards compatibility 
# they will be set
# QT_WRAP_CPP                   ,set true if QT_MOC_EXECUTABLE is found
# QT_WRAP_UI                    ,set true if QT_UIC_EXECUTABLE is found
#
#
# These variables do _NOT_ have any effect anymore (compared to FindQt.cmake)
# QT_MT_REQUIRED                , Qt4 is now always multithreaded
#
# These variables are set to "" , because Qt structure changed (They make no sence in Qt4)
# QT_QT_LIBRARY                 , Qt-Library is now splitt into different parts
# QT_QTMAIN_LIBRARY             , Qt-Library is now splitt into different parts


# check for qmake
IF(NOT QT_QMAKE_EXECUTABLE)
  FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake PATHS $ENV{QTDIR}/bin)
ENDIF(NOT QT_QMAKE_EXECUTABLE)

########################################
#
#       Setting the INCLUDE-Variables
#
########################################
# Set QT_QT_INCLUDE_DIR by searching for qglobal.h
IF(NOT QT_QT_INCLUDE_DIR)
  IF(QT_QMAKE_EXECUTABLE)
    EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
      ARGS "-query QT_INSTALL_HEADERS" 
      OUTPUT_VARIABLE qt_headers )
  ENDIF(QT_QMAKE_EXECUTABLE)
  FIND_PATH( QT_QT_INCLUDE_DIR qglobal.h
    ${qt_headers}/Qt
    $ENV{QTDIR}/include/Qt
    /usr/local/qt/include/Qt
    /usr/local/include/Qt
    /usr/lib/qt/include/Qt
    /usr/include/Qt
    /usr/share/qt4/include/Qt
    C:/Progra~1/qt/include/Qt
    /usr/include/qt4/Qt)
ENDIF(NOT QT_QT_INCLUDE_DIR)

# Set QT_INCLUDE_DIR by removine "/Qt" in the string ${QT_QT_INCLUDE_DIR}
IF(NOT QT_INCLUDE_DIR)
  IF( QT_QT_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
    STRING( REGEX REPLACE "/Qt$" "" qt4_include_dir ${QT_QT_INCLUDE_DIR})
    SET( QT_INCLUDE_DIR ${qt4_include_dir} CACHE PATH "")
  ELSE( QT_QT_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
    IF( NOT Qt_FIND_QUIETLY AND Qt_FIND_REQUIRED) 
      MESSAGE( SEND_ERROR "Could not find qglobal.h")
    ENDIF( NOT Qt_FIND_QUIETLY AND Qt_FIND_REQUIRED)
  ENDIF( QT_QT_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
ENDIF(NOT QT_INCLUDE_DIR)

# Set QT_QT3SUPPORT_INCLUDE_DIR
IF(NOT QT_QT3SUPPORT_INCLUDE_DIR)
  FIND_PATH( QT_QT3SUPPORT_INCLUDE_DIR Qt3Support ${QT_INCLUDE_DIR}/Qt3Support)
  IF( NOT QT_QT3SUPPORT_INCLUDE_DIR )
    IF( NOT Qt_FIND_QUIETLY) 
      MESSAGE( STATUS "Could not find ${QT_INCLUDE_DIR}/Qt3Support")
    ENDIF( NOT Qt_FIND_QUIETLY)
  ENDIF( NOT QT_QT3SUPPORT_INCLUDE_DIR )
ENDIF(NOT QT_QT3SUPPORT_INCLUDE_DIR)

# Set QT_QTASSISTANT_INCLUDE_DIR
IF(NOT QT_QTASSISTANT_INCLUDE_DIR)
  FIND_PATH( QT_QTASSISTANT_INCLUDE_DIR QtAssistant ${QT_INCLUDE_DIR}/QtAssistant)
  IF( NOT QT_QTASSISTANT_INCLUDE_DIR )
    IF( NOT Qt_FIND_QUIETLY) 
      MESSAGE( STATUS "Could not find ${QT_INCLUDE_DIR}/QtAssistant")
    ENDIF( NOT Qt_FIND_QUIETLY) 
  ENDIF( NOT QT_QTASSISTANT_INCLUDE_DIR )
ENDIF(NOT QT_QTASSISTANT_INCLUDE_DIR)

# Set QT_QTCORE_INCLUDE_DIR
IF(NOT QT_QTCORE_INCLUDE_DIR)
  FIND_PATH( QT_QTCORE_INCLUDE_DIR QtCore ${QT_INCLUDE_DIR}/QtCore)
  IF( NOT QT_QTCORE_INCLUDE_DIR )
    IF( NOT Qt_FIND_QUIETLY) 
      MESSAGE( STATUS "Could not find ${QT_INCLUDE_DIR}/QtCore")
    ENDIF( NOT Qt_FIND_QUIETLY) 
  ENDIF( NOT QT_QTCORE_INCLUDE_DIR )
ENDIF(NOT QT_QTCORE_INCLUDE_DIR)

# Set QT_QTDESIGNER_INCLUDE_DIR
IF(NOT QT_QTDESIGNER_INCLUDE_DIR)
  FIND_PATH( QT_QTDESIGNER_INCLUDE_DIR QDesignerComponents ${QT_INCLUDE_DIR}/QtDesigner)
  IF( NOT QT_QTDESIGNER_INCLUDE_DIR )
    IF( NOT Qt_FIND_QUIETLY) 
      MESSAGE( STATUS "Could not find ${QT_INCLUDE_DIR}/QtDesigner")
    ENDIF( NOT Qt_FIND_QUIETLY) 
  ENDIF( NOT QT_QTDESIGNER_INCLUDE_DIR )
ENDIF(NOT QT_QTDESIGNER_INCLUDE_DIR)

# Set QT_QTGUI_INCLUDE_DIR
IF(NOT QT_QTGUI_INCLUDE_DIR)
  FIND_PATH( QT_QTGUI_INCLUDE_DIR QtGui ${QT_INCLUDE_DIR}/QtGui)
  IF( NOT QT_QTGUI_INCLUDE_DIR )
    IF( NOT Qt_FIND_QUIETLY) 
      MESSAGE( STATUS "Could not find ${QT_INCLUDE_DIR}/QtGui")
    ENDIF( NOT Qt_FIND_QUIETLY) 
  ENDIF( NOT QT_QTGUI_INCLUDE_DIR )
ENDIF(NOT QT_QTGUI_INCLUDE_DIR)

# Set QT_QTMOTIF_INCLUDE_DIR
IF(NOT QT_QTMOTIF_INCLUDE_DIR)
  FIND_PATH( QT_QTMOTIF_INCLUDE_DIR QtMotif ${QT_INCLUDE_DIR}/QtMotif)
  IF( NOT QT_QTMOTIF_INCLUDE_DIR )
    IF( NOT Qt_FIND_QUIETLY) 
      MESSAGE( STATUS "Could not find ${QT_INCLUDE_DIR}/QtMotif")
    ENDIF( NOT Qt_FIND_QUIETLY) 
  ENDIF( NOT QT_QTMOTIF_INCLUDE_DIR )
ENDIF(NOT QT_QTMOTIF_INCLUDE_DIR)

# Set QT_QTNETWORK_INCLUDE_DIR
IF(NOT QT_QTNETWORK_INCLUDE_DIR)
  FIND_PATH( QT_QTNETWORK_INCLUDE_DIR QtNetwork ${QT_INCLUDE_DIR}/QtNetwork)
  IF( NOT QT_QTNETWORK_INCLUDE_DIR )
    IF( NOT Qt_FIND_QUIETLY) 
      MESSAGE( STATUS "Could not find ${QT_INCLUDE_DIR}/QtNetwork")
    ENDIF( NOT Qt_FIND_QUIETLY) 
  ENDIF( NOT QT_QTNETWORK_INCLUDE_DIR )
ENDIF(NOT QT_QTNETWORK_INCLUDE_DIR)

# Set QT_QTNSPLUGIN_INCLUDE_DIR
IF(NOT QT_QTNSPLUGIN_INCLUDE_DIR)
  FIND_PATH( QT_QTNSPLUGIN_INCLUDE_DIR QtNsPlugin ${QT_INCLUDE_DIR}/QtNsPlugin)
  IF( NOT QT_QTNSPLUGIN_INCLUDE_DIR )
    IF( NOT Qt_FIND_QUIETLY)
      MESSAGE( STATUS "Could not find ${QT_INCLUDE_DIR}/QtNsPlugin")
    ENDIF( NOT Qt_FIND_QUIETLY) 
  ENDIF( NOT QT_QTNSPLUGIN_INCLUDE_DIR )
ENDIF(NOT QT_QTNSPLUGIN_INCLUDE_DIR)

# Set QT_QTOPENGL_INCLUDE_DIR
IF(NOT QT_QTOPENGL_INCLUDE_DIR)
  FIND_PATH( QT_QTOPENGL_INCLUDE_DIR QtOpenGL ${QT_INCLUDE_DIR}/QtOpenGL)
  IF( NOT QT_QTOPENGL_INCLUDE_DIR )
    IF( NOT Qt_FIND_QUIETLY)
      MESSAGE( STATUS "Could not find ${QT_INCLUDE_DIR}/QtOpenGL")
    ENDIF( NOT Qt_FIND_QUIETLY) 
  ENDIF( NOT QT_QTOPENGL_INCLUDE_DIR )
ENDIF(NOT QT_QTOPENGL_INCLUDE_DIR)

# Set QT_QTSQL_INCLUDE_DIR
IF(NOT QT_QTSQL_INCLUDE_DIR)
  FIND_PATH( QT_QTSQL_INCLUDE_DIR QtSql ${QT_INCLUDE_DIR}/QtSql)
  IF( NOT QT_QTSQL_INCLUDE_DIR )
    IF( NOT Qt_FIND_QUIETLY)
      MESSAGE( STATUS "Could not find ${QT_INCLUDE_DIR}/QtSql")
    ENDIF( NOT Qt_FIND_QUIETLY)
  ENDIF( NOT QT_QTSQL_INCLUDE_DIR )
ENDIF(NOT QT_QTSQL_INCLUDE_DIR)


# Set QT_QTXML_INCLUDE_DIR
IF(NOT QT_QTXML_INCLUDE_DIR)
  FIND_PATH( QT_QTXML_INCLUDE_DIR QtXml ${QT_INCLUDE_DIR}/QtXml)
  IF( NOT QT_QTXML_INCLUDE_DIR )
    IF( NOT Qt_FIND_QUIETLY)
      MESSAGE( STATUS "Could not find ${QT_INCLUDE_DIR}/QtXml")
    ENDIF( NOT Qt_FIND_QUIETLY)
  ENDIF( NOT QT_QTXML_INCLUDE_DIR )
ENDIF(NOT QT_QTXML_INCLUDE_DIR)

# Make variables changeble to the advanced user
MARK_AS_ADVANCED(
  QT_LIBRARY_DIR
  QT_INCLUDE_DIR 
  QT_QT_INCLUDE_DIR 
  QT_QT3SUPPORT_INCLUDE_DIR 
  QT_QTASSISTANT_INCLUDE_DIR 
  QT_QTCORE_INCLUDE_DIR 
  QT_QTDESIGNER_INCLUDE_DIR 
  QT_QTGUI_INCLUDE_DIR 
  QT_QTMOTIF_INCLUDE_DIR 
  QT_QTNETWORK_INCLUDE_DIR 
  QT_QTNSPLUGIN_INCLUDE_DIR 
  QT_QTOPENGL_INCLUDE_DIR 
  QT_QTSQL_INCLUDE_DIR 
  QT_QTXML_INCLUDE_DIR
  )

# Set QT_INCLUDES
SET( QT_INCLUDES
  ${QT_INCLUDE_DIR} 
  ${QT_QT_INCLUDE_DIR} 
  ${QT_QT3SUPPORT_INCLUDE_DIR} 
  ${QT_QTASSISTANT_INCLUDE_DIR} 
  ${QT_QTCORE_INCLUDE_DIR} 
  ${QT_QTDESIGNER_INCLUDE_DIR} 
  ${QT_QTGUI_INCLUDE_DIR} 
  ${QT_QTMOTIF_INCLUDE_DIR} 
  ${QT_QTNETWORK_INCLUDE_DIR} 
  ${QT_QTNSPLUGIN_INCLUDE_DIR} 
  ${QT_QTOPENGL_INCLUDE_DIR} 
  ${QT_QTSQL_INCLUDE_DIR} 
  ${QT_QTXML_INCLUDE_DIR} )


########################################
#
#       Setting the LIBRARY-Variables
#
########################################
IF(NOT QT_QTCORE_LIBRARY) 
  IF(QT_QMAKE_EXECUTABLE)
    EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
      ARGS "-query QT_INSTALL_LIBS" 
      OUTPUT_VARIABLE qt_libs )
  ENDIF(QT_QMAKE_EXECUTABLE)
  # Set QT_QTCORE_LIBRARY  by searching for a lib with "QtCore." as part of the filename
  FIND_LIBRARY(  QT_QTCORE_LIBRARY
    NAMES QtCore QtCore4
    PATHS 
    ${qt_libs}
    $ENV{QTDIR}/lib
    /usr/local/qt/lib
    /usr/local/lib
    /usr/lib/qt/lib
    /usr/lib
    /usr/share/qt4/lib
    C:/Progra~1/qt/lib
    /usr/lib/qt4 )
ENDIF(NOT QT_QTCORE_LIBRARY)

# Set QT_QTCORE_LIBRARY_DEBUG by searching for a lib with "QtCore_debug" as part of the filename
IF(NOT QT_QTCORE_LIBRARY_DEBUG)
  IF(QT_QMAKE_EXECUTABLE)
    EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
      ARGS "-query QT_INSTALL_LIBS" 
      OUTPUT_VARIABLE qt_libs )
  ENDIF(QT_QMAKE_EXECUTABLE)
  FIND_LIBRARY(  QT_QTCORE_LIBRARY_DEBUG
    NAMES QtCore_debug QtCored4
    PATHS 
    ${qt_libs}
    $ENV{QTDIR}/lib
    /usr/local/qt/lib
    /usr/local/lib
    /usr/lib/qt/lib
    /usr/lib
    /usr/share/qt4/lib
    C:/Progra~1/qt/lib
    /usr/lib/qt4 )
ENDIF(NOT QT_QTCORE_LIBRARY_DEBUG)

# Set QT_LIBRARY_DIR
IF(NOT QT_LIBRARY_DIR)
  EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
        ARGS "-query QT_INSTALL_LIBS"
        OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP )
  SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir")
ENDIF(NOT QT_LIBRARY_DIR)

# Set QT_QT3SUPPORT_LIBRARY
IF(NOT QT_QT3SUPPORT_LIBRARY)
  FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY  NAMES Qt3Support Qt3Support4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QT3SUPPORT_LIBRARY)
IF(NOT QT_QT3SUPPORT_LIBRARY_DEBUG)
  FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG NAMES Qt3Support_debug Qt3Supportd4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QT3SUPPORT_LIBRARY_DEBUG)

# Set QT_QTASSISTANT_LIBRARY
IF(NOT QT_QTASSISTANT_LIBRARY)
  FIND_LIBRARY(QT_QTASSISTANT_LIBRARY  NAMES QtAssistant QtAssistant4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTASSISTANT_LIBRARY)
IF(NOT QT_QTASSISTANT_LIBRARY_DEBUG)
  FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistant_debug QtAssistantd4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTASSISTANT_LIBRARY_DEBUG)

# Set QT_QTDESIGNER_LIBRARY
IF(NOT QT_QTDESIGNER_LIBRARY)
  FIND_LIBRARY(QT_QTDESIGNER_LIBRARY NAMES QtDesigner QtDesigner4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTDESIGNER_LIBRARY)
IF(NOT QT_QTDESIGNER_LIBRARY_DEBUG)
  FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_DEBUG NAMES QtDesigner_debug QtDesignerd4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTDESIGNER_LIBRARY_DEBUG)

# Set QT_QTGUI_LIBRARY
IF(NOT QT_QTGUI_LIBRARY)
  FIND_LIBRARY(QT_QTGUI_LIBRARY NAMES QtGui QtGui4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTGUI_LIBRARY)
IF(NOT QT_QTGUI_LIBRARY_DEBUG)
  FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG NAMES QtGui_debug QtGuid4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTGUI_LIBRARY_DEBUG)

# Set QT_QTMOTIF_LIBRARY
IF(NOT QT_QTMOTIF_LIBRARY)
  FIND_LIBRARY(QT_QTMOTIF_LIBRARY NAMES QtMotif PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTMOTIF_LIBRARY)
IF(NOT QT_QTMOTIF_LIBRARY_DEBUG)
  FIND_LIBRARY(QT_QTMOTIF_LIBRARY_DEBUG NAMES QtMotif_debug PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTMOTIF_LIBRARY_DEBUG)

# Set QT_QTNETWORK_LIBRARY
IF(NOT QT_QTNETWORK_LIBRARY)
  FIND_LIBRARY(QT_QTNETWORK_LIBRARY NAMES QtNetwork QtNetwork4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTNETWORK_LIBRARY)
IF(NOT QT_QTNETWORK_LIBRARY_DEBUG)
  FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG NAMES QtNetwork_debug QtNetworkd4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTNETWORK_LIBRARY_DEBUG)

# Set QT_QTNSPLUGIN_LIBRARY
IF(NOT QT_QTNSPLUGIN_LIBRARY)
  FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY NAMES QtNsPlugin PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTNSPLUGIN_LIBRARY)
IF(NOT QT_QTNSPLUGIN_LIBRARY_DEBUG)
  FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_DEBUG NAMES QtNsPlugin_debug PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTNSPLUGIN_LIBRARY_DEBUG)

# Set QT_QTOPENGL_LIBRARY
IF(NOT QT_QTOPENGL_LIBRARY)
  FIND_LIBRARY(QT_QTOPENGL_LIBRARY NAMES QtOpenGL QtOpenGL4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTOPENGL_LIBRARY)
IF(NOT QT_QTOPENGL_LIBRARY_DEBUG)
  FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG NAMES QtOpenGL_debug QtOpenGLd4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTOPENGL_LIBRARY_DEBUG)

# Set QT_QTSQL_LIBRARY
IF(NOT QT_QTSQL_LIBRARY)
  FIND_LIBRARY(QT_QTSQL_LIBRARY NAMES QtSql QtSql4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTSQL_LIBRARY)
IF(NOT QT_QTSQL_LIBRARY_DEBUG)
  FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG NAMES QtSql_debug QtSqld4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTSQL_LIBRARY_DEBUG)

# Set QT_QTXML_LIBRARY
IF(NOT QT_QTXML_LIBRARY)
  FIND_LIBRARY(QT_QTXML_LIBRARY NAMES QtXml QtXml4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTXML_LIBRARY)
IF(NOT QT_QTXML_LIBRARY_DEBUG)
  FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG NAMES QtXml_debug QtXmld4 PATHS ${QT_LIBRARY_DIR})
ENDIF(NOT QT_QTXML_LIBRARY_DEBUG)

# Make variables changeble to the advanced user
MARK_AS_ADVANCED(
  QT_QT3SUPPORT_LIBRARY 
  QT_QTASSISTANT_LIBRARY 
  QT_QTCORE_LIBRARY 
  QT_QTDESIGNER_LIBRARY 
  QT_QTGUI_LIBRARY 
  QT_QTMOTIF_LIBRARY 
  QT_QTNETWORK_LIBRARY 
  QT_QTNSPLUGIN_LIBRARY 
  QT_QTOPENGL_LIBRARY 
  QT_QTSQL_LIBRARY 
  QT_QTXML_LIBRARY )

# Set QT_LIBRARIES
SET( QT_LIBRARIES
  ${QT_QT3SUPPORT_LIBRARY} 
  ${QT_QTASSISTANT_LIBRARY} 
  ${QT_QTCORE_LIBRARY} 
  ${QT_QTDESIGNER_LIBRARY} 
  ${QT_QTGUI_LIBRARY} 
  ${QT_QTMOTIF_LIBRARY} 
  ${QT_QTNETWORK_LIBRARY} 
  ${QT_QTNSPLUGIN_LIBRARY} 
  ${QT_QTOPENGL_LIBRARY} 
  ${QT_QTSQL_LIBRARY} 
  ${QT_QTXML_LIBRARY} )

# Make variables changeble to the advanced user
MARK_AS_ADVANCED(
  QT_QT3SUPPORT_LIBRARY_DEBUG 
  QT_QTASSISTANT_LIBRARY_DEBUG 
  QT_QTCORE_LIBRARY_DEBUG 
  QT_QTDESIGNER_LIBRARY_DEBUG 
  QT_QTGUI_LIBRARY_DEBUG 
  QT_QTMOTIF_LIBRARY_DEBUG 
  QT_QTNETWORK_LIBRARY_DEBUG 
  QT_QTNSPLUGIN_LIBRARY_DEBUG 
  QT_QTOPENGL_LIBRARY_DEBUG 
  QT_QTSQL_LIBRARY_DEBUG 
  QT_QTXML_LIBRARY_DEBUG )

# Set QT_LIBRARIES_DEBUG
SET( QT_LIBRARIES_DEBUG
  ${QT_QT3SUPPORT_LIBRARY_DEBUG} 
  ${QT_QTASSISTANT_LIBRARY_DEBUG} 
  ${QT_QTCORE_LIBRARY_DEBUG} 
  ${QT_QTDESIGNER_LIBRARY_DEBUG} 
  ${QT_QTGUI_LIBRARY_DEBUG} 
  ${QT_QTMOTIF_LIBRARY_DEBUG} 
  ${QT_QTNETWORK_LIBRARY_DEBUG} 
  ${QT_QTNSPLUGIN_LIBRARY_DEBUG} 
  ${QT_QTOPENGL_LIBRARY_DEBUG} 
  ${QT_QTSQL_LIBRARY_DEBUG} 
  ${QT_QTXML_LIBRARY_DEBUG} )

# Set QT_LIBRARIES_TRYOPTIMIZED
IF(NOT QT_LIBRARIES_TRYOPTIMIZED)
  IF(QT_QT3SUPPORT_LIBRARY)
    SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QT3SUPPORT_LIBRARY} )
  ELSE(QT_QT3SUPPORT_LIBRARY)
    IF(QT_QT3SUPPORT_LIBRARY_DEBUG)
      SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QT3SUPPORT_LIBRARY_DEBUG} )      
    ENDIF(QT_QT3SUPPORT_LIBRARY_DEBUG)
  ENDIF(QT_QT3SUPPORT_LIBRARY)
  
  IF(QT_QTASSISTANT_LIBRARY)
    SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTASSISTANT_LIBRARY} )
  ELSE(QT_QTASSISTANT_LIBRARY)
    IF(QT_QTASSISTANT_LIBRARY_DEBUG)
      SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTASSISTANT_LIBRARY_DEBUG} )     
    ENDIF(QT_QTASSISTANT_LIBRARY_DEBUG)
  ENDIF(QT_QTASSISTANT_LIBRARY)
  
  IF(QT_QTCORE_LIBRARY)
    SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTCORE_LIBRARY} )
  ELSE(QT_QTCORE_LIBRARY)
    IF(QT_QTCORE_LIBRARY_DEBUG)
      SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTCORE_LIBRARY_DEBUG} )  
    ENDIF(QT_QTCORE_LIBRARY_DEBUG)
  ENDIF(QT_QTCORE_LIBRARY)
  
  IF(QT_QTDESIGNER_LIBRARY)
    SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTDESIGNER_LIBRARY} )
  ELSE(QT_QTDESIGNER_LIBRARY)
    IF(QT_QTDESIGNER_LIBRARY_DEBUG)
      SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTDESIGNER_LIBRARY_DEBUG} )      
    ENDIF(QT_QTDESIGNER_LIBRARY_DEBUG)
  ENDIF(QT_QTDESIGNER_LIBRARY)
  
  IF(QT_QTGUI_LIBRARY)
    SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTGUI_LIBRARY} )
  ELSE(QT_QTGUI_LIBRARY)
    IF(QT_QTGUI_LIBRARY_DEBUG)
      SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTGUI_LIBRARY_DEBUG} )   
    ENDIF(QT_QTGUI_LIBRARY_DEBUG)
  ENDIF(QT_QTGUI_LIBRARY)
  
  IF(QT_QTMOTIF_LIBRARY)
    SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTMOTIF_LIBRARY} )
  ELSE(QT_QTMOTIF_LIBRARY)
    IF(QT_QTMOTIF_LIBRARY_DEBUG)
      SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTMOTIF_LIBRARY_DEBUG} ) 
    ENDIF(QT_QTMOTIF_LIBRARY_DEBUG)
  ENDIF(QT_QTMOTIF_LIBRARY)
  
  IF(QT_QTNETWORK_LIBRARY)
    SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTNETWORK_LIBRARY} )
  ELSE(QT_QTNETWORK_LIBRARY)
    IF(QT_QTNETWORK_LIBRARY_DEBUG)
      SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTNETWORK_LIBRARY_DEBUG} )       
    ENDIF(QT_QTNETWORK_LIBRARY_DEBUG)
  ENDIF(QT_QTNETWORK_LIBRARY)
  
  IF(QT_QTNSPLUGIN_LIBRARY)
    SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTNSPLUGIN_LIBRARY} )
  ELSE(QT_QTNSPLUGIN_LIBRARY)
    IF(QT_QTNSPLUGIN_LIBRARY_DEBUG)
      SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTNSPLUGIN_LIBRARY_DEBUG} )      
    ENDIF(QT_QTNSPLUGIN_LIBRARY_DEBUG)
  ENDIF(QT_QTNSPLUGIN_LIBRARY)
  
  IF(QT_QTOPENGL_LIBRARY)
    SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTOPENGL_LIBRARY} )
  ELSE(QT_QTOPENGL_LIBRARY)
    IF(QT_QTOPENGL_LIBRARY_DEBUG)
      SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTOPENGL_LIBRARY_DEBUG} )        
    ENDIF(QT_QTOPENGL_LIBRARY_DEBUG)
  ENDIF(QT_QTOPENGL_LIBRARY)
  
  IF(QT_QTSQL_LIBRARY)
    SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTSQL_LIBRARY} )
  ELSE(QT_QTSQL_LIBRARY)
    IF(QT_QTSQL_LIBRARY_DEBUG)
      SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTSQL_LIBRARY_DEBUG} )   
    ENDIF(QT_QTSQL_LIBRARY_DEBUG)
  ENDIF(QT_QTSQL_LIBRARY)
  
  IF(QT_QTXML_LIBRARY)
    SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTXML_LIBRARY} )
  ELSE(QT_QTXML_LIBRARY)
    IF(QT_QTXML_LIBRARY_DEBUG)
      SET( QT_LIBRARIES_TRYOPTIMIZED ${QT_LIBRARIES_TRYOPTIMIZED} ${QT_QTXML_LIBRARY_DEBUG} )   
    ENDIF(QT_QTXML_LIBRARY_DEBUG)
  ENDIF(QT_QTXML_LIBRARY)
ENDIF(NOT QT_LIBRARIES_TRYOPTIMIZED)

# Set QT_LIBRARIES_TRYDEBUG
IF(NOT QT_LIBRARIES_TRYDEBUG)
  IF(QT_QT3SUPPORT_LIBRARY_DEBUG)
    SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QT3SUPPORT_LIBRARY_DEBUG} )
  ELSE(QT_QT3SUPPORT_LIBRARY_DEBUG)
    IF(QT_QT3SUPPORT_LIBRARY)
      SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QT3SUPPORT_LIBRARY} )    
    ENDIF(QT_QT3SUPPORT_LIBRARY)
  ENDIF(QT_QT3SUPPORT_LIBRARY_DEBUG)
  
  IF(QT_QTASSISTANT_LIBRARY_DEBUG)
    SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTASSISTANT_LIBRARY_DEBUG} )
  ELSE(QT_QTASSISTANT_LIBRARY_DEBUG)
    IF(QT_QTASSISTANT_LIBRARY)
      SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTASSISTANT_LIBRARY} )   
    ENDIF(QT_QTASSISTANT_LIBRARY)
  ENDIF(QT_QTASSISTANT_LIBRARY_DEBUG)
  
  IF(QT_QTCORE_LIBRARY_DEBUG)
    SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTCORE_LIBRARY_DEBUG} )
  ELSE(QT_QTCORE_LIBRARY_DEBUG)
    IF(QT_QTCORE_LIBRARY)
      SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTCORE_LIBRARY} )        
    ENDIF(QT_QTCORE_LIBRARY)
  ENDIF(QT_QTCORE_LIBRARY_DEBUG)
  
  IF(QT_QTDESIGNER_LIBRARY_DEBUG)
    SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTDESIGNER_LIBRARY_DEBUG} )
  ELSE(QT_QTDESIGNER_LIBRARY_DEBUG)
    IF(QT_QTDESIGNER_LIBRARY)
      SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTDESIGNER_LIBRARY} )    
    ENDIF(QT_QTDESIGNER_LIBRARY)
  ENDIF(QT_QTDESIGNER_LIBRARY_DEBUG)
  
  IF(QT_QTGUI_LIBRARY_DEBUG)
    SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTGUI_LIBRARY_DEBUG} )
  ELSE(QT_QTGUI_LIBRARY_DEBUG)
    IF(QT_QTGUI_LIBRARY)
      SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTGUI_LIBRARY} ) 
    ENDIF(QT_QTGUI_LIBRARY)
  ENDIF(QT_QTGUI_LIBRARY_DEBUG)
  
  IF(QT_QTMOTIF_LIBRARY_DEBUG)
    SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTMOTIF_LIBRARY_DEBUG} )
  ELSE(QT_QTMOTIF_LIBRARY_DEBUG)
    IF(QT_QTMOTIF_LIBRARY)
      SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTMOTIF_LIBRARY} )       
    ENDIF(QT_QTMOTIF_LIBRARY)
  ENDIF(QT_QTMOTIF_LIBRARY_DEBUG)
  
  IF(QT_QTNETWORK_LIBRARY_DEBUG)
    SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTNETWORK_LIBRARY_DEBUG} )
  ELSE(QT_QTNETWORK_LIBRARY_DEBUG)
    IF(QT_QTNETWORK_LIBRARY)
      SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTNETWORK_LIBRARY} )     
    ENDIF(QT_QTNETWORK_LIBRARY)
  ENDIF(QT_QTNETWORK_LIBRARY_DEBUG)
  
  IF(QT_QTNSPLUGIN_LIBRARY_DEBUG)
    SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTNSPLUGIN_LIBRARY_DEBUG} )
  ELSE(QT_QTNSPLUGIN_LIBRARY_DEBUG)
    IF(QT_QTNSPLUGIN_LIBRARY)
      SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTNSPLUGIN_LIBRARY} )    
    ENDIF(QT_QTNSPLUGIN_LIBRARY)
  ENDIF(QT_QTNSPLUGIN_LIBRARY_DEBUG)
  
  IF(QT_QTOPENGL_LIBRARY_DEBUG)
    SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTOPENGL_LIBRARY_DEBUG} )
  ELSE(QT_QTOPENGL_LIBRARY_DEBUG)
    IF(QT_QTOPENGL_LIBRARY)
      SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTOPENGL_LIBRARY} )      
    ENDIF(QT_QTOPENGL_LIBRARY)
  ENDIF(QT_QTOPENGL_LIBRARY_DEBUG)
  
  IF(QT_QTSQL_LIBRARY_DEBUG)
    SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTSQL_LIBRARY_DEBUG} )
  ELSE(QT_QTSQL_LIBRARY_DEBUG)
    IF(QT_QTSQL_LIBRARY)
      SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTSQL_LIBRARY} ) 
    ENDIF(QT_QTSQL_LIBRARY)
  ENDIF(QT_QTSQL_LIBRARY_DEBUG)
  
  IF(QT_QTXML_LIBRARY_DEBUG)
    SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTXML_LIBRARY_DEBUG} )
  ELSE(QT_QTXML_LIBRARY_DEBUG)
    IF(QT_QTXML_LIBRARY)
      SET( QT_LIBRARIES_TRYDEBUG ${QT_LIBRARIES_TRYDEBUG} ${QT_QTXML_LIBRARY} ) 
    ENDIF(QT_QTXML_LIBRARY)
  ENDIF(QT_QTXML_LIBRARY_DEBUG)
ENDIF(NOT QT_LIBRARIES_TRYDEBUG)


#######################################
#
#       Check the executables of Qt 
#          ( moc, uic, rcc )
#
#######################################
IF(NOT QT_MOC_EXECUTABLE)
  IF(QT_QMAKE_EXECUTABLE)
    EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
      ARGS "-query QT_INSTALL_BINS" 
      OUTPUT_VARIABLE qt_bins ) 
  ENDIF(QT_QMAKE_EXECUTABLE)
  FIND_PROGRAM(QT_MOC_EXECUTABLE 
    NAMES moc
    PATHS
    ${qt_bins}
    $ENV{QTDIR}/bin
    /usr/local/qt/bin
    /usr/local/bin
    /usr/lib/qt/bin
    /usr/bin
    /usr/share/qt4/bin
    C:/Progra~1/qt/bin
    /usr/bin/qt4
    )
ENDIF(NOT QT_MOC_EXECUTABLE)

IF(QT_MOC_EXECUTABLE)
  SET ( QT_WRAP_CPP "YES")
ELSE(QT_MOC_EXECUTABLE)
ENDIF(QT_MOC_EXECUTABLE)

IF(NOT QT_UIC_EXECUTABLE )
  IF(QT_QMAKE_EXECUTABLE)
    EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
      ARGS "-query QT_INSTALL_BINS" 
      OUTPUT_VARIABLE qt_bins )
  ENDIF(QT_QMAKE_EXECUTABLE)
  FIND_PROGRAM(QT_UIC_EXECUTABLE 
    NAMES uic
    PATHS
    ${qt_bins}
    $ENV{QTDIR}/bin
    /usr/local/qt/bin
    /usr/local/bin
    /usr/lib/qt/bin
    /usr/bin
    /usr/share/qt4/bin
    C:/Progra~1/qt/bin
    /usr/bin/qt4
    )
ENDIF(NOT QT_UIC_EXECUTABLE )

IF(QT_UIC_EXECUTABLE)
  SET ( QT_WRAP_UI "YES")
ELSE(QT_UIC_EXECUTABLE)
ENDIF(QT_UIC_EXECUTABLE)

IF(NOT QT_RCC_EXECUTABLE)
  IF(QT_QMAKE_EXECUTABLE)
    EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE}
      ARGS "-query QT_INSTALL_BINS" 
      OUTPUT_VARIABLE qt_bins )
  ENDIF(QT_QMAKE_EXECUTABLE)
  FIND_PROGRAM(QT_RCC_EXECUTABLE 
    NAMES rcc
    PATHS
    ${qt_bins}
    $ENV{QTDIR}/bin
    /usr/local/qt/bin
    /usr/local/bin
    /usr/lib/qt/bin
    /usr/bin
    /usr/share/qt4/bin
    C:/Progra~1/qt/bin
    /usr/bin/qt4
    )
ENDIF(NOT QT_RCC_EXECUTABLE )

MARK_AS_ADVANCED(
  QT_UIC_EXECUTABLE
  QT_MOC_EXECUTABLE
  QT_RCC_EXECUTABLE )

######################################
#
#       Macros for building Qt files
#
######################################


# QT4_WRAP_CPP(outfiles inputfile ... )
# TODO  perhaps add support for -D, -U and other minor options

MACRO(QT4_WRAP_CPP outfiles )

  # get include dirs
  GET_DIRECTORY_PROPERTY(moc_includes_tmp INCLUDE_DIRECTORIES)
  SET(moc_includes)
  FOREACH(it ${moc_includes_tmp})
    SET(moc_includes ${moc_includes} "-I${it}")
  ENDFOREACH(it)

  FOREACH(it ${ARGN})
    GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)

    SET(infile ${CMAKE_CURRENT_SOURCE_DIR}/${it})
    SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/moc_${outfile}.cxx)
    ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
                       COMMAND ${QT_MOC_EXECUTABLE}
                       ARGS ${moc_includes} -o ${outfile} ${infile}
                       MAIN_DEPENDENCY ${infile})
    SET(${outfiles} ${${outfiles}} ${outfile})
  ENDFOREACH(it)

ENDMACRO(QT4_WRAP_CPP)


# QT4_WRAP_UI(outfiles inputfile ... )

MACRO(QT4_WRAP_UI outfiles )

  FOREACH(it ${ARGN})
    GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
    SET(infile ${CMAKE_CURRENT_SOURCE_DIR}/${it})
    SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h)
    ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
                       COMMAND ${QT_UIC_EXECUTABLE}
                       ARGS -o ${outfile} ${infile}
                       MAIN_DEPENDENCY ${infile})
    SET(${outfiles} ${${outfiles}} ${outfile})
  ENDFOREACH(it)

ENDMACRO(QT4_WRAP_UI)

# QT4_ADD_RESOURCE(outfiles inputfile ... )
# TODO  perhaps consider adding support for compression and root options to rcc

MACRO(QT4_ADD_RESOURCES outfiles )

  FOREACH(it ${ARGN})
    GET_FILENAME_COMPONENT(outfilename ${it} NAME_WE)
    SET(infile ${CMAKE_CURRENT_SOURCE_DIR}/${it})
    SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cxx)
    ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
                       COMMAND ${QT_RCC_EXECUTABLE}
                       ARGS -name ${outfilename} -o ${outfile} ${infile}
                       MAIN_DEPENDENCY ${infile} )
    SET(${outfiles} ${${outfiles}} ${outfile})
  ENDFOREACH(it)

ENDMACRO(QT4_ADD_RESOURCES)



######################################
#
#       deside if Qt got found
#
######################################
# if the includes,libraries,moc,uic and rcc are found then we have it
IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
  SET( QT_FOUND "YES" )
  IF( NOT Qt_FIND_QUIETLY) 
    MESSAGE(STATUS "Found Qt-Version ${QT_INST_MAJOR_VERSION}.${QT_INST_MINOR_VERSION}.${QT_INST_PATCH_VERSION}")
  ENDIF( NOT Qt_FIND_QUIETLY) 
ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE)
  SET( QT_FOUND "NO")
  IF( Qt_FIND_REQUIRED)
    MESSAGE( SEND_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!")
  ENDIF( Qt_FIND_REQUIRED)
ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND QT_UIC_EXECUTABLE AND  QT_RCC_EXECUTABLE)


#######################################
#
#       System dependent settings  
#
#######################################
# for unix add X11 stuff
IF(UNIX)
  FIND_PACKAGE(X11)
  IF (X11_FOUND)
    SET (QT_LIBRARIES ${QT_LIBRARIES} ${X11_LIBRARIES})
  ENDIF (X11_FOUND)
  IF (CMAKE_DL_LIBS)
    SET (QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_DL_LIBS})
  ENDIF (CMAKE_DL_LIBS)
ENDIF(UNIX)


#######################################
#
#       compatibility settings 
#
#######################################
# Backwards compatibility for CMake1.4 and 1.2
SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} )
SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} )

SET( QT_DEFINITIONS "")
SET( QT_QT_LIBRARY "")
SET( QT_QTMAIN_LIBRARY "")