From 19b0bae5b25323eff90e1fb6f049058ad697c705 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Thu, 29 Feb 2024 14:10:14 +0300 Subject: [PATCH] cmake: rework styles building - fix several styles-related FTBFS when disabling a style - use separated flags for BUILD_STULE and WITH_STYLE_ALL - add several convenience macros Signed-off-by: Alexander Golubev --- CMakeLists.txt | 21 +++++++------ TQtMacros.cmake | 16 ++++++++++ src/styles/CMakeLists.txt | 65 +++++++++++++++++---------------------- 3 files changed, 55 insertions(+), 47 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d858e2f9..82cfe3a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,18 +123,19 @@ option( WITH_MODULE_SQL "Build the SQL module" ${WITH_MODULE_AL ##### user requested styles: -## Motif style is mandatory for CDE, MotifPlus and SGI builds -## Windows style is mandatory for Platinum and Interlace (experimental, OFF by default) builds - -option( WITH_STYLE_ALL "Build tqt3 styles" ${WITH_MODULE_STYLES} ) -option( WITH_STYLE_MOTIF "Build Motif style" ${WITH_STYLE_ALL} ) -option( WITH_STYLE_CDE "Build CDE style" ${WITH_STYLE_ALL} ) -option( WITH_STYLE_MOTIFPLUS "Build Motif plus style" ${WITH_STYLE_ALL} ) -option( WITH_STYLE_SGI "Build SGI style" ${WITH_STYLE_ALL} ) -option( WITH_STYLE_WINDOWS "Build Windows style" ${WITH_STYLE_ALL} ) -option( WITH_STYLE_PLATINIUM "Build platinium style" ${WITH_STYLE_ALL} ) +option( WITH_STYLE_ALL "Build all style" ${WITH_MODULE_STYLES} ) +option( WITH_STYLE_MOTIF "Build Motif style" ${WITH_STYLES_ALL} ) +option( WITH_STYLE_WINDOWS "Build Windows style" ${WITH_STYLES_ALL} ) +## Depend upon WITH_MOTIF_STYLE +option( WITH_STYLE_CDE "Build CDE style" ${WITH_STYLES_ALL} ) +option( WITH_STYLE_MOTIFPLUS "Build Motif plus style" ${WITH_STYLES_ALL} ) +option( WITH_STYLE_SGI "Build SGI style" ${WITH_STYLES_ALL} ) +## Depend upon WITH_WINDOWS_STYLE +option( WITH_STYLE_COMPACT "Build compact style" ${WITH_STYLES_ALL} ) +option( WITH_STYLE_PLATINUM "Build platinium style" ${WITH_STYLES_ALL} ) option( WITH_STYLE_INTERLACE "Build interlace style" OFF ) +## NOTE: Interlace is OFF by default due to it being experimental ##### user requested sql modules diff --git a/TQtMacros.cmake b/TQtMacros.cmake index c9781ef7..9cd48750 100644 --- a/TQtMacros.cmake +++ b/TQtMacros.cmake @@ -6,6 +6,21 @@ include( TDEMacros ) +################################################# +##### +##### tqt_requires +##### +##### Asserts that if opt1 is set opt2 is set also +##### +##### Syntax: +##### tqt_requires( opt1 opt2 ) + +macro( tqt_requires _opt1 _opt2 ) + if( ${_opt1} AND NOT ${_opt2} ) + tde_message_fatal( "${_opt1}=ON requires ${_opt2}=ON to build" ) + endif( ) +endmacro( tqt_requires ) + ################################################# ##### @@ -113,6 +128,7 @@ endmacro( tqt_install_includes ) ##### ##### Syntax: ##### tqt_header_for_source ( header_list source [source ...] ) + macro( tqt_header_for_source _include_out ) foreach( _src ${ARGN} ) # As for now tqt has an "nt" prefix before filenames, so in order to handle all the casses diff --git a/src/styles/CMakeLists.txt b/src/styles/CMakeLists.txt index bee32d5a..2b5f7fec 100644 --- a/src/styles/CMakeLists.txt +++ b/src/styles/CMakeLists.txt @@ -13,52 +13,43 @@ link_directories() ##### styles (static) set( target styles ) -set( _SRC_ qcdestyle.cpp - qcommonstyle.cpp - qcompactstyle.cpp - qinterlacestyle.cpp - qmotifplusstyle.cpp - qmotifstyle.cpp - qplatinumstyle.cpp - qsgistyle.cpp - qstylefactory.cpp +set( _SRC_ qcommonstyle.cpp qstyleplugin.cpp - qwindowsstyle.cpp + qstylefactory.cpp ) -set( _disabled_styles "" ) -list( APPEND _disabled_styles +set( _STYLE_MOTIF_SRC_ qmotifstyle.cpp ) +set( _STYLE_WINDOWS_SRC_ qwindowsstyle.cpp ) +set( _STYLE_CDE_SRC_ qcdestyle.cpp ) +set( _STYLE_MOTIFPLUS_SRC_ qmotifplusstyle.cpp ) +set( _STYLE_SGI_SRC_ qsgistyle.cpp ) +set( _STYLE_COMPACT_SRC_ qcompactstyle.cpp ) +set( _STYLE_INTERLACE_SRC_ qinterlacestyle.cpp ) +set( _STYLE_PLATINUM_SRC_ qplatinumstyle.cpp ) + +# check style dependencies +tqt_requires( WITH_STYLE_CDE WITH_STYLE_MOTIF ) +tqt_requires( WITH_STYLE_MOTIFPLUS WITH_STYLE_MOTIF ) +tqt_requires( WITH_STYLE_SGI WITH_STYLE_MOTIF ) +tqt_requires( WITH_STYLE_INTERLACE WITH_STYLE_WINDOWS ) +tqt_requires( WITH_STYLE_PLATINUM WITH_STYLE_WINDOWS ) +tqt_requires( WITH_STYLE_COMPACT WITH_STYLE_WINDOWS ) + +# styles unsupported on X11 +set ( _disabled_styles TQT_NO_STYLE_WINDOWSXP TQT_NO_STYLE_AQUA TQT_NO_STYLE_POCKETPC TQT_NO_STYLE_MAC ) -if( WITH_STYLE_WINDOWS ) - if( NOT WITH_STYLE_INTERLACE ) - list( APPEND _disabled_styles TQT_NO_STYLE_INTERLACE ) - endif() - if( NOT WITH_STYLE_PLATINIUM ) - list( APPEND _disabled_styles TQT_NO_STYLE_PLATINUM ) - endif() - else() - tde_message_fatal( "Windows style is required for this build" ) -endif( WITH_STYLE_WINDOWS ) - -if( WITH_STYLE_MOTIF ) - if( NOT WITH_STYLE_SGI ) - list( APPEND _disabled_styles TQT_NO_STYLE_SGI ) - endif() - if( NOT WITH_STYLE_MOTIFPLUS) - list( APPEND _disabled_styles TQT_NO_STYLE_MOTIFPLUS ) - endif() - if( NOT WITH_STYLE_CDE ) - list( APPEND _disabled_styles TQT_NO_STYLE_CDE ) - endif() - else() - tde_message_fatal( "Motif style is required for this build" ) -endif( WITH_STYLE_MOTIF ) - +foreach( _style MOTIF WINDOWS CDE MOTIFPLUS SGI COMPACT INTERLACE PLATINUM ) + if( WITH_STYLE_${_style} ) + list( APPEND _SRC_ "${_STYLE_${_style}_SRC_}" ) + else( ) + list( APPEND _disabled_styles "TQT_NO_STYLE_${_style}" ) + endif( ) +endforeach( ) tde_add_library( ${target} STATIC_PIC