mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
Merge pull request #903 from Paul-Licameli/more-module-preliminaries
More module preliminaries
This commit is contained in:
commit
b1f05e5747
@ -433,6 +433,7 @@ include( "src/Experimental.cmake" )
|
||||
add_subdirectory( "cmake-proxies" )
|
||||
add_subdirectory( "help" )
|
||||
add_subdirectory( "images" )
|
||||
add_subdirectory( "libraries" )
|
||||
add_subdirectory( "locale" )
|
||||
add_subdirectory( "src" )
|
||||
add_subdirectory( "modules" )
|
||||
|
@ -270,6 +270,7 @@ endfunction()
|
||||
function( import_export_symbol var module_name )
|
||||
# compute, e.g. "TRACK_UI_API" from module name "mod-track-ui"
|
||||
string( REGEX REPLACE "^mod-" "" symbol "${module_name}" )
|
||||
string( REGEX REPLACE "^lib-" "" symbol "${symbol}" )
|
||||
string( TOUPPER "${symbol}" symbol )
|
||||
string( REPLACE "-" "_" symbol "${symbol}" )
|
||||
string( APPEND symbol "_API" )
|
||||
@ -301,7 +302,7 @@ function( export_symbol_define var module_name )
|
||||
endfunction()
|
||||
|
||||
function( audacity_module_fn NAME SOURCES IMPORT_TARGETS
|
||||
ADDITIONAL_DEFINES ADDITIONAL_LIBRARIES )
|
||||
ADDITIONAL_DEFINES ADDITIONAL_LIBRARIES LIBTYPE )
|
||||
|
||||
set( TARGET ${NAME} )
|
||||
set( TARGET_ROOT ${CMAKE_CURRENT_SOURCE_DIR} )
|
||||
@ -310,17 +311,46 @@ function( audacity_module_fn NAME SOURCES IMPORT_TARGETS
|
||||
|
||||
def_vars()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
set( LIBTYPE SHARED )
|
||||
if (LIBTYPE STREQUAL "MODULE" AND CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
set( REAL_LIBTYPE SHARED )
|
||||
else()
|
||||
set( LIBTYPE MODULE )
|
||||
set( REAL_LIBTYPE "${LIBTYPE}" )
|
||||
endif()
|
||||
add_library( ${TARGET} ${REAL_LIBTYPE} )
|
||||
|
||||
# Manual propagation seems to be necessary from
|
||||
# interface libraries -- just doing target_link_libraries naming them
|
||||
# doesn't work as promised
|
||||
|
||||
# compute INCLUDES
|
||||
set( INCLUDES )
|
||||
list( APPEND INCLUDES PUBLIC ${TARGET_ROOT} )
|
||||
|
||||
# compute DEFINES
|
||||
set( DEFINES )
|
||||
list( APPEND DEFINES ${ADDITIONAL_DEFINES} )
|
||||
|
||||
if (LIBTYPE STREQUAL "MODULE")
|
||||
set( SHAPE "box" )
|
||||
set_target_property_all( ${TARGET} LIBRARY_OUTPUT_DIRECTORY "${_MODDIR}" )
|
||||
set_target_properties( ${TARGET}
|
||||
PROPERTIES
|
||||
PREFIX ""
|
||||
FOLDER "modules" # for IDE organization
|
||||
)
|
||||
else()
|
||||
set( SHAPE "octagon" )
|
||||
set_target_property_all( ${TARGET} LIBRARY_OUTPUT_DIRECTORY "${_EXEDIR}" )
|
||||
set_target_properties( ${TARGET}
|
||||
PROPERTIES
|
||||
PREFIX ""
|
||||
FOLDER "libraries" # for IDE organization
|
||||
)
|
||||
endif()
|
||||
add_library( ${TARGET} ${LIBTYPE} )
|
||||
|
||||
export_symbol_define( export_symbol "${TARGET}" )
|
||||
import_symbol_define( import_symbol "${TARGET}" )
|
||||
set( DEFINES
|
||||
${ADDITIONAL_DEFINES}
|
||||
list( APPEND DEFINES
|
||||
PRIVATE "${export_symbol}"
|
||||
INTERFACE "${import_symbol}"
|
||||
)
|
||||
@ -337,13 +367,6 @@ function( audacity_module_fn NAME SOURCES IMPORT_TARGETS
|
||||
endforeach()
|
||||
list( APPEND LIBRARIES ${ADDITIONAL_LIBRARIES} )
|
||||
|
||||
set_target_property_all( ${TARGET} LIBRARY_OUTPUT_DIRECTORY "${_MODDIR}" )
|
||||
set_target_properties( ${TARGET}
|
||||
PROPERTIES
|
||||
PREFIX ""
|
||||
FOLDER "modules"
|
||||
)
|
||||
|
||||
# list( TRANSFORM SOURCES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/" )
|
||||
|
||||
# Compute compilation options.
|
||||
@ -360,13 +383,25 @@ function( audacity_module_fn NAME SOURCES IMPORT_TARGETS
|
||||
target_link_options( ${TARGET} PRIVATE ${LOPTS} )
|
||||
target_link_libraries( ${TARGET} PUBLIC ${LIBRARIES} )
|
||||
|
||||
if( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" )
|
||||
add_custom_command(
|
||||
TARGET "${TARGET}"
|
||||
POST_BUILD
|
||||
COMMAND $<IF:$<CONFIG:Debug>,echo,strip> -x $<TARGET_FILE:${TARGET}>
|
||||
)
|
||||
endif()
|
||||
|
||||
# define an additional interface library target
|
||||
set(INTERFACE_TARGET "${TARGET}-interface")
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
if (NOT REAL_LIBTYPE STREQUAL "MODULE")
|
||||
add_library("${INTERFACE_TARGET}" ALIAS "${TARGET}")
|
||||
else()
|
||||
add_library("${INTERFACE_TARGET}" INTERFACE)
|
||||
foreach(PROP INTERFACE_INCLUDE_DIRECTORIES INTERFACE_COMPILE_DEFINITIONS)
|
||||
foreach(PROP
|
||||
INTERFACE_INCLUDE_DIRECTORIES
|
||||
INTERFACE_COMPILE_DEFINITIONS
|
||||
INTERFACE_LINK_LIBRARIES
|
||||
)
|
||||
get_target_property( PROPS "${TARGET}" "${PROP}" )
|
||||
if (PROPS)
|
||||
set_target_properties(
|
||||
@ -377,7 +412,10 @@ function( audacity_module_fn NAME SOURCES IMPORT_TARGETS
|
||||
endif()
|
||||
|
||||
# collect dependency information
|
||||
list( APPEND GRAPH_EDGES "\"${TARGET}\" [shape=box]" )
|
||||
list( APPEND GRAPH_EDGES "\"${TARGET}\" [shape=${SHAPE}]" )
|
||||
if (NOT LIBTYPE STREQUAL "MODULE")
|
||||
list( APPEND GRAPH_EDGES "\"Audacity\" -> \"${TARGET}\"" )
|
||||
endif ()
|
||||
set(ACCESS PUBLIC PRIVATE INTERFACE)
|
||||
foreach( IMPORT ${IMPORT_TARGETS} )
|
||||
if(IMPORT IN_LIST ACCESS)
|
||||
@ -409,10 +447,35 @@ macro( audacity_module NAME SOURCES IMPORT_TARGETS
|
||||
"${IMPORT_TARGETS}"
|
||||
"${ADDITIONAL_DEFINES}"
|
||||
"${ADDITIONAL_LIBRARIES}"
|
||||
"MODULE"
|
||||
)
|
||||
set( GRAPH_EDGES "${GRAPH_EDGES}" PARENT_SCOPE )
|
||||
endmacro()
|
||||
|
||||
# Set up for defining a library target.
|
||||
# The application depends on all libraries.
|
||||
# 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.
|
||||
# More defines, and more target libraries (maybe generator expressions)
|
||||
# may be given too.
|
||||
macro( audacity_library NAME SOURCES IMPORT_TARGETS
|
||||
ADDITIONAL_DEFINES ADDITIONAL_LIBRARIES )
|
||||
# ditto comment in the previous macro
|
||||
audacity_module_fn(
|
||||
"${NAME}"
|
||||
"${SOURCES}"
|
||||
"${IMPORT_TARGETS}"
|
||||
"${ADDITIONAL_DEFINES}"
|
||||
"${ADDITIONAL_LIBRARIES}"
|
||||
"SHARED"
|
||||
)
|
||||
set( GRAPH_EDGES "${GRAPH_EDGES}" PARENT_SCOPE )
|
||||
# Collect list of libraries for the executable to declare dependency on
|
||||
list( APPEND AUDACITY_LIBRARIES "${NAME}" )
|
||||
set( AUDACITY_LIBRARIES "${AUDACITY_LIBRARIES}" PARENT_SCOPE )
|
||||
endmacro()
|
||||
|
||||
#
|
||||
# Add individual library targets
|
||||
#
|
||||
|
13
libraries/CMakeLists.txt
Normal file
13
libraries/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
# Include the libraries that we'll build
|
||||
|
||||
# The list of modules is ordered so that each library occurs after any others
|
||||
# that it depends on
|
||||
set( LIBRARIES
|
||||
)
|
||||
|
||||
foreach( LIBRARY ${LIBRARIES} )
|
||||
add_subdirectory("${LIBRARY}")
|
||||
endforeach()
|
||||
|
||||
set( GRAPH_EDGES "${GRAPH_EDGES}" PARENT_SCOPE )
|
||||
set( AUDACITY_LIBRARIES "${AUDACITY_LIBRARIES}" PARENT_SCOPE )
|
@ -1321,6 +1321,7 @@ target_compile_options( ${TARGET} PRIVATE ${OPTIONS} )
|
||||
target_include_directories( ${TARGET} PRIVATE ${INCLUDES} )
|
||||
target_link_options( ${TARGET} PRIVATE ${LDFLAGS} )
|
||||
target_link_libraries( ${TARGET} ${LIBRARIES} )
|
||||
target_link_libraries( ${TARGET} PUBLIC ${AUDACITY_LIBRARIES} )
|
||||
|
||||
if( CMAKE_VERSION VERSION_GREATER_EQUAL "3.16" AND NOT CCACHE_PROGRAM )
|
||||
if( ${_OPT}use_pch )
|
||||
|
Loading…
x
Reference in New Issue
Block a user