From e1e5169e4b55d45e5341684f29b91a0d572f8df5 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 4 Nov 2018 16:30:20 +0100 Subject: [PATCH] CMake: enable Direct2D graphics context by default Disable it when the d2d1.h header is not found. When using MSVC, match the behaviour of setup.h. --- build/cmake/init.cmake | 19 +++++++++++++++---- build/cmake/options.cmake | 4 ++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/build/cmake/init.cmake b/build/cmake/init.cmake index 740cfa17cd..292440380f 100644 --- a/build/cmake/init.cmake +++ b/build/cmake/init.cmake @@ -142,10 +142,6 @@ if(DEFINED wxUSE_OLE AND wxUSE_OLE) set(wxUSE_OLE_AUTOMATION ON) endif() -if(DEFINED wxUSE_GRAPHICS_DIRECT2D AND NOT wxUSE_GRAPHICS_CONTEXT) - set(wxUSE_GRAPHICS_DIRECT2D OFF) -endif() - if(wxUSE_OPENGL) set(wxUSE_GLCANVAS ON) endif() @@ -174,6 +170,21 @@ if(wxUSE_GUI) set(wxUSE_ENH_METAFILE ON) endif() + # Direct2D check + if(WIN32 AND wxUSE_GRAPHICS_DIRECT2D) + check_include_file(d2d1.h HAVE_D2D1_H) + if (NOT HAVE_D2D1_H) + wx_option_force_value(wxUSE_GRAPHICS_DIRECT2D OFF) + endif() + endif() + if(MSVC) # match setup.h + if(MSVC_VERSION LESS 1600) + wx_option_force_value(wxUSE_GRAPHICS_DIRECT2D OFF) + else() + wx_option_force_value(wxUSE_GRAPHICS_DIRECT2D ${wxUSE_GRAPHICS_CONTEXT}) + endif() + endif() + # WXQT checks if(WXQT) wx_option_force_value(wxUSE_WEBVIEW OFF) diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake index 0e2401a18c..6b03f2b068 100644 --- a/build/cmake/options.cmake +++ b/build/cmake/options.cmake @@ -208,8 +208,8 @@ if(APPLE) set(wxUSE_GRAPHICS_CONTEXT ON) else() wx_option(wxUSE_GRAPHICS_CONTEXT "use graphics context 2D drawing API") - if (WIN32 AND (NOT MSVC OR MSVC_VERSION LESS 1600)) - wx_option(wxUSE_GRAPHICS_DIRECT2D "enable Direct2D graphics context" OFF) + if(WIN32) + wx_option(wxUSE_GRAPHICS_DIRECT2D "enable Direct2D graphics context") endif() endif()