1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-14 07:58:54 +02:00

Transitive link dependencies via Audacity simplify module CMakeLists

This commit is contained in:
Paul Licameli 2021-02-15 14:44:49 -05:00 committed by Leland Lucius
parent 938bbeb4f9
commit ca7d96f20a
5 changed files with 9 additions and 32 deletions

View File

@ -206,7 +206,6 @@ endmacro()
# Set up for defining a module target. # Set up for defining a module target.
# All modules depend on the application.
# Pass a name and sources, and a list of other targets. # Pass a name and sources, and a list of other targets.
# Use the interface compile definitions and include directories of the # Use the interface compile definitions and include directories of the
# other targets, and link to them. # other targets, and link to them.
@ -224,35 +223,13 @@ function( audacity_module NAME SOURCES IMPORT_TARGETS
add_library( ${TARGET} MODULE ) add_library( ${TARGET} MODULE )
# compute INCLUDES
unset( INCLUDES )
foreach( IMPORT ${IMPORT_TARGETS} )
unset( PROPS )
get_target_property( PROPS ${IMPORT} INTERFACE_INCLUDE_DIRECTORIES )
if (PROPS)
list( APPEND INCLUDES PUBLIC ${PROPS} )
endif()
endforeach()
list( APPEND INCLUDES PUBLIC ${TARGET_ROOT} )
# compute DEFINES
unset( DEFINES )
foreach( IMPORT ${IMPORT_TARGETS} )
unset( PROPS )
get_target_property( PROPS ${IMPORT} INTERFACE_COMPILE_DEFINITIONS )
if (PROPS)
list( APPEND DEFINES ${PROPS} )
endif()
endforeach()
list( APPEND DEFINES ${ADDITIONAL_DEFINES} )
set( LOPTS set( LOPTS
PRIVATE PRIVATE
$<$<PLATFORM_ID:Darwin>:-undefined dynamic_lookup> $<$<PLATFORM_ID:Darwin>:-undefined dynamic_lookup>
) )
# compute LIBRARIES # compute LIBRARIES
set( LIBRARIES PRIVATE Audacity ) set( LIBRARIES PRIVATE )
foreach( IMPORT ${IMPORT_TARGETS} ) foreach( IMPORT ${IMPORT_TARGETS} )
list( APPEND LIBRARIES "${IMPORT}" ) list( APPEND LIBRARIES "${IMPORT}" )
endforeach() endforeach()
@ -270,8 +247,8 @@ function( audacity_module NAME SOURCES IMPORT_TARGETS
organize_source( "${TARGET_ROOT}" "" "${SOURCES}" ) organize_source( "${TARGET_ROOT}" "" "${SOURCES}" )
target_sources( ${TARGET} PRIVATE ${SOURCES} ) target_sources( ${TARGET} PRIVATE ${SOURCES} )
target_compile_definitions( ${TARGET} PRIVATE ${DEFINES} ) target_compile_definitions( ${TARGET} PRIVATE ${ADDITIONAL_DEFINES} )
target_include_directories( ${TARGET} PRIVATE ${INCLUDES} ) target_include_directories( ${TARGET} PUBLIC ${TARGET_ROOT} )
target_link_options( ${TARGET} PRIVATE ${LOPTS} ) target_link_options( ${TARGET} PRIVATE ${LOPTS} )
target_link_libraries( ${TARGET} PRIVATE ${LIBRARIES} ) target_link_libraries( ${TARGET} PRIVATE ${LIBRARIES} )
endfunction() endfunction()

View File

@ -12,7 +12,7 @@ set( SOURCES
ModNullCallback.cpp ModNullCallback.cpp
ModNullCallback.h ModNullCallback.h
) )
audacity_module( ${TARGET} "${SOURCES}" "wxWidgets" audacity_module( ${TARGET} "${SOURCES}" "Audacity"
"${DEFINES}" "" ) "${DEFINES}" "" )
set_target_properties( ${TARGET} PROPERTIES EXCLUDE_FROM_ALL YES ) set_target_properties( ${TARGET} PROPERTIES EXCLUDE_FROM_ALL YES )

View File

@ -12,7 +12,7 @@ set( DEFINES
# versions of wxWidgets...even if the build is for Release. # versions of wxWidgets...even if the build is for Release.
wxDEBUG_LEVEL=0 wxDEBUG_LEVEL=0
) )
audacity_module( ${TARGET} "${SOURCES}" "wxWidgets;portaudio-v19;libnyquist" audacity_module( ${TARGET} "${SOURCES}" "Audacity"
"${DEFINES}" "" ) "${DEFINES}" "" )
set_target_properties( ${TARGET} PROPERTIES EXCLUDE_FROM_ALL YES ) set_target_properties( ${TARGET} PROPERTIES EXCLUDE_FROM_ALL YES )

View File

@ -13,5 +13,5 @@ set( DEFINES
# debug versions of wxWidgets...even if the build is for Release. # debug versions of wxWidgets...even if the build is for Release.
wxDEBUG_LEVEL=0 wxDEBUG_LEVEL=0
) )
audacity_module( mod-script-pipe "${SOURCES}" "wxWidgets" audacity_module( mod-script-pipe "${SOURCES}" "Audacity"
"${DEFINES}" "" ) "${DEFINES}" "" )

View File

@ -1043,7 +1043,7 @@ list( APPEND LDFLAGS
# #
# #
list( APPEND LIBRARIES list( APPEND LIBRARIES
PRIVATE PUBLIC
${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES}
wxWidgets wxWidgets
expat expat
@ -1306,7 +1306,7 @@ target_compile_definitions( ${TARGET} PRIVATE ${DEFINES} )
target_compile_options( ${TARGET} PRIVATE ${OPTIONS} ) target_compile_options( ${TARGET} PRIVATE ${OPTIONS} )
target_include_directories( ${TARGET} PRIVATE ${INCLUDES} ) target_include_directories( ${TARGET} PRIVATE ${INCLUDES} )
target_link_options( ${TARGET} PRIVATE ${LDFLAGS} ) target_link_options( ${TARGET} PRIVATE ${LDFLAGS} )
target_link_libraries( ${TARGET} PRIVATE ${LIBRARIES} ) target_link_libraries( ${TARGET} ${LIBRARIES} )
# If was have cmake 3.16 or higher, we can use precompiled headers, but # If was have cmake 3.16 or higher, we can use precompiled headers, but
# only use them if ccache is not available and the user hasn't disabled # only use them if ccache is not available and the user hasn't disabled