From abec10d88becf2712911fb2baeb4a7fdf4834b4c Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Sat, 7 Mar 2020 18:16:27 -0600 Subject: [PATCH] Add cmake_build.txt and fix a small CMake issue The cmake_build.txt is for Mac only right now, so we'll probably want to try and figure out how to make it generic enough for all platforms. --- CMakeLists.txt | 5 +- mac/cmake_build.txt | 141 ++++++++++++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 3 +- 3 files changed, 146 insertions(+), 3 deletions(-) create mode 100644 mac/cmake_build.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e663b53e..dfed311d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -347,14 +347,15 @@ find_package( OpenGL QUIET ) # .../bin/Debug// # or: # .../bin//Debug -set( _DEST "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${CMAKE_BUILD_TYPE}" ) +set( _DESTDIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${CMAKE_BUILD_TYPE}" ) +set( _DEST "${_DESTDIR}" ) set( _EXEDIR "${_DEST}" ) string( REGEX REPLACE "/+$" "" _EXEDIR "${_EXEDIR}" ) # Adjust them for the Mac if( CMAKE_SYSTEM_NAME MATCHES "Darwin" ) set( _DEST "${_DEST}/Audacity.app/Contents" ) - set( _EXEDIR "${_DEST}/Macos" ) + set( _EXEDIR "${_DEST}/MacOS" ) endif() set( _PREFIX "${CMAKE_INSTALL_PREFIX}" ) diff --git a/mac/cmake_build.txt b/mac/cmake_build.txt new file mode 100644 index 000000000..cbbf97c7f --- /dev/null +++ b/mac/cmake_build.txt @@ -0,0 +1,141 @@ +Instructions for building on macOS using CMake. + +Building on macOS has been made much simpler with the Audacity 2.4.0 +release. Still, read this document throughly before starting. + +1) Get and install the latest Xcode version available your macOS version: + + MacOS Xcode Version (as of Mar 2020) + Catalina - 10.15 11.3 + Mojave - 10.14 10.3 + High Sierra - 10.13 9.4.1 + Sierra - 10.12 9.2 + El Capitan - 10.11 8.2.1 + Yosemite - 10.10 7.2.1 + +2) Clone the Audacity repository: + + git clone https://github.com/audacity/audacity + +3) Clone wxWidgets 3.1.1: + + git clone --recurse-submodules https://github.com/audacity/wxWidgets.git + + Ensure that you clone with the "--recurse-submodules" option, and do not + just download the Zip package, otherwise there will be required components + missing. + + Don't be tempted to use wxWidgets already installed by a package manager + such as Homebrew because this will cause problems. + + We have applied some Audacity specific patches to wxWidgets to better + support VoiceOver, so please use the audacity-fixes-3.1.1 branch. It's + the default branch on our GitHub copy: + + https://github.com/audacity/wxWidgets/tree/audacity-fixes-3.1.1 + + You can be certain the correct branch is active with: + + git checkout audacity-fixes-3.1.1 + +4) Change directory to the folder where wxWidgets was cloned and build it using: + + sudo /mac/scripts/build_wxwidgets + +5) The config command should return "3.1.1" if the install was successful: + + /usr/local/x86_64/bin/wx-config --version + +6) Now that you have wxWidgets installed, edit your .bash_profile and add: + + export WX_CONFIG=/usr/local/x86_64/bin/wx-config + +7) Download the CMake 3.16.4 DMG from: + + https://cmake.org/download + +8) Double click the DMG, follow the prompts and drag the CMake app to the + Applications folder. + + If you will be building from the command line, open the CMake application + and click the "Tools -> How to Install For Command Line Use" menu. It will + give you additional instructions on making CMake available to the command + line. + + You are now ready to start building Audacity. + +BUILDING USING THE CMAKE GUI + + NOTE: Building with the GUI interface will result in the downloading of + another copy of wxWidgets from Audacity. + +1) Open the app. + +2) Click the "Browse Source..." button and locate the top of your Audacity + source tree, then click the "Open" button. + +3) Click the "Browse Build..." button and find the location where you want to + put the build (use the "New Folder" button at the bottom left to create a + new folder). + + This folder does not have to be in or even near the source tree, but it + must not be the same as the source tree. However, it is common to make it + a subdirectory of the Audacity source tree. + +4) Click the "Configure" button and when the dialog pops up, select "Xcode" for + the generator, then click the "Done" button. + +5) Click the "Generate" button to create the Xcode project. + +6) Now you can either click the "Open Project" button or go to your "Build" folder in + Finder and open the Xcode project as normal. + +BUILDING FROM THE COMMAND LINE + +1) Change directory to your Audacity source tree. + + cd audacity + +2) Create the "build" folder (name it anything you like): + + mkdir bld + +3) Change to the "build" folder: + + cd bld + +4) Configure and generate the Xcode project: + + cmake -G Xcode .. + +5) Build Audacity using the CMake command or xcodebuild: + + cmake --build . --config Release + + xcodebuild --configuration Release + + The "Audacity.app" bundle will be in the "bin/Release" subdirectory of your + "build" folder, so you can start it via Finder or: + + open bin/Release/Audacity.app + +Notes: + + - If you'd like to get a completely clean build, just delete "build" folder + and return to step 2 above. + + - Once the Xcode project is generated, you shouldn't have to "configure" or + "generate" again as it will be done for you automatically after pulling + updates and building. + + For example: + + cd directory + git pull + cd bld + cmake --build . --config Release + + - Instructions on optional signing of DMGs, showing languages other than English, + and other useful information can be found on our wiki at: + http://wiki.audacityteam.org/wiki/Building_On_Mac + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 684cd2839..96e24b4ef 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1198,6 +1198,7 @@ elseif( CMAKE_SYSTEM_NAME MATCHES "Darwin" ) # Add the resources RESOURCE "${MAC_RESOURCES};${RESOURCES}" ) + set_target_property_all( ${TARGET} RUNTIME_OUTPUT_DIRECTORY "${_DESTDIR}" ) # These sources must be compiled as Objective C++ set_source_files_properties( @@ -1235,7 +1236,7 @@ elseif( CMAKE_SYSTEM_NAME MATCHES "Darwin" ) TARGET ${TARGET} COMMAND - sh -c "TARGET_BUILD_DIR=${_DEST} EXECUTABLE_PATH=Macos/${_EXE} FRAMEWORKS_FOLDER_PATH=Frameworks ${topdir}/mac/scripts/install_wxlibs.sh" + sh -c "TARGET_BUILD_DIR=${_DEST} EXECUTABLE_PATH=MacOS/${_EXE} FRAMEWORKS_FOLDER_PATH=Frameworks ${topdir}/mac/scripts/install_wxlibs.sh" POST_BUILD ) endif()