From 46ba9ca2f9930eeff21ef8e31fbb58ac4c3e2788 Mon Sep 17 00:00:00 2001 From: PB Date: Sat, 5 May 2018 10:16:08 +0200 Subject: [PATCH 1/2] Fix automatic linking with MSVC for monolithic builds MSVC users can simplify their projects by prepending $(WXWIN)\include\msvc to the compiler include directories, which results in automatic including the build-specific setup.h and linking all required wxWidgets and system libraries. This worked only for the default multilib builds but not for monolithic builds where wxWidgets libraries are created and named differently. This patch allows the users (by defining wxMONOLITHIC=1 in their project) to use it also for monolithic builds. --- include/msvc/wx/setup.h | 105 ++++++++++++++++++++++------------------ 1 file changed, 59 insertions(+), 46 deletions(-) diff --git a/include/msvc/wx/setup.h b/include/msvc/wx/setup.h index 588d34d9e2..9748ab0b0a 100644 --- a/include/msvc/wx/setup.h +++ b/include/msvc/wx/setup.h @@ -149,20 +149,27 @@ // special version for regex as it does have a Unicode version #define wx3RD_PARTY_LIB_NAME_U(name) "wx" name wxSUFFIX_STR -#pragma comment(lib, wxWX_LIB_NAME("base", "")) +#if defined(wxMONOLITHIC) && wxMONOLITHIC == 1 + #pragma comment(lib, wxWX_LIB_NAME("msw", "")) +#else + #pragma comment(lib, wxWX_LIB_NAME("base", "")) -#ifndef wxNO_NET_LIB - #ifndef WXUSINGDLL - #pragma comment(lib, "wsock32") + #ifndef wxNO_NET_LIB + #pragma comment(lib, wxBASE_LIB_NAME("net")) #endif - #pragma comment(lib, wxBASE_LIB_NAME("net")) -#endif -#if wxUSE_XML && !defined(wxNO_XML_LIB) - #pragma comment(lib, wxBASE_LIB_NAME("xml")) - #if !defined(wxNO_EXPAT_LIB) && !defined(WXUSINGDLL) - #pragma comment(lib, wx3RD_PARTY_LIB_NAME("expat")) + #if wxUSE_XML && !defined(wxNO_XML_LIB) + #pragma comment(lib, wxBASE_LIB_NAME("xml")) #endif +#endif // defined(wxMONOLITHIC) && wxMONOLITHIC == 1 + +#if !defined(wxNO_NET_LIB) && !defined(WXUSINGDLL) + #pragma comment(lib, "wsock32") #endif + +#if wxUSE_XML && !defined(wxNO_XML_LIB) && !defined(wxNO_EXPAT_LIB) && !defined(WXUSINGDLL) + #pragma comment(lib, wx3RD_PARTY_LIB_NAME("expat")) +#endif + #if wxUSE_REGEX && !defined(wxNO_REGEX_LIB) && !defined(WXUSINGDLL) #pragma comment(lib, wx3RD_PARTY_LIB_NAME_U("regex")) #endif @@ -181,48 +188,54 @@ #pragma comment(lib, wx3RD_PARTY_LIB_NAME("tiff")) #endif - #pragma comment(lib, wxTOOLKIT_LIB_NAME("core")) + #if !defined(wxMONOLITHIC) || wxMONOLITHIC == 0 - #ifndef wxNO_ADV_LIB - #pragma comment(lib, wxTOOLKIT_LIB_NAME("adv")) - #endif + #pragma comment(lib, wxTOOLKIT_LIB_NAME("core")) + + #ifndef wxNO_ADV_LIB + #pragma comment(lib, wxTOOLKIT_LIB_NAME("adv")) + #endif + + #if wxUSE_HTML && !defined(wxNO_HTML_LIB) + #pragma comment(lib, wxTOOLKIT_LIB_NAME("html")) + #endif + #if wxUSE_DEBUGREPORT && !defined(wxNO_QA_LIB) + #pragma comment(lib, wxTOOLKIT_LIB_NAME("qa")) + #endif + #if wxUSE_XRC && !defined(wxNO_XRC_LIB) + #pragma comment(lib, wxTOOLKIT_LIB_NAME("xrc")) + #endif + #if wxUSE_AUI && !defined(wxNO_AUI_LIB) + #pragma comment(lib, wxTOOLKIT_LIB_NAME("aui")) + #endif + #if wxUSE_PROPGRID && !defined(wxNO_PROPGRID_LIB) + #pragma comment(lib, wxTOOLKIT_LIB_NAME("propgrid")) + #endif + #if wxUSE_RIBBON && !defined(wxNO_RIBBON_LIB) + #pragma comment(lib, wxTOOLKIT_LIB_NAME("ribbon")) + #endif + #if wxUSE_RICHTEXT && !defined(wxNO_RICHTEXT_LIB) + #pragma comment(lib, wxTOOLKIT_LIB_NAME("richtext")) + #endif + #if wxUSE_MEDIACTRL && !defined(wxNO_MEDIA_LIB) + #pragma comment(lib, wxTOOLKIT_LIB_NAME("media")) + #endif + #if wxUSE_STC && !defined(wxNO_STC_LIB) + #pragma comment(lib, wxTOOLKIT_LIB_NAME("stc")) + #endif + #if wxUSE_WEBVIEW && !defined(wxNO_WEBVIEW_LIB) + #pragma comment(lib, wxTOOLKIT_LIB_NAME("webview")) + #endif + #endif // !defined(wxMONOLITHIC) || wxMONOLITHIC == 0 - #if wxUSE_HTML && !defined(wxNO_HTML_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("html")) - #endif #if wxUSE_GLCANVAS && !defined(wxNO_GL_LIB) #pragma comment(lib, wxTOOLKIT_LIB_NAME("gl")) #endif - #if wxUSE_DEBUGREPORT && !defined(wxNO_QA_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("qa")) - #endif - #if wxUSE_XRC && !defined(wxNO_XRC_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("xrc")) - #endif - #if wxUSE_AUI && !defined(wxNO_AUI_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("aui")) - #endif - #if wxUSE_PROPGRID && !defined(wxNO_PROPGRID_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("propgrid")) - #endif - #if wxUSE_RIBBON && !defined(wxNO_RIBBON_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("ribbon")) - #endif - #if wxUSE_RICHTEXT && !defined(wxNO_RICHTEXT_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("richtext")) - #endif - #if wxUSE_MEDIACTRL && !defined(wxNO_MEDIA_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("media")) - #endif - #if wxUSE_STC && !defined(wxNO_STC_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("stc")) - #ifndef WXUSINGDLL - #pragma comment(lib, wx3RD_PARTY_LIB_NAME("scintilla")) - #endif - #endif - #if wxUSE_WEBVIEW && !defined(wxNO_WEBVIEW_LIB) - #pragma comment(lib, wxTOOLKIT_LIB_NAME("webview")) + + #if wxUSE_STC && !defined(wxNO_STC_LIB) && !defined(WXUSINGDLL) + #pragma comment(lib, wx3RD_PARTY_LIB_NAME("scintilla")) #endif + #endif // wxUSE_GUI From 30c2bbf0810d92dcccd4a4790b4d36a2fb760514 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 31 May 2018 01:21:20 +0200 Subject: [PATCH 2/2] Factor out WXUSINGDLL check in MSVC-specific wx/setup.h Don't repeat the same check for !defined(WXUSINGDLL) many times. No real changes, this is just a simplification (which should be viewed with "git diff -w --color-words" to see how little has really changed). --- include/msvc/wx/setup.h | 54 ++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/include/msvc/wx/setup.h b/include/msvc/wx/setup.h index 9748ab0b0a..8a7c0c488d 100644 --- a/include/msvc/wx/setup.h +++ b/include/msvc/wx/setup.h @@ -162,31 +162,39 @@ #endif #endif // defined(wxMONOLITHIC) && wxMONOLITHIC == 1 -#if !defined(wxNO_NET_LIB) && !defined(WXUSINGDLL) - #pragma comment(lib, "wsock32") -#endif +#if !defined(WXUSINGDLL) + #if !defined(wxNO_NET_LIB) + #pragma comment(lib, "wsock32") + #endif -#if wxUSE_XML && !defined(wxNO_XML_LIB) && !defined(wxNO_EXPAT_LIB) && !defined(WXUSINGDLL) - #pragma comment(lib, wx3RD_PARTY_LIB_NAME("expat")) -#endif + #if wxUSE_XML && !defined(wxNO_XML_LIB) && !defined(wxNO_EXPAT_LIB) + #pragma comment(lib, wx3RD_PARTY_LIB_NAME("expat")) + #endif -#if wxUSE_REGEX && !defined(wxNO_REGEX_LIB) && !defined(WXUSINGDLL) - #pragma comment(lib, wx3RD_PARTY_LIB_NAME_U("regex")) -#endif -#if wxUSE_ZLIB && !defined(wxNO_ZLIB_LIB) && !defined(WXUSINGDLL) - #pragma comment(lib, wx3RD_PARTY_LIB_NAME("zlib")) -#endif + #if wxUSE_REGEX && !defined(wxNO_REGEX_LIB) + #pragma comment(lib, wx3RD_PARTY_LIB_NAME_U("regex")) + #endif + #if wxUSE_ZLIB && !defined(wxNO_ZLIB_LIB) + #pragma comment(lib, wx3RD_PARTY_LIB_NAME("zlib")) + #endif +#endif // !defined(WXUSINGDLL) #if wxUSE_GUI - #if wxUSE_LIBJPEG && !defined(wxNO_JPEG_LIB) && !defined(WXUSINGDLL) - #pragma comment(lib, wx3RD_PARTY_LIB_NAME("jpeg")) - #endif - #if wxUSE_LIBPNG && !defined(wxNO_PNG_LIB) && !defined(WXUSINGDLL) - #pragma comment(lib, wx3RD_PARTY_LIB_NAME("png")) - #endif - #if wxUSE_LIBTIFF && !defined(wxNO_TIFF_LIB) && !defined(WXUSINGDLL) - #pragma comment(lib, wx3RD_PARTY_LIB_NAME("tiff")) - #endif + #if !defined(WXUSINGDLL) + #if wxUSE_LIBJPEG && !defined(wxNO_JPEG_LIB) + #pragma comment(lib, wx3RD_PARTY_LIB_NAME("jpeg")) + #endif + #if wxUSE_LIBPNG && !defined(wxNO_PNG_LIB) + #pragma comment(lib, wx3RD_PARTY_LIB_NAME("png")) + #endif + #if wxUSE_LIBTIFF && !defined(wxNO_TIFF_LIB) + #pragma comment(lib, wx3RD_PARTY_LIB_NAME("tiff")) + #endif + #if wxUSE_STC && !defined(wxNO_STC_LIB) + #pragma comment(lib, wx3RD_PARTY_LIB_NAME("scintilla")) + #endif + #endif // !defined(WXUSINGDLL) + #if !defined(wxMONOLITHIC) || wxMONOLITHIC == 0 @@ -232,10 +240,6 @@ #pragma comment(lib, wxTOOLKIT_LIB_NAME("gl")) #endif - #if wxUSE_STC && !defined(wxNO_STC_LIB) && !defined(WXUSINGDLL) - #pragma comment(lib, wx3RD_PARTY_LIB_NAME("scintilla")) - #endif - #endif // wxUSE_GUI