CMake: generate build.cfg

This commit is contained in:
Maarten Bent 2021-06-17 23:27:38 +02:00
parent 980bba88aa
commit cd9a35b997
5 changed files with 123 additions and 6 deletions

39
build/cmake/build.cfg.in Normal file
View File

@ -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@

View File

@ -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})

View File

@ -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 "$<$<CONFIG:Debug>:d>")

View File

@ -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)

View File

@ -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