Skip to content

Commit

Permalink
Add the first Conan-based dependecies
Browse files Browse the repository at this point in the history
add_conan_lib cmake function is defined, that allows to add a dependency using Conan with two possible system fallbacks:

1. pkg_check_modules is invoked, if `PGK_CONFIG ...` is present
2. find_package is invoked if `FIND_PACKAGE_OPTIONS` is present and `pkg_check_modules` has failed

If `ALWAYS_ALLOW_CONAN_FALLBACK` is present - `obey_system_dependencies` will be ignored for the package

Currently, the following dependencies are retrieved using Conan:

* zlib
* expat
* wxwidgets
* libmp3lame
* libid3tag
* libmad

The last three libraries are included in this commit, as they depend on zlib.
Properly pass **arch** and **os.version** to Conan
  • Loading branch information
crsib committed May 24, 2021
1 parent 576b7e6 commit 8aca9d0
Show file tree
Hide file tree
Showing 12 changed files with 1,479 additions and 63 deletions.
26 changes: 21 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,18 @@ if( APPLE )
endif()

# Add our module path
set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake-proxies/cmake-modules)
# CMAKE_BINARY_DIR is required for Conan to work
set( AUDACITY_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake-proxies/cmake-modules")
set( CMAKE_MODULE_PATH
${AUDACITY_MODULE_PATH}
${CMAKE_BINARY_DIR}
${CMAKE_MODULE_PATH}
)

set( CMAKE_PREFIX_PATH
${CMAKE_BINARY_DIR}
${CMAKE_PREFIX_PATH}
)

# This "is a good thing" but greatly increases link time on Linux
#set( CMAKE_INTERPROCEDURAL_OPTIMIZATION ON )
Expand All @@ -116,6 +127,9 @@ if( CCACHE_PROGRAM )
set_property( GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}" )
endif()

# Define option() prefix
set( _OPT "audacity_" )

# Our very own project
project( Audacity )

Expand All @@ -125,7 +139,7 @@ include( AudacityFunctions )
# Allow user to globally set the library preference
cmd_option( ${_OPT}lib_preference
"Library preference [system (if available), local]"
"local"
"system"
STRINGS "system" "local"
)

Expand Down Expand Up @@ -215,9 +229,6 @@ endif()
message( STATUS " Current Commit: ${GIT_COMMIT_SHORT}" )
message( STATUS )

# Define option() prefix
set( _OPT "audacity_" )

# Organize subdirectories/targets into folders for the IDEs
set_property( GLOBAL PROPERTY USE_FOLDERS ON )

Expand Down Expand Up @@ -437,6 +448,7 @@ find_package( Python3 )
if( Python3_FOUND )
set( PYTHON "${Python3_EXECUTABLE}" )
elseif( CMAKE_SYSTEM_NAME MATCHES "Windows" )
# This is an odd case now, as Conan requires Python as well
nuget_package( pkgdir "python3" "3.7.7" )
file( TO_NATIVE_PATH "${pkgdir}/tools/python.exe" PYTHON )
endif()
Expand All @@ -447,6 +459,10 @@ include( "src/Experimental.cmake" )

# Add our children
add_subdirectory( "cmake-proxies" )

# Conan uses find_package and does not set GLOBAL flag
resolve_conan_dependencies()

add_subdirectory( "help" )
add_subdirectory( "images" )
add_subdirectory( "libraries" )
Expand Down
101 changes: 86 additions & 15 deletions cmake-proxies/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,96 @@
# Allow user to globally set the library preference
cmd_option( ${_OPT}lib_preference
"Library preference [system (if available), local]"
"system"
STRINGS "system" "local"
add_conan_lib(
ZLIB
zlib/1.2.11
REQUIRED
PGK_CONFIG "zlib >= 1.2.11"
INTERFACE_NAME ZLIB::ZLIB
OPTION_NAME zlib
CONAN_OPTIONS
zlib:shared=True
)

# Special mode, that will force dependencies to the packages provided by system unless they were set to local explicitly.
cmd_option( ${_OPT}obey_system_dependencies
"Use system packages to satisfy dependencies"
Off
add_conan_lib(
expat
expat/2.2.9
REQUIRED
PGK_CONFIG "expat >= 2.1.0"
CONAN_OPTIONS
expat:shared=True
)

set(wx_zlib "zlib")
set(wx_png "libpng")

if (${_OPT}use_zlib STREQUAL "system")
set(wx_zlib "sys")
# To prevent linking conflicts - we need to use system libpng as well.
# wxWdigets will attempt to resolve it using find_package
set(wx_png "sys")
endif()

set(wx_expat "expat")

if (${_OPT}use_expat STREQUAL "system")
set(wx_expat "sys")
endif()

add_conan_lib(
wxWidgets
wxwidgets/3.1.3-audacity
REQUIRED
ALWAYS_ALLOW_CONAN_FALLBACK
OPTION_NAME wxwidgets
FIND_PACKAGE_OPTIONS COMPONENTS adv base core html qa xml net
INTERFACE_NAME wxwidgets::wxwidgets
CONAN_OPTIONS
wxwidgets:shared=True
wxwidgets:zlib=${wx_zlib}
wxwidgets:expat=${wx_expat}
wxwidgets:compatibility=3.0
wxwidgets:png=${wx_png}
wxwidgets:tiff=off
wxwidgets:secretstore=False
wxwidgets:opengl=False
wxwidgets:propgrid=False
wxwidgets:ribbon=False
wxwidgets:richtext=False
wxwidgets:stc=False
wxwidgets:webview=False
wxwidgets:help=False
wxwidgets:html_help=False
wxwidgets:fs_inet=False
wxwidgets:protocol=False
)

add_conan_lib(
libmp3lame
libmp3lame/3.100
REQUIRED
INTERFACE_NAME libmp3lame::libmp3lame
PGK_CONFIG "lame >= 3.100"
)

add_conan_lib(
libid3tag
libid3tag/0.15.1b
OPTION_NAME id3tag
HAS_ONLY_DEBUG_RELEASE
PGK_CONFIG "id3tag >= 0.15.1b"
)

add_conan_lib(
libmad
libmad/0.15.1b
OPTION_NAME mad
HAS_ONLY_DEBUG_RELEASE
PGK_CONFIG "mad >= 0.15.1b"
)

set_conan_vars_to_parent()

# Required libraries
#
# directory option symbol req chk version
addlib( wxWidgets wxwidgets WX YES NO "" ) # must be first
addlib( expat expat EXPAT YES YES "expat >= 2.1.0" )
addlib( lame lame LAME YES YES "lame >= 3.100" )
addlib( libsndfile sndfile SNDFILE YES YES "sndfile >= 1.0.28" )
addlib( libsoxr soxr SOXR YES YES "soxr >= 0.1.1" )
addlib( portaudio-v19 portaudio PORTAUDIO YES YES "" )
Expand All @@ -26,8 +100,6 @@ addlib( sqlite sqlite SQLITE YES YES "sqlite3 >= 3.32.
#
# directory option symbol req chk version
addlib( ffmpeg ffmpeg FFMPEG NO NO "libavcodec >= 51.53" "libavformat >= 52.12" "libavutil >= 52.66" )
addlib( libid3tag id3tag LIBID3TAG NO YES "id3tag >= 0.15.1b" )
addlib( libmad mad LIBMAD NO YES "mad >= 0.15.1b" )
addlib( libnyquist nyquist NYQUIST NO YES "" )
addlib( libvamp vamp VAMP NO YES "vamp >= 2.5" "vamp-hostsdk >= 2.5" )
addlib( libogg ogg LIBOGG NO YES "ogg >= 1.3.1" )
Expand All @@ -53,4 +125,3 @@ addlib( portsmf portsmf PORTSMF NO YES "portSMF >= 0.1"
addlib( libsbsms sbsms SBSMS NO YES "sbsms >= 2.2.0" )
addlib( soundtouch soundtouch SOUNDTOUCH NO YES "soundtouch >= 1.7.1" )
addlib( twolame twolame LIBTWOLAME NO YES "twolame >= 0.3.13" )

Loading

0 comments on commit 8aca9d0

Please sign in to comment.