Introducing CMake target wxBase, for restricted uses of wxWidgets

This commit is contained in:
Paul Licameli 2021-05-21 22:11:03 -04:00
commit 90903d237a
2 changed files with 41 additions and 8 deletions

View File

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

View File

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