]> Creatis software - crea.git/blob - cmake/CREAMacro_FindAndUseWxWidgets.cmake
969300c73478ef2338d415e949462b8c1612da53
[crea.git] / cmake / CREAMacro_FindAndUseWxWidgets.cmake
1 # ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
4 #                        pour la Santé)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and 
10 #  abiding by the rules of distribution of free software. You can  use, 
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
12 #  license as circulated by CEA, CNRS and INRIA at the following URL 
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability. 
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */ 
25
26
27 #=======================================================================
28 # Looks for WxWidgets
29 #=======================================================================
30 MACRO(CREA_FIND_WXWIDGETS)
31   IF(WIN32)
32     # Search WXWIDGETS
33     
34     #  WXWINDOWS_LIBRARY         = full path to the wxWindows library and linker flags on unix
35     #  CMAKE_WX_CXX_FLAGS        = compiler flags for building wxWindows 
36     #  WXWINDOWS_INCLUDE_PATH    = include path of wxWindows
37     SET(WXWINDOWS_USE_GL 1)
38     
39     #wxWidgets build related stuff
40     # DO NOT FORCE DEBUG LIBS !!
41         SET(WXW_USE_DEBUG OFF)
42     SET(WXW_USE_UNICODE OFF)
43     SET(WXW_USE_SHARED ON)
44     SET(WXW_USE_UNIV OFF)
45     SET(WXW_USE_MONO OFF)
46     SET(WXW_FILE_VERSION "28")
47     SET(WXW_VERSION "2.8")
48     
49     #CMake Options
50     # Why forcing verbosity ?
51     # SET(CMAKE_VERBOSE_MAKEFILE TRUE)
52     
53     INCLUDE (${CREA_CMAKE_DIR}/FindWxWidgetsWin32.cmake)
54     #
55   
56   ELSE(WIN32)
57     IF(NOT wxWidgets_FOUND)
58     # CMake 2.6:
59     # technically those packages are not required 
60     # since one can still use the Motif/X11 version and not the gtk one:
61     FIND_PACKAGE(PkgConfig)
62     pkg_check_modules (GTK2 gtk+-2.0)
63     #MESSAGE("${GTK2_INCLUDE_DIRS}")
64     # Can I require all my user to have the gl lib on linux, even if they do not really need it...
65 #EED  SET(WXGLCANVASLIBS "gl")
66     # aui ?
67     SET(WXAUILIBS "aui")
68     # LG : These options should be set by the user at top level of crea
69     FIND_PACKAGE(wxWidgets COMPONENTS base core adv html 
70       ${WXAUILIBS}
71       ${WXGLCANVASLIBS})
72     #
73     IF(wxWidgets_FOUND)
74       MESSAGE ( STATUS "=======================================")
75       MESSAGE ( STATUS "Looking for wxWidgets... found ${wxWidgets_CONFIG_EXECUTABLE}")
76     ENDIF(wxWidgets_FOUND)
77     ENDIF(NOT wxWidgets_FOUND)
78   ENDIF(WIN32)
79   
80
81
82 ENDMACRO(CREA_FIND_WXWIDGETS)
83 #=======================================================================
84
85 #=======================================================================
86 MACRO(CREA_USE_WXWIDGETS)
87   # Preprocessor settings
88   CREA_DEFINE( USE_WXWIDGETS )
89   CREA_DEFINE( _USE_WXWIDGETS_ )
90   #
91   IF(WIN32)
92     # Clean ?
93     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}${WXWIDGETS_CXX_FLAGS}")
94     SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}${WXWIDGETS_EXE_LINKER_FLAGS}")
95     #
96     ADD_DEFINITIONS( ${WXWIDGETS_DEFINITIONS}  )
97     #
98     INCLUDE_DIRECTORIES(${WXWIDGETS_INCLUDE_DIR})
99     LINK_DIRECTORIES( ${WXWIDGETS_LINK_DIRECTORIES} )
100     SET(WXWIDGETS_LIBRARIES
101       ${WXWIDGETS_LIBRARIES}  
102 #DO NOT FORCE DEBUG LIBS !!
103       debug wxmsw28d_aui
104       optimized wxmsw28_aui
105       debug msvcrtd
106       debug msvcprtd
107       optimized msvcrt
108       optimized msvcprt
109       )
110   ELSE(WIN32)
111     # GTK2
112     INCLUDE_DIRECTORIES(${GTK2_INCLUDE_DIRS})
113     LINK_DIRECTORIES(${GTK2_LIBRARY_DIRS})
114     LINK_LIBRARIES(${GTK2_LIBRARIES})
115     # WX
116
117
118 #    INCLUDE( ${GTK_USE_FILE} )
119     INCLUDE( ${wxWidgets_USE_FILE} )
120     MARK_AS_ADVANCED(wxWidgets_CONFIG_EXECUTABLE)
121     SET(WXWIDGETS_LIBRARIES
122       ${GTK2_LIBRARIES}
123       #${GTK_LIBRARIES}
124       ${wxWidgets_LIBRARIES}
125       )
126   ENDIF(WIN32)
127 ENDMACRO(CREA_USE_WXWIDGETS)
128 #=======================================================================
129
130 #=======================================================================
131 MACRO(CREA_FIND_AND_USE_WXWIDGETS)
132   CREA_FIND_WXWIDGETS()
133   CREA_USE_WXWIDGETS()
134 ENDMACRO(CREA_FIND_AND_USE_WXWIDGETS)
135 #=======================================================================