2016-09-25 16:19:39 -04:00
|
|
|
#############################################################################
|
|
|
|
# Name: build/cmake/toolkit.cmake
|
|
|
|
# Purpose: CMake platform toolkit options
|
|
|
|
# Author: Tobias Taschner
|
|
|
|
# Created: 2016-10-03
|
|
|
|
# Copyright: (c) 2016 wxWidgets development team
|
|
|
|
# Licence: wxWindows licence
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
# Options required for toolkit selection/detection
|
|
|
|
wx_option(wxUSE_GUI "Use GUI" ON)
|
|
|
|
|
|
|
|
if(CMAKE_OSX_SYSROOT MATCHES iphoneos)
|
|
|
|
set(IPHONE ON)
|
2020-06-18 14:18:45 -04:00
|
|
|
|
|
|
|
# workaround a bug where try_compile (and functions using it,
|
|
|
|
# like find_package, check_c_source_compiles) fails
|
|
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
set(wxDEFAULT_TOOLKIT msw)
|
|
|
|
set(wxTOOLKIT_OPTIONS msw gtk2 gtk3 qt)
|
|
|
|
set(wxPLATFORM WIN32)
|
|
|
|
elseif(APPLE AND IPHONE)
|
|
|
|
set(wxDEFAULT_TOOLKIT osx_iphone)
|
|
|
|
set(wxTOOLKIT_OPTIONS osx_iphone)
|
|
|
|
set(wxPLATFORM OSX)
|
|
|
|
elseif(APPLE)
|
|
|
|
set(wxDEFAULT_TOOLKIT osx_cocoa)
|
2019-11-08 01:12:26 -05:00
|
|
|
set(wxTOOLKIT_OPTIONS osx_cocoa gtk2 gtk3 gtk4 qt)
|
2016-09-25 16:19:39 -04:00
|
|
|
set(wxPLATFORM OSX)
|
|
|
|
elseif(UNIX)
|
2020-04-26 16:01:11 -04:00
|
|
|
set(wxDEFAULT_TOOLKIT gtk3)
|
2019-11-08 01:12:26 -05:00
|
|
|
set(wxTOOLKIT_OPTIONS gtk2 gtk3 gtk4 motif qt)
|
2016-09-25 16:19:39 -04:00
|
|
|
set(wxPLATFORM UNIX)
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unsupported platform")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
wx_option(wxBUILD_TOOLKIT "Toolkit used by wxWidgets" ${wxDEFAULT_TOOLKIT}
|
|
|
|
STRINGS ${wxTOOLKIT_OPTIONS})
|
|
|
|
# TODO: set to univ for universal build
|
|
|
|
set(wxBUILD_WIDGETSET "")
|
|
|
|
|
|
|
|
# Create shortcut variable for easy toolkit tests
|
|
|
|
string(TOUPPER ${wxBUILD_TOOLKIT} toolkit_upper)
|
|
|
|
set(WX${toolkit_upper} ON)
|
|
|
|
if(wxBUILD_TOOLKIT MATCHES "^gtk*")
|
|
|
|
set(WXGTK ON)
|
|
|
|
elseif(wxBUILD_TOOLKIT MATCHES "^osx*")
|
|
|
|
set(WXOSX ON)
|
2018-09-25 13:41:17 -04:00
|
|
|
elseif(wxBUILD_TOOLKIT MATCHES "qt")
|
|
|
|
set(WXQT ON)
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(wxTOOLKIT_DEFINITIONS __WX${toolkit_upper}__)
|
|
|
|
|
2018-01-27 07:39:45 -05:00
|
|
|
if(NOT wxUSE_GUI)
|
|
|
|
set(wxBUILD_TOOLKIT "base")
|
|
|
|
string(TOUPPER ${wxBUILD_TOOLKIT} toolkit_upper)
|
|
|
|
set(WX${toolkit_upper} ON)
|
|
|
|
set(wxTOOLKIT_DEFINITIONS __WX${toolkit_upper}__)
|
|
|
|
endif()
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
# Initialize toolkit variables
|
|
|
|
if(wxUSE_GUI)
|
|
|
|
set(wxTOOLKIT_INCLUDE_DIRS)
|
|
|
|
set(wxTOOLKIT_LIBRARIES)
|
|
|
|
set(wxTOOLKIT_VERSION)
|
|
|
|
|
|
|
|
if(UNIX AND NOT APPLE AND NOT WIN32)
|
|
|
|
find_package(X11 REQUIRED)
|
|
|
|
list(APPEND wxTOOLKIT_INCLUDE_DIRS ${X11_INCLUDE_DIR})
|
|
|
|
list(APPEND wxTOOLKIT_LIBRARIES ${X11_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2018-01-27 07:39:45 -05:00
|
|
|
if(WXGTK)
|
2019-11-08 01:12:26 -05:00
|
|
|
if(WXGTK4)
|
|
|
|
set(gtk_lib GTK4)
|
|
|
|
elseif(WXGTK3)
|
2016-09-25 16:19:39 -04:00
|
|
|
set(gtk_lib GTK3)
|
|
|
|
elseif(WXGTK2)
|
|
|
|
set(gtk_lib GTK2)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
find_package(${gtk_lib} REQUIRED)
|
|
|
|
list(APPEND wxTOOLKIT_INCLUDE_DIRS ${${gtk_lib}_INCLUDE_DIRS})
|
|
|
|
list(APPEND wxTOOLKIT_LIBRARIES ${${gtk_lib}_LIBRARIES})
|
|
|
|
list(APPEND wxTOOLKIT_DEFINITIONS ${${gtk_lib}_DEFINITIONS})
|
|
|
|
list(APPEND wxTOOLKIT_DEFINITIONS __WXGTK__)
|
|
|
|
set(wxTOOLKIT_VERSION ${${gtk_lib}_VERSION})
|
2018-02-28 18:16:06 -05:00
|
|
|
|
|
|
|
if(WIN32 AND MSVC)
|
|
|
|
if(WXGTK4)
|
|
|
|
list(APPEND wxTOOLKIT_LIBRARIES
|
|
|
|
libgtk-4.dll.a
|
|
|
|
libgdk-4.dll.a
|
|
|
|
)
|
|
|
|
elseif(WXGTK3)
|
|
|
|
list(APPEND wxTOOLKIT_LIBRARIES
|
|
|
|
libgtk-3.dll.a
|
|
|
|
libgdk-3.dll.a
|
|
|
|
)
|
|
|
|
elseif(WXGTK2)
|
|
|
|
list(APPEND wxTOOLKIT_LIBRARIES
|
|
|
|
gtk-win32-2.0
|
|
|
|
gdk-win32-2.0
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
list(APPEND wxTOOLKIT_LIBRARIES
|
|
|
|
gio-2.0
|
|
|
|
pangocairo-1.0
|
|
|
|
gdk_pixbuf-2.0
|
|
|
|
cairo
|
|
|
|
pango-1.0
|
|
|
|
gobject-2.0
|
|
|
|
gthread-2.0
|
|
|
|
glib-2.0
|
|
|
|
)
|
|
|
|
endif()
|
2016-09-25 16:19:39 -04:00
|
|
|
endif()
|
|
|
|
|
2018-09-25 13:41:17 -04:00
|
|
|
if(WXQT)
|
|
|
|
set(QT_COMPONENTS Core Widgets Gui OpenGL Test)
|
|
|
|
foreach(QT_COMPONENT ${QT_COMPONENTS})
|
|
|
|
find_package(Qt5 COMPONENTS ${QT_COMPONENT} REQUIRED)
|
|
|
|
list(APPEND wxTOOLKIT_INCLUDE_DIRS ${Qt5${QT_COMPONENT}_INCLUDE_DIRS})
|
|
|
|
list(APPEND wxTOOLKIT_LIBRARIES ${Qt5${QT_COMPONENT}_LIBRARIES})
|
|
|
|
list(APPEND wxTOOLKIT_DEFINITIONS ${Qt5${QT_COMPONENT}_COMPILE_DEFINITIONS})
|
|
|
|
endforeach()
|
|
|
|
set(wxTOOLKIT_VERSION ${Qt5Core_VERSION})
|
|
|
|
endif()
|
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
if(APPLE)
|
|
|
|
list(APPEND wxTOOLKIT_DEFINITIONS __WXMAC__ __WXOSX__)
|
|
|
|
endif()
|
2018-09-25 13:41:17 -04:00
|
|
|
|
2016-09-25 16:19:39 -04:00
|
|
|
endif() # wxUSE_GUI
|