From 1f71ef4300812edbdbf84ff0eafbb774528dcc06 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sat, 20 Jun 2020 10:21:27 -0400 Subject: [PATCH 1/2] New interface library target wxBase restricts view of wxWidgets... ... It will be used as a target link library of some lower level Audacity libraries, to be separated from the executable. These libraries will have link time dependency only on the wxBase subset of non-monolithic wxWidgets builds. More, they are restricted to use only a proper subset of wxBase functionality: they are prevented, at compile time, not only from using any graphical user interface, but also from using the main event loop or global application object -- though these things are also in wxBase. They may still use things like strings, files, threads, atomics, and other utilities that may have modern C++ standard library equivalents. It would be preferable to use those, but it is not a priority to make those rewrites. --- cmake-proxies/wxWidgets/CMakeLists.txt | 39 ++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/cmake-proxies/wxWidgets/CMakeLists.txt b/cmake-proxies/wxWidgets/CMakeLists.txt index ac0b827a7..47b6bd0ee 100644 --- a/cmake-proxies/wxWidgets/CMakeLists.txt +++ b/cmake-proxies/wxWidgets/CMakeLists.txt @@ -1,5 +1,6 @@ add_library( ${TARGET} INTERFACE ) +add_library( wxBase INTERFACE ) add_library( ${symbol} ALIAS ${TARGET} ) def_vars() @@ -248,11 +249,39 @@ if( NOT ours ) ) endif() -target_include_directories( ${TARGET} INTERFACE ${INCLUDES} ) -target_compile_definitions( ${TARGET} INTERFACE ${DEFINES} ) -target_compile_options( ${TARGET} INTERFACE ${COPTS} ) -target_link_directories( ${TARGET} INTERFACE ${LINKDIRS} ) -target_link_libraries( ${TARGET} INTERFACE ${LIBRARIES} ) +foreach( target "${TARGET}" wxBase ) + target_include_directories( ${target} INTERFACE ${INCLUDES} ) + target_compile_definitions( ${target} INTERFACE ${DEFINES} ) + target_compile_options( ${target} INTERFACE ${COPTS} ) + target_link_directories( ${target} INTERFACE ${LINKDIRS} ) + target_link_libraries( ${target} INTERFACE ${LIBRARIES} ) +endforeach() + +# wxBase exposes only the GUI-less subset of full wxWidgets +# Also prohibit use of some other headers by pre-defining their include guards +# wxUSE_GUI=0 doesn't exclude all of wxCore dependency, and the application +# object and event loops are in wxBase, but we want to exclude their use too +target_compile_definitions( wxBase INTERFACE + "wxUSE_GUI=0" + + # Don't use app.h + _WX_APP_H_BASE_ + + # Don't use evtloop.h + _WX_EVTLOOP_H_ + + # Don't use image.h + _WX_IMAGE_H + + # Don't use colour.h + _WX_COLOUR_H_BASE_ + + # Don't use brush.h + _WX_BRUSH_H_BASE_ + + # Don't use pen.h + _WX_PEN_H_BASE_ +) install( TARGETS ${TARGET} DESTINATION ${_LIBDIR} ) From 26217c22f11dfd89f5f65d82ccaa788f943ca1ae Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sun, 28 Feb 2021 14:34:17 -0500 Subject: [PATCH 2/2] Distinguish nodes in modules.dot.svg that depend directly on wxBase --- cmake-proxies/cmake-modules/AudacityFunctions.cmake | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmake-proxies/cmake-modules/AudacityFunctions.cmake b/cmake-proxies/cmake-modules/AudacityFunctions.cmake index 169545ac7..d0cb1e3bf 100644 --- a/cmake-proxies/cmake-modules/AudacityFunctions.cmake +++ b/cmake-proxies/cmake-modules/AudacityFunctions.cmake @@ -339,7 +339,7 @@ function( audacity_module_fn NAME SOURCES IMPORT_TARGETS endif () if (LIBTYPE STREQUAL "MODULE") - set( SHAPE "box" ) + set( ATTRIBUTES "shape=box" ) set_target_property_all( ${TARGET} ${DIRECTORY_PROPERTY} "${_MODDIR}" ) set_target_properties( ${TARGET} PROPERTIES @@ -347,7 +347,7 @@ function( audacity_module_fn NAME SOURCES IMPORT_TARGETS FOLDER "modules" # for IDE organization ) else() - set( SHAPE "octagon" ) + set( ATTRIBUTES "shape=octagon" ) set_target_property_all( ${TARGET} ${DIRECTORY_PROPERTY} "${_EXEDIR}" ) set_target_properties( ${TARGET} PROPERTIES @@ -356,6 +356,10 @@ function( audacity_module_fn NAME SOURCES IMPORT_TARGETS ) endif() + if( "wxBase" IN_LIST IMPORT_TARGETS ) + string( APPEND ATTRIBUTES " style=filled" ) + endif() + export_symbol_define( export_symbol "${TARGET}" ) import_symbol_define( import_symbol "${TARGET}" ) list( APPEND DEFINES @@ -420,7 +424,7 @@ function( audacity_module_fn NAME SOURCES IMPORT_TARGETS endif() # collect dependency information - list( APPEND GRAPH_EDGES "\"${TARGET}\" [shape=${SHAPE}]" ) + list( APPEND GRAPH_EDGES "\"${TARGET}\" [${ATTRIBUTES}]" ) if (NOT LIBTYPE STREQUAL "MODULE") list( APPEND GRAPH_EDGES "\"Audacity\" -> \"${TARGET}\"" ) endif ()