From ca7d96f20ae4fb271509745f89476c4c4d8cd29c Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 15 Feb 2021 14:44:49 -0500 Subject: [PATCH] Transitive link dependencies via Audacity simplify module CMakeLists --- .../cmake-modules/AudacityFunctions.cmake | 31 +++---------------- modules/mod-null/CMakeLists.txt | 2 +- modules/mod-nyq-bench/CMakeLists.txt | 2 +- modules/mod-script-pipe/CMakeLists.txt | 2 +- src/CMakeLists.txt | 4 +-- 5 files changed, 9 insertions(+), 32 deletions(-) diff --git a/cmake-proxies/cmake-modules/AudacityFunctions.cmake b/cmake-proxies/cmake-modules/AudacityFunctions.cmake index 740816a83..d22dfdca0 100644 --- a/cmake-proxies/cmake-modules/AudacityFunctions.cmake +++ b/cmake-proxies/cmake-modules/AudacityFunctions.cmake @@ -206,7 +206,6 @@ endmacro() # Set up for defining a module target. -# All modules depend on the application. # Pass a name and sources, and a list of other targets. # Use the interface compile definitions and include directories of the # other targets, and link to them. @@ -223,36 +222,14 @@ function( audacity_module NAME SOURCES IMPORT_TARGETS def_vars() 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 PRIVATE $<$:-undefined dynamic_lookup> ) # compute LIBRARIES - set( LIBRARIES PRIVATE Audacity ) + set( LIBRARIES PRIVATE ) foreach( IMPORT ${IMPORT_TARGETS} ) list( APPEND LIBRARIES "${IMPORT}" ) endforeach() @@ -270,8 +247,8 @@ function( audacity_module NAME SOURCES IMPORT_TARGETS organize_source( "${TARGET_ROOT}" "" "${SOURCES}" ) target_sources( ${TARGET} PRIVATE ${SOURCES} ) - target_compile_definitions( ${TARGET} PRIVATE ${DEFINES} ) - target_include_directories( ${TARGET} PRIVATE ${INCLUDES} ) + target_compile_definitions( ${TARGET} PRIVATE ${ADDITIONAL_DEFINES} ) + target_include_directories( ${TARGET} PUBLIC ${TARGET_ROOT} ) target_link_options( ${TARGET} PRIVATE ${LOPTS} ) target_link_libraries( ${TARGET} PRIVATE ${LIBRARIES} ) endfunction() diff --git a/modules/mod-null/CMakeLists.txt b/modules/mod-null/CMakeLists.txt index 333735fab..4798e6ac1 100644 --- a/modules/mod-null/CMakeLists.txt +++ b/modules/mod-null/CMakeLists.txt @@ -12,7 +12,7 @@ set( SOURCES ModNullCallback.cpp ModNullCallback.h ) -audacity_module( ${TARGET} "${SOURCES}" "wxWidgets" +audacity_module( ${TARGET} "${SOURCES}" "Audacity" "${DEFINES}" "" ) set_target_properties( ${TARGET} PROPERTIES EXCLUDE_FROM_ALL YES ) diff --git a/modules/mod-nyq-bench/CMakeLists.txt b/modules/mod-nyq-bench/CMakeLists.txt index a0b9f1a3d..dc02c6cf3 100644 --- a/modules/mod-nyq-bench/CMakeLists.txt +++ b/modules/mod-nyq-bench/CMakeLists.txt @@ -12,7 +12,7 @@ set( DEFINES # versions of wxWidgets...even if the build is for Release. wxDEBUG_LEVEL=0 ) -audacity_module( ${TARGET} "${SOURCES}" "wxWidgets;portaudio-v19;libnyquist" +audacity_module( ${TARGET} "${SOURCES}" "Audacity" "${DEFINES}" "" ) set_target_properties( ${TARGET} PROPERTIES EXCLUDE_FROM_ALL YES ) diff --git a/modules/mod-script-pipe/CMakeLists.txt b/modules/mod-script-pipe/CMakeLists.txt index 56f0e7c3e..5ee18627f 100644 --- a/modules/mod-script-pipe/CMakeLists.txt +++ b/modules/mod-script-pipe/CMakeLists.txt @@ -13,5 +13,5 @@ set( DEFINES # debug versions of wxWidgets...even if the build is for Release. wxDEBUG_LEVEL=0 ) -audacity_module( mod-script-pipe "${SOURCES}" "wxWidgets" +audacity_module( mod-script-pipe "${SOURCES}" "Audacity" "${DEFINES}" "" ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5b2b1daef..496df229c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1043,7 +1043,7 @@ list( APPEND LDFLAGS # # list( APPEND LIBRARIES - PRIVATE + PUBLIC ${CMAKE_REQUIRED_LIBRARIES} wxWidgets expat @@ -1306,7 +1306,7 @@ target_compile_definitions( ${TARGET} PRIVATE ${DEFINES} ) target_compile_options( ${TARGET} PRIVATE ${OPTIONS} ) target_include_directories( ${TARGET} PRIVATE ${INCLUDES} ) 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 # only use them if ccache is not available and the user hasn't disabled