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