From cd9a35b9977e3a4b676f8c1f78ba5c7d1d5f3336 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Thu, 17 Jun 2021 23:27:38 +0200 Subject: [PATCH] CMake: generate build.cfg --- build/cmake/build.cfg.in | 39 ++++++++++++++++++++ build/cmake/build_cfg.cmake | 71 +++++++++++++++++++++++++++++++++++++ build/cmake/init.cmake | 3 ++ build/cmake/main.cmake | 4 +++ build/cmake/toolkit.cmake | 12 +++---- 5 files changed, 123 insertions(+), 6 deletions(-) create mode 100644 build/cmake/build.cfg.in create mode 100644 build/cmake/build_cfg.cmake diff --git a/build/cmake/build.cfg.in b/build/cmake/build.cfg.in new file mode 100644 index 0000000000..ccec3108fa --- /dev/null +++ b/build/cmake/build.cfg.in @@ -0,0 +1,39 @@ +WXVER_MAJOR=@wxMAJOR_VERSION@ +WXVER_MINOR=@wxMINOR_VERSION@ +WXVER_RELEASE=@wxRELEASE_NUMBER@ +BUILD=@wxBUILD@ +MONOLITHIC=@wxBUILD_MONOLITHIC_bf@ +SHARED=@wxBUILD_SHARED_bf@ +UNICODE=@wxUSE_UNICODE_bf@ +TOOLKIT=@wxBUILD_TOOLKIT_UPPER@ +TOOLKIT_VERSION=@wxTOOLKIT_VERSION@ +WXUNIV=@wxUNIV@ +CFG=@wxCFG@ +VENDOR=@wxBUILD_VENDOR@ +OFFICIAL_BUILD=@wxOFFICIAL_BUILD@ +DEBUG_FLAG=@wxDEBUG_FLAG@ +DEBUG_INFO=@wxDEBUG_INFO@ +RUNTIME_LIBS=@wxRUNTIME_LIBS@ +USE_EXCEPTIONS=@wxUSE_EXCEPTIONS_bf@ +USE_RTTI=@wxUSE_RTTI@ +USE_THREADS=@wxUSE_THREADS_bf@ +USE_AUI=@wxUSE_AUI_bf@ +USE_GUI=@wxUSE_GUI_bf@ +USE_HTML=@wxUSE_HTML_bf@ +USE_MEDIA=@wxUSE_MEDIA_bf@ +USE_OPENGL=@wxUSE_OPENGL_bf@ +USE_QA=@wxUSE_DEBUGREPORT_bf@ +USE_PROPGRID=@wxUSE_PROPGRID_bf@ +USE_RIBBON=@wxUSE_RIBBON_bf@ +USE_RICHTEXT=@wxUSE_RICHTEXT_bf@ +USE_STC=@wxUSE_STC_bf@ +USE_WEBVIEW=@wxUSE_WEBVIEW_bf@ +USE_XRC=@wxUSE_XRC_bf@ +COMPILER=@wxCOMPILER_PREFIX@ +COMPILER_VERSION=@wxCOMPILER_VERSION@ +CC=@wxCC@ +CXX=@wxCXX@ +CFLAGS=@wxCFLAGS@ +CPPFLAGS=@wxCPPFLAGS@ +CXXFLAGS=@wxCXXFLAGS@ +LDFLAGS=@wxLDFLAGS@ diff --git a/build/cmake/build_cfg.cmake b/build/cmake/build_cfg.cmake new file mode 100644 index 0000000000..9de219c29c --- /dev/null +++ b/build/cmake/build_cfg.cmake @@ -0,0 +1,71 @@ +############################################################################# +# Name: build/cmake/build_cfg.cmake +# Purpose: Create and configure build.cfg +# Author: Maarten Bent +# Created: 2021-06-17 +# Copyright: (c) 2021 wxWidgets development team +# Licence: wxWindows licence +############################################################################# + +macro(wx_buildfile_var var) + # convert TRUE/FALSE to 1/0, add _bf suffix for use in build.cfg + if(${var}) + set(${var}_bf 1) + else() + set(${var}_bf 0) + endif() +endmacro() + +wx_buildfile_var(wxBUILD_MONOLITHIC) +wx_buildfile_var(wxBUILD_SHARED) +wx_buildfile_var(wxUSE_UNICODE) +wx_buildfile_var(wxUSE_EXCEPTIONS) +wx_buildfile_var(wxUSE_THREADS) +wx_buildfile_var(wxUSE_AUI) +wx_buildfile_var(wxUSE_GUI) +wx_buildfile_var(wxUSE_HTML) +wx_buildfile_var(wxUSE_MEDIACTRL) +wx_buildfile_var(wxUSE_OPENGL) +wx_buildfile_var(wxUSE_DEBUGREPORT) +wx_buildfile_var(wxUSE_PROPGRID) +wx_buildfile_var(wxUSE_RIBBON) +wx_buildfile_var(wxUSE_RICHTEXT) +wx_buildfile_var(wxUSE_STC) +wx_buildfile_var(wxUSE_WEBVIEW) +wx_buildfile_var(wxUSE_XRC) + +if(wxUSE_NO_RTTI) + set(wxUSE_RTTI 0) +else() + set(wxUSE_RTTI 1) +endif() +if(wxBUILD_STRIPPED_RELEASE) + set(wxDEBUG_INFO 0) +else() + set(wxDEBUG_INFO 1) +endif() +if(wxBUILD_USE_STATIC_RUNTIME) + set(wxRUNTIME_LIBS "static") +else() + set(wxRUNTIME_LIBS "dynamic") +endif() + +set(wxDEBUG_FLAG ${wxBUILD_DEBUG_LEVEL}) +get_filename_component(wxCC ${CMAKE_C_COMPILER} NAME_WE) +get_filename_component(wxCXX ${CMAKE_CXX_COMPILER} NAME_WE) +set(wxCFLAGS ${CMAKE_C_FLAGS}) +set(wxCPPFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}") +set(wxCXXFLAGS ${CMAKE_CXX_FLAGS}) +set(wxLDFLAGS ${CMAKE_EXE_LINKER_FLAGS}) + +# These are currently not used by CMake +set(wxCFG "") +set(wxUNIV 0) +set(wxOFFICIAL_BUILD 0) +set(wxCOMPILER_VERSION "") + +set(wxBUILD "release") +configure_file(build/cmake/build.cfg.in ${wxBUILD_FILE}) + +set(wxBUILD "debug") +configure_file(build/cmake/build.cfg.in ${wxBUILD_FILE_DEBUG}) diff --git a/build/cmake/init.cmake b/build/cmake/init.cmake index 41d3da4a81..e1426afd42 100644 --- a/build/cmake/init.cmake +++ b/build/cmake/init.cmake @@ -183,6 +183,9 @@ else() endif() set(wxSETUP_HEADER_FILE ${wxSETUP_HEADER_PATH}/wx/setup.h) +set(wxBUILD_FILE ${wxSETUP_HEADER_PATH}/build.cfg) +set(wxBUILD_FILE_DEBUG ${wxSETUP_HEADER_PATH}d/build.cfg) + if(DEFINED wxSETUP_HEADER_FILE_DEBUG) # Append configuration specific suffix to setup header path wx_string_append(wxSETUP_HEADER_PATH "$<$:d>") diff --git a/build/cmake/main.cmake b/build/cmake/main.cmake index 5707352874..4a871a7ed8 100644 --- a/build/cmake/main.cmake +++ b/build/cmake/main.cmake @@ -41,6 +41,10 @@ if(NOT wxBUILD_CUSTOM_SETUP_HEADER_PATH) include(build/cmake/setup.cmake) endif() +if(WIN32_MSVC_NAMING) + include(build/cmake/build_cfg.cmake) +endif() + if(NOT MSVC) # Write wx-config include(build/cmake/config.cmake) diff --git a/build/cmake/toolkit.cmake b/build/cmake/toolkit.cmake index bcbbd75491..d61a58e72e 100644 --- a/build/cmake/toolkit.cmake +++ b/build/cmake/toolkit.cmake @@ -44,8 +44,8 @@ wx_option(wxBUILD_TOOLKIT "Toolkit used by wxWidgets" ${wxDEFAULT_TOOLKIT} set(wxBUILD_WIDGETSET "") # Create shortcut variable for easy toolkit tests -string(TOUPPER ${wxBUILD_TOOLKIT} toolkit_upper) -set(WX${toolkit_upper} ON) +string(TOUPPER ${wxBUILD_TOOLKIT} wxBUILD_TOOLKIT_UPPER) +set(WX${wxBUILD_TOOLKIT_UPPER} ON) if(wxBUILD_TOOLKIT MATCHES "^gtk*") set(WXGTK ON) elseif(wxBUILD_TOOLKIT MATCHES "^osx*") @@ -54,13 +54,13 @@ elseif(wxBUILD_TOOLKIT MATCHES "qt") set(WXQT ON) endif() -set(wxTOOLKIT_DEFINITIONS __WX${toolkit_upper}__) +set(wxTOOLKIT_DEFINITIONS __WX${wxBUILD_TOOLKIT_UPPER}__) 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}__) + string(TOUPPER ${wxBUILD_TOOLKIT} wxBUILD_TOOLKIT_UPPER) + set(WX${wxBUILD_TOOLKIT_UPPER} ON) + set(wxTOOLKIT_DEFINITIONS __WX${wxBUILD_TOOLKIT_UPPER}__) endif() # Initialize toolkit variables