]> Creatis software - crea.git/blob - cmake/CREAMacro_FindAndUseWxWidgets.cmake
18df9d2b231a9fe75437cca8557597203fc3b58d
[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         if (DEFINED CREA_USE_MXE)
33                 SET(WXGLCANVASLIBS "gl")  
34                 SET(WXAUILIBS "aui")
35                 # LG : These options should be set by the user at top level of crea
36                 FIND_PACKAGE(wxWidgets COMPONENTS base core adv html
37                   ${WXAUILIBS}
38                   ${WXGLCANVASLIBS})
39                 IF(wxWidgets_FOUND)
40                         MESSAGE ( STATUS "=======================================")
41                         MESSAGE ( STATUS "Looking for wxWidgets... found ${wxWidgets_CONFIG_EXECUTABLE}")
42                         MESSAGE(STATUS "wxWidgets_INCLUDE_DIRS = ${wxWidgets_INCLUDE_DIRS}")
43                 ELSE(wxWidgets_FOUND)
44                         MESSAGE ( ERROR "EED cmake ERROR : wxWidgets not found")
45                 ENDIF(wxWidgets_FOUND)
46         ELSE(DEFINED CREA_USE_MXE)
47             # Search WXWIDGETS
48             
49             #  WXWINDOWS_LIBRARY         = full path to the wxWindows library and linker flags on unix
50             #  CMAKE_WX_CXX_FLAGS        = compiler flags for building wxWindows 
51             #  WXWINDOWS_INCLUDE_PATH    = include path of wxWindows
52             SET(WXWINDOWS_USE_GL 1)
53             
54             #wxWidgets build related stuff
55             # DO NOT FORCE DEBUG LIBS !!
56             SET(WXW_USE_DEBUG OFF)
57             SET(WXW_USE_UNICODE OFF)
58             SET(WXW_USE_SHARED ON)
59             SET(WXW_USE_UNIV OFF)
60             SET(WXW_USE_MONO OFF)
61             SET(WXW_FILE_VERSION "28")
62             SET(WXW_VERSION "2.8")
63             
64             #CMake Options
65             # Why forcing verbosity ?
66             # SET(CMAKE_VERBOSE_MAKEFILE TRUE)
67             
68             INCLUDE (${CREA_CMAKE_DIR}/FindWxWidgetsWin32.cmake)
69             #
70         ENDIF (DEFINED CREA_USE_MXE)
71   
72   ELSE(WIN32)
73     IF(NOT wxWidgets_FOUND)
74     # CMake 2.6:
75     # technically those packages are not required 
76     # since one can still use the Motif/X11 version and not the gtk one:
77     FIND_PACKAGE(PkgConfig REQUIRED)
78
79 ##    pkg_check_modules (GTK2 gtk+-2.0)
80 ##    pkg_check_modules (GTK322 gtk+-3.0)
81     pkg_check_modules (GTK3 REQUIRED gtk+-3.0)
82     #MESSAGE("${GTK3_INCLUDE_DIRS}")
83
84     # Can I require all my user to have the gl lib on linux, even if they do not really need it...
85     SET(WXGLCANVASLIBS "gl")
86   
87     SET(WXAUILIBS "aui")
88     # LG : These options should be set by the user at top level of crea
89     FIND_PACKAGE(wxWidgets COMPONENTS base core adv html
90       ${WXAUILIBS}
91       ${WXGLCANVASLIBS})
92     #
93     IF(wxWidgets_FOUND)
94       MESSAGE ( STATUS "=======================================")
95       MESSAGE ( STATUS "Looking for wxWidgets... found ${wxWidgets_CONFIG_EXECUTABLE}")
96     ENDIF(wxWidgets_FOUND)
97     ENDIF(NOT wxWidgets_FOUND)
98   ENDIF(WIN32)
99   
100
101
102 ENDMACRO(CREA_FIND_WXWIDGETS)
103 #=======================================================================
104
105 #=======================================================================
106 MACRO(CREA_USE_WXWIDGETS)
107   # Preprocessor settings
108   CREA_DEFINE( USE_WXWIDGETS )
109   CREA_DEFINE( _USE_WXWIDGETS_ )
110   IF(WIN32)
111         if (DEFINED CREA_USE_MXE)
112            include(${wxWidgets_USE_FILE})
113                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}${wxWidgets_CXX_FLAGS}")
114                 INCLUDE_DIRECTORIES(${wxWidgets_INCLUDE_DIRS})
115                 LINK_DIRECTORIES( ${wxWidgets_LIBRARY_DIRS} )
116                 SET(WXWIDGETS_LIBRARIES
117                           ${wxWidgets_LIBRARIES}  
118                 )
119
120       MESSAGE ( STATUS "EED : MACRO CREA_USE_WXWIDGETS B    wxWidgets_INCLUDE_DIRS = ${wxWidgets_INCLUDE_DIRS}")
121       MESSAGE ( STATUS "EED : MACRO CREA_USE_WXWIDGETS B    wxWidgets_DEFINITIONS = ${wxWidgets_DEFINITIONS}")
122       MESSAGE ( STATUS "EED : MACRO CREA_USE_WXWIDGETS B    wxWidgets_LIBRARY_DIRS = ${wxWidgets_LIBRARY_DIRS}")
123       MESSAGE ( STATUS "EED : MACRO CREA_USE_WXWIDGETS B    wxWidgets_LIBRARIES = ${wxWidgets_LIBRARIES}")
124       MESSAGE ( STATUS "EED : MACRO CREA_USE_WXWIDGETS B    wxWidgets_USE_FILE = ${wxWidgets_USE_FILE}")
125
126
127         ELSE(DEFINED CREA_USE_MXE)
128                 # Clean ?
129                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}${WXWIDGETS_CXX_FLAGS}")
130                 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}${WXWIDGETS_EXE_LINKER_FLAGS}")
131                 #
132                 ADD_DEFINITIONS( ${WXWIDGETS_DEFINITIONS}  )
133                 #
134                 INCLUDE_DIRECTORIES(${WXWIDGETS_INCLUDE_DIR})
135                 LINK_DIRECTORIES( ${WXWIDGETS_LINK_DIRECTORIES} )
136                 SET(WXWIDGETS_LIBRARIES
137                         ${WXWIDGETS_LIBRARIES}  
138         #DO NOT FORCE DEBUG LIBS !!
139                           debug wxmsw28d_aui
140                           optimized wxmsw28_aui
141                           debug msvcrtd
142                           debug msvcprtd
143                           optimized msvcrt
144                           optimized msvcprt
145                   )
146         ENDIF (DEFINED CREA_USE_MXE)
147   ELSE(WIN32)
148 ##    # GTK2
149 ##    INCLUDE_DIRECTORIES(${GTK2_INCLUDE_DIRS})
150 ##    LINK_DIRECTORIES(${GTK2_LIBRARY_DIRS})
151 ##    LINK_LIBRARIES(${GTK2_LIBRARIES})
152     # GTK3
153     INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
154     LINK_DIRECTORIES(${GTK3_LIBRARY_DIRS})
155     LINK_LIBRARIES(${GTK3_LIBRARIES} )
156     # WX
157
158
159 #    INCLUDE( ${GTK_USE_FILE} )
160     INCLUDE( ${wxWidgets_USE_FILE} )
161     MARK_AS_ADVANCED(wxWidgets_CONFIG_EXECUTABLE)
162     SET(WXWIDGETS_LIBRARIES
163 ##    GTK2
164 ##      ${GTK2_LIBRARIES}
165       ${GTK3_LIBRARIES}
166       #${GTK_LIBRARIES}
167
168       ${wxWidgets_LIBRARIES}
169       )
170
171   ENDIF(WIN32)
172 ENDMACRO(CREA_USE_WXWIDGETS)
173 #=======================================================================
174
175 #=======================================================================
176 MACRO(CREA_FIND_AND_USE_WXWIDGETS)
177   CREA_FIND_WXWIDGETS()
178   CREA_USE_WXWIDGETS()
179 ENDMACRO(CREA_FIND_AND_USE_WXWIDGETS)
180 #=======================================================================