debian: fix build-deps for focal
[amule.git] / cmake / wx.cmake
blob8f9ff295b1986f836b8c1f9aac9b34783fc23a2f
2 # This file is part of the aMule Project.
4 # Copyright (c) 2011 Werner Mahr (Vollstrecker) <amule@vollstreckernet.de>
6 # Any parts of this program contributed by third-party developers are copyrighted
7 # by their respective authors.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
24 # This file provides the CHECK_WX Macro which checks if wx is at least in a
25 # version defined by MIN_WX_VERSION. This check will go away, when cmake
26 # findWX module supports check of version
27
28 # Furthermore it sets the LIBS, LIBDIR and DEFS needed for compilation.
29 # This can be controled by setting wx_NEED_BASE and wx_NEED_GUI vars.
32 INCLUDE (CheckCXXSymbolExists)
33 INCLUDE (ExternalProject)
35 #IF (BUILT_WX)
36         #SET (BUILT_WX ${BUILT_WX} CACHE BOOL "Remeber that wx was built" FORCE)
38         #EXTERNALPROJECT_ADD (WX
39                 #GIT_REPOSITORY https://github.com/wxWidgets/wxWidgets.git
40                 #GIT_TAG v3.1.2
41                 #CONFIGURE_COMMAND ""
42                 #BUILD_COMMAND ""
43                 #INSTALL_COMMAND ""
44                 #EXCLUDE_FROM_ALL TRUE
45         #)
47         #EXTERNALPROJECT_GET_PROPERTY (WX SOURCE_DIR)
49         #IF (WIN32)
50                 #SET (wxWidgets_ROOT_DIR ${CMAKE_INSTALL_PREFIX})
51         #ELSE (WIN32)
52                 #INSTALL (CODE
53                         #"EXECUTE_PROCESS (
54                                 #COMMAND ${CMAKE_MAKE_PROGRAM} clean
55                                 #WORKING_DIRECTORY ${SOURCE_DIR}
56                         #)
58                         #EXECUTE_PROCESS (
59                                 #COMMAND ./configure --prefix=${CMAKE_INSTALL_PREFIX}
60                                 #WORKING_DIRECTORY ${SOURCE_DIR}
61                         #)
63                         #EXECUTE_PROCESS (
64                                 #COMMAND ${CMAKE_MAKE_PROGRAM} install
65                                 #WORKING_DIRECTORY ${SOURCE_DIR}
66                         #)"
67                 #)
69                 #SET (wxWidgets_CONFIG_EXECUTABLE ${SOURCE_DIR}/wx-config CACHE FILEPATH "Location of wxWidgets library configuration provider binary (wx-config)." FORCE)
70         #ENDIF (WIN32)
71 #ENDIF (BUILT_WX)
73 #IF (NOT DOWNLOAD_AND_BUILD_DEPS)
74         SET (wx_REQUIRED "REQUIRED")
75 #ELSE (NOT DOWNLOAD_AND_BUILD_DEPS)
76 #       UNSET (wx_REQUIRED)
77 #ENDIF (NOT DOWNLOAD_AND_BUILD_DEPS)
79 IF (wx_NEED_BASE)
80         SET (BASE "base")
81         LIST (APPEND WX_COMPONENTS BASE)
83         ADD_LIBRARY (wxWidgets::BASE
84                 UNKNOWN
85                 IMPORTED
86         )
87 ENDIF (wx_NEED_BASE)
89 IF (wx_NEED_ADV)
90         SET (ADV "adv")
91         LIST (APPEND WX_COMPONENTS ADV)
93         ADD_LIBRARY (wxWidgets::ADV
94                 UNKNOWN
95                 IMPORTED
96         )
97 ENDIF (wx_NEED_ADV)
99 IF (wx_NEED_GUI)
100         SET (CORE "core")
101         LIST (APPEND WX_COMPONENTS CORE)
103         ADD_LIBRARY (wxWidgets::CORE
104                 UNKNOWN
105                 IMPORTED
106         )
107 ENDIF (wx_NEED_GUI)
109 IF (wx_NEED_NET)
110         SET (NET "net")
111         LIST (APPEND WX_COMPONENTS NET)
113         ADD_LIBRARY (wxWidgets::NET
114                 UNKNOWN
115                 IMPORTED
116         )
117 ENDIF (wx_NEED_NET)
119 #IF (DOWNLOAD_AND_BUILD_DEPS)
120 #       UNSET (WX_REQUIRED)
121 #ELSE (DOWNLOAD_AND_BUILD_DEPS)
122         SET (WX_REQUIRED "REQUIRED")
123 #ENDIF (DOWNLOAD_AND_BUILD_DEPS)
125 IF (wxWidgets_BASE_DEFINITIONS)
126         SET (WX_QUIET QUIET)
127 ENDIF (wxWidgets_BASE_DEFINITIONS)
129 IF (WX_COMPONENTS)
130         FOREACH (COMPONENT ${WX_COMPONENTS})
131                 IF (${COMPONENT} STREQUAL ADV AND wxWidgets_VERSION_STRING VERSION_GREATER_EQUAL 3.1.2 AND NOT WX_QUIET)
132                         MESSAGE (STATUS "wx_Version 3.1.2 or newer detected. Disabling wx_ADV")
133                         CONTINUE()
134                 ENDIF (${COMPONENT} STREQUAL ADV AND wxWidgets_VERSION_STRING VERSION_GREATER_EQUAL 3.1.2 AND NOT WX_QUIET)
136                 IF (NOT wxWidgets_${COMPONENT}_LIBRARY AND NOT (wxWidgets_${COMPONENT}_LIBRARY_RELEASE AND wxWidgets_${COMPONENT}_LIBRARY_DEBUG))
137                         FIND_PACKAGE (wxWidgets ${MIN_WX_VERSION} ${WX_QUIET} ${WX_REQUIRED} COMPONENTS ${${COMPONENT}})
138                 ENDIF (NOT wxWidgets_${COMPONENT}_LIBRARY AND NOT (wxWidgets_${COMPONENT}_LIBRARY_RELEASE AND wxWidgets_${COMPONENT}_LIBRARY_DEBUG))
140                 IF (WIN32)
141                         SET_PROPERTY (TARGET wxWidgets::${COMPONENT}
142                                                         PROPERTY IMPORTED_LOCATION_RELEASE ${WX_${${COMPONENT}}}
143                         )
145                         SET_PROPERTY (TARGET wxWidgets::${COMPONENT}
146                                                         PROPERTY IMPORTED_LOCATION_DEBUG ${WX_${${COMPONENT}}d}
147                         )
149                         SET (wxWidgets_DEFINITIONS ${wxWidgets_DEFINITIONS} WXUSINGDLL)
151                         IF (${COMPONENT} STREQUAL CORE)
152                                 SET (wxWidgets_DEFINITIONS ${wxWidgets_DEFINITIONS} wxUSE_GUI=1)
153                                 SET (CMAKE_REQUIRED_INCLUDES ${wxWidgets_INCLUDE_DIRS})
155                                 IF (NOT UNICODE_SUPPORT)
156                                         UNSET (UNICODE_SUPPORT CACHE)
158                                         CHECK_CXX_SYMBOL_EXISTS (wxUSE_UNICODE
159                                                 wx/setup.h
160                                                 UNICODE_SUPPORT
161                                         )
162                                 ENDIF (NOT UNICODE_SUPPORT)
164                                 UNSET (CMAKE_REQUIRED_INCLUDES)
166                                 IF (UNICODE_SUPPORT)
167                                         SET (wxWidgets_DEFINITIONS ${wxWidgets_DEFINITIONS} _UNICODE)
168                                 ENDIF (UNICODE_SUPPORT)
169                         ENDIF (${COMPONENT} STREQUAL CORE)
171                         SET (wxWidgets_${COMPONENT}_LIBRARY_RELEASE ${WX_${${COMPONENT}}} CACHE STRING "Libs to use when linking to ${COMPONENT}" FORCE)
172                         SET (wxWidgets_${COMPONENT}_LIBRARY_DEBUG ${WX_${${COMPONENT}}d} CACHE STRING "Libs to use when linking to ${COMPONENT}" FORCE)
174                         MARK_AS_ADVANCED (wxWidgets_${COMPONENT}_LIBRARY_RELEASE
175                                 wxWidgets_${COMPONENT}_LIBRARY_DEBUG
176                         )
177                 ELSE (WIN32)
178                         FOREACH (LIB IN LISTS wxWidgets_LIBRARIES)
179                                 IF ("${LIB}" MATCHES "^-l(.*)$")
180                                         SET (LIB_TO_SEARCH ${CMAKE_MATCH_1})
182                                         FIND_LIBRARY (${LIB_TO_SEARCH}_SEARCH
183                                                 ${LIB_TO_SEARCH}
184                                                 PATHS ${wxWidgets_LIBRARY_DIRS}
185                                         )
187                                         IF (${LIB_TO_SEARCH}_SEARCH AND ${${LIB_TO_SEARCH}_SEARCH} MATCHES ${${COMPONENT}})
188                                                 SET_PROPERTY (TARGET wxWidgets::${COMPONENT}
189                                                         PROPERTY IMPORTED_LOCATION ${${LIB_TO_SEARCH}_SEARCH}
190                                                 )
191                                         ELSE (${LIB_TO_SEARCH}_SEARCH AND ${${LIB_TO_SEARCH}_SEARCH} MATCHES ${${COMPONENT}})
192                                                 FOREACH (TGT ${WX_COMPONENTS})
193                                                         IF (${${LIB_TO_SEARCH}_SEARCH} MATCHES ${${TGT}} AND TARGET wxWidgets::${TGT})
194                                                                 TARGET_LINK_LIBRARIES (wxWidgets::${COMPONENT}
195                                                                         INTERFACE wxWidgets::${TGT}
196                                                                 )
197                                                         ELSEIF (NOT TARGET wxWidgets::${TGT})
198                                                                 MESSAGE (FATAL_ERROR "Tried to add dependency for wxWidgets::${TGT} but didn't find a target wxWidgets::${COMPONENT}")
199                                                         ENDIF (${${LIB_TO_SEARCH}_SEARCH} MATCHES ${${TGT}} AND TARGET wxWidgets::${TGT})
200                                                 ENDFOREACH (TGT ${WX_COMPONENTS})
201                                         ENDIF (${LIB_TO_SEARCH}_SEARCH AND ${${LIB_TO_SEARCH}_SEARCH} MATCHES ${${COMPONENT}})
202                                 ENDIF ("${LIB}" MATCHES "^-l(.*)$")
203                         ENDFOREACH (LIB IN LISTS wxWidgets_LIBRARIES)
205                         SET (wxWidgets_${COMPONENT}_LIBRARY ${wxWidgets_${COMPONENT}_LIBRARY} CACHE STRING "Libs to use when linking to ${COMPONENT}" FORCE)
207                         MARK_AS_ADVANCED (wxWidgets_${COMPONENT_NAME}_LIBRARY
208                                 wxWidgets_${COMPONENT_NAME}_DEFINITIONS
209                         )
210                 ENDIF (WIN32)
212                 SET_TARGET_PROPERTIES (wxWidgets::${COMPONENT} PROPERTIES
213                         INTERFACE_COMPILE_DEFINITIONS "${wxWidgets_DEFINITIONS};$<$<CONFIG:Debug>:__WXDEBUG__>"
214                         INTERFACE_INCLUDE_DIRECTORIES "${wxWidgets_INCLUDE_DIRS}"
215                 )
217                 UNSET (wxWidgets_DEFINITIONS)
218         ENDFOREACH (COMPONENT ${WX_COMPONENTS})
220         IF (wxWidgets_VERSION_STRING VERSION_LESS 3.1.2)
221                 TARGET_LINK_LIBRARIES (wxWidgets::ADV
222                         INTERFACE wxWidgets::BASE
223                 )
224         ENDIF (wxWidgets_VERSION_STRING VERSION_LESS 3.1.2)
226         TARGET_LINK_LIBRARIES (wxWidgets::CORE
227                 INTERFACE wxWidgets::BASE
228         )
229         TARGET_LINK_LIBRARIES (wxWidgets::NET
230                 INTERFACE wxWidgets::BASE
231         )
233         SET (wxWidgets_INCLUDE_DIRS ${wxWidgets_INCLUDE_DIRS} CACHE STRING "Where to find wx header files" FORCE)
235         MARK_AS_ADVANCED (wxWidgets_INCLUDE_DIRS
236                 wxWidgets_BASE_DEFINITIONS
237         )
238 ENDIF (WX_COMPONENTS)
240 #IF (DOWNLOAD_AND_BUILD_DEPS AND NOT wxWidgets_FOUND AND NOT BUILT_WX)
241         #IF (WIN32)
242                 #EXTERNALPROJECT_ADD (WX
243                         #GIT_REPOSITORY https://github.com/wxWidgets/wxWidgets.git
244                         #GIT_TAG v3.1.2
245                         #GIT_PROGRESS TRUE
246                         #BUILD_IN_SOURCE FALSE
247                         #CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DwxUSE_IPV6=OFF -DwxBUILD_COMPATIBILITY=2.8
248                         #BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Debug
249                         #COMMAND ${CMAKE_COMMAND} --build . --config Release
250                         #INSTALL_COMMAND ${CMAKE_COMMAND} --install . --config Debug
251                         #COMMAND ${CMAKE_COMMAND} --install . --config Release
252                 #)
253         #ELSE (WIN32)
254                 #EXTERNALPROJECT_ADD (WX
255                         #GIT_REPOSITORY https://github.com/wxWidgets/wxWidgets.git
256                         #GIT_TAG v3.1.2
257                         #GIT_PROGRESS TRUE
258                         #BUILD_IN_SOURCE TRUE
259                         #CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
260                         #CONFIGURE_COMMAND ./autogen.sh
261                         #BUILD_COMMAND ./configure --enable-debug --prefix=<SOURCE_DIR>
262                         #INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM}
263                 #)
264         #ENDIF (WIN32)
267         #LIST (APPEND EXTERNAL_DEPS WX)
268         #SET (RECONF_COMMAND ${RECONF_COMMAND} -DBUILT_WX=TRUE)
269 #ENDIF (DOWNLOAD_AND_BUILD_DEPS AND NOT wxWidgets_FOUND AND NOT BUILT_WX)