18f8578810
Adds a cross-platform script that automates the process of creating a build directory and compiling MuseScore. Run the script like this: $ cmake -P build.cmake [args...] This works in all shells on all platforms. Developers with a Unix-like environment (including Git Bash on Windows) can also use: $ ./build.cmake [args...] Build step arguments: clean Delete the build directory. configure Create a build directory and run CMake inside it. build Compile code using the native build tool. install Copy compiled files to final destinations. run Run the installed program. Each step implies all previous steps except 'clean' and 'run', which are only performed when explictly requested. If no steps are given then the configure, build, and install steps are performed by default. All other arguments are passed to CMake during configuration. Example command: $ cmake -P build.cmake -GNinja -DCMAKE_BUILD_TYPE=Debug $ cmake -P build.cmake -GNinja -DCMAKE_BUILD_TYPE=Debug run -F This creates and installs a Debug build using the Ninja generator, and then runs the compiled program with the -F option to perform a factory reset, thereby ensuring it is in the initial state. Overrides: If you frequently need to build with non-default settings then you can create a file build_overrides.cmake with all your personal settings to avoid having to pass them in on the command line each time. # build_overrides.cmake example file set(ENV{QTDIR} "$ENV{HOME}/Qt/5.15.2/gcc_64") list(APPEND CONFIGURE_ARGS -GNinja -DCMAKE_BUILD_TYPE=Debug) This file is ignored by Git to prevent it being shared with other developers, but you could always copy another file into its place (e.g. during a CI build on GitHub Actions).
28 lines
1.1 KiB
Batchfile
28 lines
1.1 KiB
Batchfile
@echo off
|
|
setlocal EnableDelayedExpansion
|
|
|
|
rem Please only use this file to do things that absolutely cannot be done within build.cmake,
|
|
rem such as CALL a batch file to set environment variables in the current process. This is not
|
|
rem the same as executing a batch file, which would set environment variables in a subprocess.
|
|
|
|
set "TARGET_PROCESSOR_BITS=64"
|
|
:loop
|
|
rem CMD splits arguments on equals sign, so -DFOO=BAR is treated as -DFOO and BAR
|
|
if "%~1%~2" == "" goto continue
|
|
if "%~1=%~2" == "-DBUILD_64=OFF" set "TARGET_PROCESSOR_BITS=32"
|
|
shift
|
|
goto loop
|
|
:continue
|
|
echo "TARGET_PROCESSOR_BITS: %TARGET_PROCESSOR_BITS%"
|
|
|
|
echo "Setup VS Environment"
|
|
set VSWHERE="C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"
|
|
for /f "usebackq tokens=*" %%i in (`%VSWHERE% -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
|
|
set VS_INSTALL_DIR=%%i
|
|
)
|
|
echo "VS_INSTALL_DIR: %VS_INSTALL_DIR%"
|
|
echo "PATH: %PATH%"
|
|
|
|
CALL "%VS_INSTALL_DIR%\VC\Auxiliary\Build\vcvars%TARGET_PROCESSOR_BITS%.bat"
|
|
|
|
cmake %*
|