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.
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
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)
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
44 #EXCLUDE_FROM_ALL TRUE
47 #EXTERNALPROJECT_GET_PROPERTY (WX SOURCE_DIR)
50 #SET (wxWidgets_ROOT_DIR ${CMAKE_INSTALL_PREFIX})
54 #COMMAND ${CMAKE_MAKE_PROGRAM} clean
55 #WORKING_DIRECTORY ${SOURCE_DIR}
59 #COMMAND ./configure --prefix=${CMAKE_INSTALL_PREFIX}
60 #WORKING_DIRECTORY ${SOURCE_DIR}
64 #COMMAND ${CMAKE_MAKE_PROGRAM} install
65 #WORKING_DIRECTORY ${SOURCE_DIR}
69 #SET (wxWidgets_CONFIG_EXECUTABLE ${SOURCE_DIR}/wx-config CACHE FILEPATH "Location of wxWidgets library configuration provider binary (wx-config)." FORCE)
73 #IF (NOT DOWNLOAD_AND_BUILD_DEPS)
74 SET (wx_REQUIRED "REQUIRED")
75 #ELSE (NOT DOWNLOAD_AND_BUILD_DEPS)
77 #ENDIF (NOT DOWNLOAD_AND_BUILD_DEPS)
81 LIST (APPEND WX_COMPONENTS BASE)
83 ADD_LIBRARY (wxWidgets::BASE
91 LIST (APPEND WX_COMPONENTS ADV)
93 ADD_LIBRARY (wxWidgets::ADV
101 LIST (APPEND WX_COMPONENTS CORE)
103 ADD_LIBRARY (wxWidgets::CORE
111 LIST (APPEND WX_COMPONENTS NET)
113 ADD_LIBRARY (wxWidgets::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)
127 ENDIF (wxWidgets_BASE_DEFINITIONS)
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")
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))
141 SET_PROPERTY (TARGET wxWidgets::${COMPONENT}
142 PROPERTY IMPORTED_LOCATION_RELEASE ${WX_${${COMPONENT}}}
145 SET_PROPERTY (TARGET wxWidgets::${COMPONENT}
146 PROPERTY IMPORTED_LOCATION_DEBUG ${WX_${${COMPONENT}}d}
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
162 ENDIF (NOT UNICODE_SUPPORT)
164 UNSET (CMAKE_REQUIRED_INCLUDES)
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
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
184 PATHS ${wxWidgets_LIBRARY_DIRS}
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}
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}
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
212 SET_TARGET_PROPERTIES (wxWidgets::${COMPONENT} PROPERTIES
213 INTERFACE_COMPILE_DEFINITIONS "${wxWidgets_DEFINITIONS};$<$<CONFIG:Debug>:__WXDEBUG__>"
214 INTERFACE_INCLUDE_DIRECTORIES "${wxWidgets_INCLUDE_DIRS}"
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
224 ENDIF (wxWidgets_VERSION_STRING VERSION_LESS 3.1.2)
226 TARGET_LINK_LIBRARIES (wxWidgets::CORE
227 INTERFACE wxWidgets::BASE
229 TARGET_LINK_LIBRARIES (wxWidgets::NET
230 INTERFACE wxWidgets::BASE
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
238 ENDIF (WX_COMPONENTS)
240 #IF (DOWNLOAD_AND_BUILD_DEPS AND NOT wxWidgets_FOUND AND NOT BUILT_WX)
242 #EXTERNALPROJECT_ADD (WX
243 #GIT_REPOSITORY https://github.com/wxWidgets/wxWidgets.git
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
254 #EXTERNALPROJECT_ADD (WX
255 #GIT_REPOSITORY https://github.com/wxWidgets/wxWidgets.git
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}
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)