1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-03 09:29:30 +02:00

Reworked cmake command options

And fixed a recursion problem when copying DLLs to dest folder

The command options are now:

   // Enable Audio Unit plug-in support
   audacity_enable_audiounits:BOOL=ON

   // Library preference [system (if available), local]
   audacity_lib_preference:STRING=system

   // Use FileDialog library [local]
   audacity_use_FileDialog:STRING=local

   // Use expat library [local]
   audacity_use_expat:STRING=local

   // Use ffmpeg library [loaded, off]
   audacity_use_ffmpeg:STRING=off

   // Use flac library [system (if available), local, off]
   audacity_use_flac:STRING=local

   // Use id3tag library [system (if available), local, off]
   audacity_use_id3tag:STRING=local

   // Use LADSPA plug-in support [on, off]
   audacity_use_ladspa:BOOL=ON

   // Use lame library [system (if available), local]
   audacity_use_lame:STRING=local

   // Use libextra library [local]
   audacity_use_libextra:STRING=local

   // Use lv2 library [system (if available), local, off]
   audacity_use_lv2:STRING=local

   // Use mad library [system (if available), local, off]
   audacity_use_mad:STRING=local

   // Use midi library [system (if available), local, off]
   audacity_use_midi:STRING=local

   // Use nyquist library [local, off]
   audacity_use_nyquist:STRING=local

   // Use ogg library [system (if available), local, off]
   audacity_use_ogg:STRING=local

   // Use the portaudio CoreAudio interface if available
   audacity_use_pa_coreaudio:BOOL=YES

   // Use the JACK audio interface if available [loaded, linked, off]
   audacity_use_pa_jack:STRING=off

   // Use the OSS audio interface if available
   audacity_use_pa_oss:BOOL=NO

   // Use portaudio library [local]
   audacity_use_portaudio:STRING=local

   // Use portmixer library [local, off]
   audacity_use_portmixer:STRING=local

   // Use portsmf library [system (if available), local, off]
   audacity_use_portsmf:STRING=local

   // Use sbsms library [system (if available), local, off]
   audacity_use_sbsms:STRING=local

   // Use sndfile library [system (if available), local]
   audacity_use_sndfile:STRING=local

   // Use soundtouch library [system (if available), local, off]
   audacity_use_soundtouch:STRING=local

   // Use soxr library [system (if available), local]
   audacity_use_soxr:STRING=local

   // Use twolame library [system (if available), local, off]
   audacity_use_twolame:STRING=local

   // Use vamp library [system (if available), local, off]
   audacity_use_vamp:STRING=local

   // Use vorbis library [system (if available), local, off]
   audacity_use_vorbis:STRING=local

   // Use VST2 plug-in support [on, off]
   audacity_use_vst:BOOL=ON

   // Use wxwidgets library [system (if available), local]
   audacity_use_wxwidgets:STRING=system
This commit is contained in:
Leland Lucius 2020-02-14 15:56:33 -06:00
parent 5501ac0fc2
commit e07b5df6f3
7 changed files with 215 additions and 97 deletions

View File

@ -384,6 +384,12 @@ macro( get_package_interface package )
)
endmacro()
# Set the cache and context value
macro( set_cache_value var value )
set( ${var} "${value}" )
set_property( CACHE ${var} PROPERTY VALUE "${value}" )
endmacro()
# Set the given property and its config specific brethren to the same value
function( set_target_property_all target property value )
set_target_properties( "${target}" PROPERTIES "${property}" "${value}" )
@ -393,6 +399,51 @@ function( set_target_property_all target property value )
endforeach()
endfunction()
# Taken from wxWidgets and modified for Audcaity
#
# cmd_option(<name> <desc> [default] [STRINGS strings])
# The default is ON if third parameter isn't specified
function( cmd_option name desc )
cmake_parse_arguments( OPTION "" "" "STRINGS" ${ARGN} )
if( ARGC EQUAL 2 )
if( OPTION_STRINGS )
list( GET OPTION_STRINGS 1 default )
else()
set( default ON )
endif()
else()
set( default ${OPTION_UNPARSED_ARGUMENTS} )
endif()
if( OPTION_STRINGS )
set( cache_type STRING )
else()
set( cache_type BOOL )
endif()
set( ${name} "${default}" CACHE ${cache_type} "${desc}" )
if( OPTION_STRINGS )
set_property( CACHE ${name} PROPERTY STRINGS ${OPTION_STRINGS} )
# Check valid value
set( value_is_valid FALSE )
set( avail_values )
foreach( opt ${OPTION_STRINGS} )
if( ${name} STREQUAL opt )
set( value_is_valid TRUE )
break()
endif()
string( APPEND avail_values " ${opt}" )
endforeach()
if( NOT value_is_valid )
message( FATAL_ERROR "Invalid value \"${${name}}\" for option ${name}. Valid values are: ${avail_values}" )
endif()
endif()
set( ${name} "${${name}}" PARENT_SCOPE )
endfunction()
# Add our children
add_subdirectory( "cmake-proxies" )
add_subdirectory( "help" )

View File

@ -1,6 +1,9 @@
# Allow user to globally set the system library preference
option( ${_OPT}prefer_system_libs "Use system libraries if available" YES )
# Allow user to globally set the library preference
cmd_option( ${_OPT}lib_preference
"Library preference [system (if available), local]"
"system"
STRINGS "system" "local"
)
#
# Add individual library targets
@ -31,23 +34,8 @@ function( addlib dir name symbol required check )
set( TARGET ${dir} )
set( TARGET_ROOT ${libsrc}/${dir} )
# If the target is required, then it's always enabled. Otherwise,
# give the user the option to enable/disable it.
set( enable ${_OPT}enable_${name} )
if( required )
set( ${enable} YES )
else()
option( ${enable} "Enable ${name} library" ON )
endif()
# Let the Audacity target know that this library will be used.
set( USE_${symbol} ${${enable}} CACHE INTERNAL USE_${symbol} )
# Bail if the target isn't enabled.
if( NOT ${enable} )
message( STATUS "========== ${name} disabled ==========" )
return()
endif()
# Define the option name
set( use ${_OPT}use_${name} )
# If we're not checking for system or local here, then let the
# target config handle the rest.
@ -56,30 +44,54 @@ function( addlib dir name symbol required check )
return()
endif()
# Only present the system library option if pkg-config was found and
# a package has been specified. Otherwise, the local library will
# be used unconditionally.
set( system ${_OPT}use_system_${name} )
if( PkgConfig_FOUND AND packages )
option( ${system} "Use ${name} system library if available" ${${_OPT}prefer_system_libs} )
# If the target isn't required, allow the user to select which one
# to use or disable it entirely
set( desc "local" )
if( packages )
set( sysopt "system" )
string( PREPEND desc "system (if available), " )
set( default "${${_OPT}lib_preference}" )
else()
set( ${system} NO )
set( default "local" )
endif()
if( NOT required )
set( reqopt "off" )
string( APPEND desc ", off" )
endif()
cmd_option( ${use}
"Use ${name} library [${desc}]"
"${default}"
STRINGS ${sysopt} "local" ${reqopt}
)
# Bail if the target will not be used
if( ${use} STREQUAL "off" )
message( STATUS "========== ${name} disabled ==========" )
set( USE_${symbol} OFF CACHE INTERNAL "" FORCE )
return()
endif()
# Let the Audacity target know that this library will be used
set( USE_${symbol} ON CACHE INTERNAL "" FORCE )
message( STATUS "========== Configuring ${name} ==========" )
# Check for the system package if the user prefers it.
if( ${system} )
# Check for the system package(s) if the user prefers it
if( ${use} STREQUAL "system" )
# Look them up
pkg_check_modules( ${TARGET} ${packages} )
if( ${TARGET}_FOUND )
pkg_check_modules( PKG_${TARGET} ${packages} )
if( PKG_${TARGET}_FOUND )
message( STATUS "Using '${name}' system library" )
# Create the target interface library
add_library( ${TARGET} INTERFACE IMPORTED GLOBAL )
# Retrieve the package information
get_package_interface( ${TARGET} )
get_package_interface( PKG_${TARGET} )
# And add it to our target
target_include_directories( ${TARGET} INTERFACE ${INCLUDES} )
@ -87,11 +99,14 @@ function( addlib dir name symbol required check )
target_link_directories( ${TARGET} INTERFACE ${LINKDIRS} )
target_link_options( ${TARGET} INTERFACE ${LOPTS} )
target_link_libraries( ${TARGET} INTERFACE ${LIBRARIES} )
else()
set( ${use} "local" )
set_property( CACHE ${use} PROPERTY VALUE "local" )
endif()
endif()
# User want the local package or the system one wasn't found
if( NOT ${TARGET}_FOUND )
# User wants the local package or the system one wasn't found
if( ${use} STREQUAL "local" )
message( STATUS "Using '${name}' local library" )
# Pull in the target config

View File

@ -11,39 +11,52 @@ def_vars()
message( STATUS "========== Configuring ${name} ==========" )
# Let the Audacity target know we're using ffmpeg
set( USE_${symbol} ON CACHE INTERNAL USE_${symbol} )
# Add the system/local option
option( ${_OPT}use_system_${name} "Use ${name} system library if available" ${${_OPT}prefer_system_libs} )
# Look up the system packages if the user wants them
if( ${_OPT}use_system_${name} )
# Provide an option that determines if the libraries are loaded
# dynamically at run time or statically linked at build time
option( ${_OPT}disable_dynamic_${name} "Disable dynamic loading of ${name} libraries" NO)
# Look them up
pkg_check_modules( ${TARGET} ${packages} )
else()
# Make sure to reset in case user reconfigures between local/system
set( ${_OPT}disable_dynamic_${name} NO CACHE INTERNAL "" )
# We can only (possibly) link to it if we have pkg-config
if( PkgConfig_FOUND )
set( opt "linked" )
set( desc "linked, " )
endif()
# If the system packages were found
if( ${TARGET}_FOUND )
message( STATUS "Using '${name}' system library" )
# FFmpeg is either dynamically loaded, linked to, or off
cmd_option( ${_OPT}use_ffmpeg
"Use ffmpeg library [loaded, ${desc}off]"
"loaded"
STRINGS "loaded" ${opt} "off"
)
# Pull in the package settings
get_package_interface( ${TARGET} )
# Deteremine if it will be turned off, linked to, or loaded
if( ${_OPT}use_ffmpeg STREQUAL "off" )
message( STATUS "Disabling '${name}' library" )
else()
message( STATUS "Using '${name}' local library" )
# Let the Audacity target know that this library will be used.
set( USE_${symbol} ON CACHE INTERNAL USE_${symbol} )
# Otherwise define the local settings
list( APPEND INCLUDES
INTERFACE
${TARGET_ROOT}
)
# Only need to look up the package if we're linking to it
set( isdyn YES )
if( ${_OPT}use_ffmpeg STREQUAL "linked" )
pkg_check_modules( ${TARGET} ${packages} )
# Set up for link if it was found
if( ${TARGET}_FOUND )
message( STATUS "Linking '${name}' library during build" )
# Pull in the package settings
get_package_interface( ${TARGET} )
# Not dynamic
set( isdyn NO )
endif()
endif()
# Pull in the local includes if we're dynamically loading
if( isdyn )
message( STATUS "Will dynamically load '${name}' library at runtime" )
list( APPEND INCLUDES
INTERFACE
${TARGET_ROOT}
)
endif()
endif()
# And add the settings to the target

View File

@ -29,6 +29,7 @@
/* This is the version 1.0.X header file. */
#define SNDFILE_1
#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>

View File

@ -7,23 +7,48 @@ set( CMAKE_MODULE_PATH ${TARGET_ROOT}/cmake_support )
# Define the platform specific interface options
if( CMAKE_SYSTEM_NAME MATCHES "Windows" )
option( ${_OPT}use_pa_ds "Enable the portaudio DirectSound interface if available" YES )
option( ${_OPT}use_pa_wasapi "Enable the portaudio WASAPI interface if available" YES )
option( ${_OPT}use_pa_wmme "Enable the portaudio WMME interface if available" YES )
cmd_option(
${_OPT}use_pa_ds
"Use the portaudio DirectSound interface if available"
YES
)
cmd_option(
${_OPT}use_pa_wasapi
"Use the portaudio WASAPI interface if available"
YES
)
cmd_option(
${_OPT}use_pa_wmme
"Use the portaudio WMME interface if available"
YES
)
elseif( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
option( ${_OPT}use_pa_coreaudio "Enable the portaudio CoreAudio interface if available" YES )
cmd_option(
${_OPT}use_pa_coreaudio
"Use the portaudio CoreAudio interface if available"
YES
)
elseif( CMAKE_SYSTEM_NAME MATCHES "Linux|FreeBSD" )
option( ${_OPT}use_pa_alsa "Enable the portaudio ALSA interface if available" YES )
cmd_option(
${_OPT}use_pa_alsa
"Use the portaudio ALSA interface if available"
YES
)
if( ${_OPT}use_pa_alsa )
find_package( ALSA )
if( NOT ALSA_FOUND )
set( ${_OPT}use_pa_alsa NO CACHE INTERNAL "" )
set_cache_value( ${_OPT}use_pa_alsa NO )
endif()
endif()
endif()
# Look for OSS if the user wants it
option( ${_OPT}use_pa_oss "Use the OSS audio interface if available" YES )
cmd_option(
${_OPT}use_pa_oss
"Use the OSS audio interface if available"
YES
)
if( ${_OPT}use_pa_oss )
find_path( OSS_INCLUDE NAMES sys/soundcard.h )
mark_as_advanced( FORCE OSS_INCLUDE )
@ -40,25 +65,23 @@ if( ${_OPT}use_pa_oss )
endif()
if( NOT OSS_INCLUDE_DIRS )
set( ${_OPT}use_pa_oss NO CACHE INTERNAL "" )
set_cache_value( ${_OPT}use_pa_oss NO )
endif()
endif()
# Look for JACK if the user wants it
option( ${_OPT}use_pa_jack "Use the JACK audio interface if available" YES )
if( ${_OPT}use_pa_jack )
# Provide an option that determines if the libraries are loaded
# dynamically at run time or statically linked at build time
option( ${_OPT}disable_dynamic_jack "Disable dynamic loading of JACK libraries" YES )
# JACK can be dynamically loaded, linked to, or off
cmd_option( ${_OPT}use_pa_jack
"Use the JACK audio interface if available [loaded, linked, off]"
"linked"
STRINGS "loaded" "linked" "off"
)
if( NOT ${_OPT}use_pa_jack STREQUAL "off" )
# Find it
find_package( Jack )
if( NOT JACK_FOUND)
set( ${_OPT}use_pa_jack NO CACHE INTERNAL "" )
set_cache_value( ${_OPT}use_pa_jack "off" )
endif()
else()
# Make sure to reset in case user reconfigures later
set( ${_OPT}disable_dynamic_jack NO CACHE INTERNAL "" )
endif()
list( APPEND SOURCES
@ -116,7 +139,7 @@ list( APPEND SOURCES
${TARGET_ROOT}/src/hostapi/oss/pa_unix_oss.c
>
$<$<BOOL:${${_OPT}use_pa_jack}>:
$<$<NOT:$<STREQUAL:${${_OPT}use_pa_jack},off>>:
${TARGET_ROOT}/src/hostapi/jack/pa_jack.c
${TARGET_ROOT}/src/hostapi/jack/pa_jack_dynload.c
>
@ -150,7 +173,7 @@ list( APPEND INCLUDES
${OSS_INCLUDE_DIRS}
>
$<$<BOOL:${${_OPT}use_pa_jack}>:
$<$<NOT:$<STREQUAL:${${_OPT}use_pa_jack},off>>:
${TARGET_ROOT}/src/hostapi/jack
${JACK_INCLUDE_DIRS}
>
@ -186,11 +209,11 @@ list( APPEND DEFINES
HAVE_SYS_SOUNDCARD_H=1
>
$<$<BOOL:${${_OPT}use_pa_jack}>:
$<$<NOT:$<STREQUAL:${${_OPT}use_pa_jack},off>>:
PA_USE_JACK=1
>
$<$<NOT:$<BOOL:${${_OPT}disable_dynamic_jack}>>:
$<$<STREQUAL:${${_OPT}use_pa_jack},dynamic>:
PA_DYNAMIC_JACK=1
>
)
@ -205,7 +228,7 @@ list( APPEND LIBRARIES
${OSS_LIBRARIES}
>
$<$<BOOL:${${_OPT}use_pa_jack}>:
$<$<NOT:$<STREQUAL:${${_OPT}use_pa_jack},off>>:
${JACK_LIBRARIES}
>
)

View File

@ -6,8 +6,13 @@ def_vars()
message( STATUS "========== Configuring ${name} ==========" )
option( ${_OPT}use_system_${name} "Use ${name} system library if available" ${${_OPT}prefer_system_libs} )
if( ${_OPT}use_system_${name} )
cmd_option( ${_OPT}use_wxwidgets
"Use ${name} library [system (if available), local]"
"${audacity_lib_preference}"
STRINGS "system" "local"
)
if( ${_OPT}use_wxwidgets STREQUAL "system" )
find_package(wxWidgets)
endif()
@ -53,8 +58,6 @@ if( wxWidgets_FOUND )
else()
message( STATUS "Using local '${name}' library" )
set( ${_OPT}use_system_${name} OFF CACHE BOOL "Prefer ${name} system library if available" FORCE )
set( WXWIN $ENV{WXWIN} )
if( "${WXWIN}" STREQUAL "" )
# XXX: Look into importing instead of adding to this project
@ -118,7 +121,7 @@ else()
)
# Do NOT split the generator expressions across multiple lines here.
# CMake appears to have a bug and doesn't see to handle it correctly
# CMake appears to have a bug and doesn't seem to handle it correctly
# for target link libraries.
set( LIBRARIES
adv

View File

@ -1072,11 +1072,19 @@ if( CMAKE_VERSION VERSION_GREATER_EQUAL "3.16" AND NOT CCACHE_PROGRAM )
endif()
# Handle Ladspa option
option( ${_OPT}enable_ladspa "Enable LADSPA plug-in support" ON )
set( USE_LADSPA ${${_OPT}enable_ladspa} )
cmd_option(
${_OPT}use_ladspa
"Use LADSPA plug-in support [on, off]"
ON
)
set( USE_LADSPA ${${_OPT}use_ladspa} )
# Handle VST option
option( ${_OPT}enable_vst "Enable VST2 plug-in support" ON )
cmd_option(
${_OPT}use_vst
"Use VST2 plug-in support [on, off]"
ON
)
set( USE_VST ${${_OPT}enable_vst} )
set( AUDACITY_NAME "Audacity" )
@ -1119,7 +1127,7 @@ if( CMAKE_SYSTEM_NAME MATCHES "Windows" )
configure_file( audacity_config.h.in private/configwin.h )
# Copy over the wxWidgets DLLs
if( use_system_wxwidgets )
if( ${_OPT}use_wxwidgets STREQUAL "system" )
set( wxlibs "$ENV{WXWIN}" )
else()
set( wxlibs "${CMAKE_BINARY_DIR}" )
@ -1144,7 +1152,7 @@ if( CMAKE_SYSTEM_NAME MATCHES "Windows" )
DEL ${dlls}
)
IF %1 EQU xyzzy (
FOR /F %%i IN ('DUMPBIN /DEPENDENTS \"%2\"\\%3 ^| FIND \" wx\"') DO (
FOR /F %%i IN ('DUMPBIN /DEPENDENTS \"%2\"\\%3 ^| findstr /B \"/C: wx\"') DO (
ECHO %%i >>\"${dlls}\"
CALL %0 xyzzy \"${libdir}\" %%i
)
@ -1172,7 +1180,11 @@ elseif( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
set( _EXE "Audacity" )
# Handle Audio Units option
option( ${_OPT}enable_audiounits "Enable Audio Unit plug-in support" ON )
cmd_option(
${_OPT}enable_audiounits
"Enable Audio Unit plug-in support"
ON
)
set( USE_AUDIO_UNITS ${${_OPT}enable_audiounits} )
set_target_properties(
@ -1296,7 +1308,7 @@ elseif( CMAKE_SYSTEM_NAME MATCHES "Linux|FreeBSD" )
configure_file( audacity.desktop.in ${_INTDIR}/audacity.desktop )
# Create the script to copy required wxWidgets libraries
if( NOT use_system_wxwidgets )
if( ${_OPT}use_wxwidgets STREQUAL "local" )
file( WRITE "${_INTDIR}/copy_libs.sh"
"for lib in \$(ldd ${_EXEDIR}/${_EXE} | awk '/libwx/{print \$1}')
do