ONE BUILD SCRIPT TO RULE THEM ALL!
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).
This commit is contained in:
parent
4be754d3f3
commit
18f8578810
|
@ -1,4 +1,14 @@
|
|||
build/PortableApps/**/*.ini eol=crlf
|
||||
build/PortableApps/**/*.txt eol=crlf
|
||||
build/PortableApps/**/*.ini.in eol=crlf
|
||||
build/PortableApps/**/*.html eol=crlf
|
||||
build/PortableApps/**/*.html eol=crlf
|
||||
|
||||
# Shell scripts with shebang lines must have LF line endings
|
||||
*.sh text eol=lf
|
||||
*.py text eol=lf
|
||||
*.ps1 text eol=lf
|
||||
build.cmake text eol=lf
|
||||
|
||||
# Batch files need CRLF line endings
|
||||
*.bat text eol=crlf
|
||||
*.cmd text eol=crlf
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
*.autosave
|
||||
.qped
|
||||
.directory
|
||||
/builds
|
||||
/build_overrides.cmake
|
||||
build.release
|
||||
build.debug
|
||||
build.install
|
||||
|
|
13
Makefile
13
Makefile
|
@ -17,6 +17,15 @@
|
|||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#=============================================================================
|
||||
|
||||
$(warning DEPRECATION NOTICE. This method of compiling will soon be removed.)
|
||||
$(warning )
|
||||
$(warning Please use 'build.cmake' instead:)
|
||||
$(warning )
|
||||
$(warning $ $$ ./build.cmake)
|
||||
$(warning )
|
||||
$(warning See https://github.com/musescore/MuseScore/pull/7531 for details.)
|
||||
$(warning )
|
||||
|
||||
CPUS := $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null || echo 1)
|
||||
|
||||
PREFIX = "/usr/local"
|
||||
|
@ -191,7 +200,7 @@ portable: install
|
|||
|
||||
installdebug: debug
|
||||
cd build.debug \
|
||||
&& make install
|
||||
&& make install
|
||||
|
||||
uninstall:
|
||||
cd build.release \
|
||||
|
@ -231,5 +240,3 @@ unix:
|
|||
|
||||
zip:
|
||||
zip -q -r MuseScore-${VERSION}.zip * -x .git\* -x vtest/html\*
|
||||
|
||||
|
||||
|
|
|
@ -17,6 +17,15 @@
|
|||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#=============================================================================
|
||||
|
||||
$(warning DEPRECATION NOTICE. This method of compiling will soon be removed.)
|
||||
$(warning )
|
||||
$(warning Please use 'build.cmake' instead with these options:)
|
||||
$(warning )
|
||||
$(warning $ $$ cmake -P build.cmake -G "MinGW Makefiles")
|
||||
$(warning )
|
||||
$(warning See https://github.com/musescore/MuseScore/pull/7531 for details.)
|
||||
$(warning )
|
||||
|
||||
VERSION := $(cmake -P config.cmake | sed -n -e "s/^.*VERSION *//p")
|
||||
BUILD_NUMBER=""
|
||||
CPUS = %NUMBER_OF_PROCESSORS%
|
||||
|
@ -59,5 +68,3 @@ version:
|
|||
|
||||
clean:
|
||||
-rmdir /S/Q build.debug build.release win32install
|
||||
|
||||
|
||||
|
|
12
Makefile.osx
12
Makefile.osx
|
@ -17,6 +17,15 @@
|
|||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#=============================================================================
|
||||
|
||||
$(warning DEPRECATION NOTICE. This method of compiling will soon be removed.)
|
||||
$(warning )
|
||||
$(warning Please use 'build.cmake' instead with these options:)
|
||||
$(warning )
|
||||
$(warning $ $$ ./build.cmake -G Xcode)
|
||||
$(warning )
|
||||
$(warning See https://github.com/musescore/MuseScore/pull/7531 for details.)
|
||||
$(warning )
|
||||
|
||||
VERSION := $(cmake -P config.cmake | sed -n -e "s/^.*VERSION *//p")
|
||||
BUILD_NUMBER = ""
|
||||
PREFIX=../applebuild
|
||||
|
@ -104,7 +113,7 @@ ci:
|
|||
-DCRASH_REPORT_URL="${CRASH_REPORT_URL}" \
|
||||
.. -G Xcode; \
|
||||
xcodebuild -project ${XCODEPROJ} -target lrelease; \
|
||||
$(FORMATTER_START) xcodebuild -project ${XCODEPROJ} -configuration Release -target install $(FORMATTER_END);
|
||||
$(FORMATTER_START) xcodebuild -project ${XCODEPROJ} -configuration Release -target install $(FORMATTER_END);
|
||||
|
||||
#
|
||||
# clean out of source build
|
||||
|
@ -112,4 +121,3 @@ ci:
|
|||
clean:
|
||||
-rm -rf build.release build.debug build.xcode
|
||||
-rm -rf applebuild
|
||||
|
||||
|
|
29
README.md
29
README.md
|
@ -1,4 +1,4 @@
|
|||
![MuseScore](assets/musescore_logo_full.png)
|
||||
![MuseScore](assets/musescore_logo_full.png)
|
||||
Music notation and composition software
|
||||
|
||||
[![License: GPL v2](https://img.shields.io/badge/License-GPL%20v2-blue.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
|
||||
|
@ -45,30 +45,29 @@ Otherwise, you can just download the latest source release tarball from the [Rel
|
|||
cd MuseScore-x.x.x
|
||||
|
||||
### Release Build
|
||||
To compile MuseScore, type:
|
||||
To compile MuseScore for release, type:
|
||||
|
||||
make release
|
||||
cmake -P build.cmake -DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
If something goes wrong, then remove the whole build subdirectory with `make clean` and start new with `make release`.
|
||||
If something goes wrong, append the word "clean" to the above command to delete the build subdirectory:
|
||||
|
||||
cmake -P build.cmake -DCMAKE_BUILD_TYPE=Release clean
|
||||
|
||||
Then try running the first command again.
|
||||
|
||||
### Running
|
||||
To start MuseScore, type:
|
||||
|
||||
./build.release/mscore/mscore
|
||||
cmake -P build.cmake -DCMAKE_BUILD_TYPE=Release run
|
||||
|
||||
The Start Center window will appear on every invocation until you disable that setting via the "Preferences" dialog.
|
||||
|
||||
### Installing
|
||||
To install to default prefix using root user, type:
|
||||
|
||||
sudo make install
|
||||
Or run the compiled executable directly.
|
||||
|
||||
### Debug Build
|
||||
A debug version can be built by doing `make debug` instead of `make release`.
|
||||
A debug version can be built and run by replacing `-DCMAKE_BUILD_TYPE=Release`
|
||||
with `-DCMAKE_BUILD_TYPE=Debug` in the above commands.
|
||||
|
||||
To run the debug version, type:
|
||||
|
||||
./build.debug/mscore/mscore
|
||||
If you omit the `-DCMAKE_BUILD_TYPE` option entirely then `RelWithDebInfo` is
|
||||
used by default, as it provides a useful compromise between Release and Debug.
|
||||
|
||||
### Testing
|
||||
See [mtest/README.md](/mtest/README.md) or [the developer handbook](https://musescore.org/handbook/developers-handbook/finding-your-way-around/automated-tests) for instructions on how to run the test suite.
|
||||
|
|
|
@ -0,0 +1,296 @@
|
|||
#!/usr/bin/env -S cmake -P
|
||||
|
||||
# This cross-platform script automates the process of creating a build directory and
|
||||
# compiling MuseScore. Despite being written in the CMake language, you should think
|
||||
# of this file as like a shell script or batch file rather than as part of the CMake
|
||||
# project tree. As always, the project tree starts in the top-level CMakeLists.txt.
|
||||
|
||||
if(NOT DEFINED CMAKE_SCRIPT_MODE_FILE)
|
||||
file(RELATIVE_PATH SCRIPT_PATH "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_LIST_FILE}")
|
||||
message(FATAL_ERROR
|
||||
"This file is a script. You should run it with:\n"
|
||||
" \$ cmake -P ${SCRIPT_PATH} [args...]\n"
|
||||
"Don't try to use it in other CMake files with include().\n"
|
||||
"See https://cmake.org/cmake/help/latest/manual/cmake.1.html#run-a-script"
|
||||
)
|
||||
endif()
|
||||
|
||||
cmake_minimum_required(VERSION 3.16) # should match version in CMakeLists.txt
|
||||
|
||||
# CMake arguments up to '-P' (ignore these)
|
||||
set(i "1")
|
||||
while(i LESS "${CMAKE_ARGC}")
|
||||
if("${CMAKE_ARGV${i}}" STREQUAL "-P")
|
||||
math(EXPR i "${i} + 1") # ignore '-P' option
|
||||
break() # done with CMake arguments
|
||||
endif()
|
||||
math(EXPR i "${i} + 1") # next argument
|
||||
endwhile()
|
||||
|
||||
# Script arguments (store these for later processing)
|
||||
# By convention, SCRIPT_ARG[0] is the name of the script
|
||||
set(SCRIPT_ARGS "") # empty argument list
|
||||
while(i LESS "${CMAKE_ARGC}")
|
||||
list(APPEND SCRIPT_ARGS "${CMAKE_ARGV${i}}")
|
||||
math(EXPR i "${i} + 1") # next argument
|
||||
endwhile()
|
||||
|
||||
# load custom CMake functions and macros
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/build/cmake/GetUtilsFunctions.cmake") # "fn__" namespace
|
||||
|
||||
# Set the name of the build folder (just the folder name, not the full path)
|
||||
function(build_folder
|
||||
VAR_NAME # Name of variable to store build folder name
|
||||
)
|
||||
# Windows has a 260 character limit on file paths, so the build folder
|
||||
# name must be abbreviated to prevent build files exceeding this limit.
|
||||
# The limit applies to the *entire* path, not just individual components.
|
||||
# Abbreviation is not essential on other platforms but is still welcome.
|
||||
if(WIN32)
|
||||
set(PLATFORM "Win")
|
||||
elseif(APPLE)
|
||||
set(PLATFORM "Mac")
|
||||
else()
|
||||
set(PLATFORM "${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
set(GEN_SHORT "${GENERATOR}")
|
||||
string(REGEX REPLACE ".*Visual Studio ([0-9]+).*" "VS\\1" GEN_SHORT "${GEN_SHORT}")
|
||||
string(REGEX REPLACE ".*MinGW.*" "MinGW" GEN_SHORT "${GEN_SHORT}")
|
||||
string(REGEX REPLACE ".*Makefile.*" "Make" GEN_SHORT "${GEN_SHORT}")
|
||||
set(BUILD_FOLDER "${PLATFORM}-Qt${QT_VERSION}-${QT_COMPILER}-${GEN_SHORT}-${BUILD_TYPE}")
|
||||
string(REGEX REPLACE "[ /\\]" "" BUILD_FOLDER "${BUILD_FOLDER}") # remove spaces and slashes
|
||||
set("${VAR_NAME}" "${BUILD_FOLDER}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Default values for independent build variables
|
||||
set(SOURCE_PATH "${CMAKE_CURRENT_LIST_DIR}") # MuseScore repo (directory of this script)
|
||||
set(ALL_BUILDS_PATH "${SOURCE_PATH}/builds") # Where all build folders will be created
|
||||
|
||||
# CPUS
|
||||
cmake_host_system_information(RESULT CPUS QUERY NUMBER_OF_LOGICAL_CORES)
|
||||
if(NOT "${CPUS}" GREATER "0")
|
||||
include(ProcessorCount)
|
||||
ProcessorCount(CPUS)
|
||||
endif()
|
||||
|
||||
# Overrides
|
||||
# Use this file to replace build variable defaults with your own values.
|
||||
# E.g. set your own GENERATOR, BUILD_TYPE, BUILD_FOLDER, or CPUS.
|
||||
if(EXISTS "${SOURCE_PATH}/build_overrides.cmake")
|
||||
message(STATUS "Including personal build overrides")
|
||||
include("${SOURCE_PATH}/build_overrides.cmake")
|
||||
endif()
|
||||
|
||||
# QTDIR environment variable is set automatically by Qt Creator. It can also
|
||||
# be set manually in build_overrides.cmake for use with other IDEs.
|
||||
# Typical value for ENV{QTDIR}: /path/to/Qt/<version>/<compiler>
|
||||
if(DEFINED ENV{QTDIR})
|
||||
# Add selected build kit to PATH.
|
||||
if(WIN32)
|
||||
set(ENV{PATH} "$ENV{QTDIR}/bin;$ENV{PATH}") # semicolon
|
||||
else()
|
||||
set(ENV{PATH} "$ENV{QTDIR}/bin:$ENV{PATH}") # colon
|
||||
endif()
|
||||
endif()
|
||||
|
||||
fn__require_program(QMAKE Qt --version "https://musescore.org/en/handbook/developers-handbook/compilation" qmake)
|
||||
fn__set_qt_variables("${QMAKE}")
|
||||
message(STATUS "QT_LOCATION: ${QT_LOCATION}")
|
||||
message(STATUS "QT_VERSION: ${QT_VERSION}")
|
||||
message(STATUS "QT_COMPILER: ${QT_COMPILER}")
|
||||
|
||||
# Process script arguments
|
||||
set(i "1")
|
||||
list(LENGTH SCRIPT_ARGS nargs)
|
||||
while(i LESS "${nargs}")
|
||||
list(GET SCRIPT_ARGS "${i}" ARG)
|
||||
if("${ARG}" STREQUAL "clean")
|
||||
set(ARG_CLEAN "TRUE")
|
||||
elseif("${ARG}" STREQUAL "configure")
|
||||
set(ARG_CONFIGURE "TRUE")
|
||||
elseif("${ARG}" STREQUAL "build")
|
||||
set(ARG_CONFIGURE "TRUE")
|
||||
set(ARG_BUILD "TRUE")
|
||||
elseif("${ARG}" STREQUAL "install")
|
||||
set(ARG_CONFIGURE "TRUE")
|
||||
set(ARG_BUILD "TRUE")
|
||||
set(ARG_INSTALL "TRUE")
|
||||
elseif("${ARG}" STREQUAL "run")
|
||||
set(ARG_RUN "TRUE")
|
||||
else()
|
||||
# Other arguments are used by certain subprocesses in build steps
|
||||
if(ARG_RUN)
|
||||
list(APPEND RUN_ARGS "${ARG}") # args after "run" belong to Run step
|
||||
else()
|
||||
list(APPEND CONFIGURE_ARGS "${ARG}") # all other args belong to Configure step
|
||||
endif()
|
||||
endif()
|
||||
math(EXPR i "${i} + 1") # next argument
|
||||
endwhile()
|
||||
|
||||
# Default if no build steps given as arguments
|
||||
if(NOT (ARG_CLEAN OR ARG_CONFIGURE OR ARG_BUILD OR ARG_INSTALL OR ARG_RUN))
|
||||
set(ARG_CONFIGURE "TRUE")
|
||||
set(ARG_BUILD "TRUE")
|
||||
set(ARG_INSTALL "TRUE")
|
||||
endif()
|
||||
|
||||
# Default values for build variables that depend on other build variables.
|
||||
# These will only be set here if they were not already defined elsewhere,
|
||||
# e.g. by script arguments or in build_overrides.cmake.
|
||||
|
||||
fn__get_option(GENERATOR -G ${CONFIGURE_ARGS})
|
||||
if(WIN32)
|
||||
fn__set_default(GENERATOR "Visual Studio 16 2019")
|
||||
else()
|
||||
fn__set_default(GENERATOR "Unix Makefiles")
|
||||
endif()
|
||||
|
||||
fn__get_option(BUILD_TYPE -DCMAKE_BUILD_TYPE ${CONFIGURE_ARGS})
|
||||
fn__set_default(BUILD_TYPE "RelWithDebInfo")
|
||||
|
||||
if(NOT DEFINED BUILD_FOLDER)
|
||||
build_folder(BUILD_FOLDER)
|
||||
endif()
|
||||
set(BUILD_PATH "${ALL_BUILDS_PATH}/${BUILD_FOLDER}")
|
||||
|
||||
fn__get_option(INSTALL_PATH -DCMAKE_INSTALL_PREFIX ${CONFIGURE_ARGS})
|
||||
fn__set_default(INSTALL_PATH "install") # relative to BUILD_PATH
|
||||
|
||||
# MSCORE_EXECUTABLE (path relative to INSTALL_PATH)
|
||||
if(WIN32)
|
||||
fn__set_default(MSCORE_EXECUTABLE "bin/MuseScore4.exe")
|
||||
elseif(APPLE)
|
||||
fn__set_default(MSCORE_EXECUTABLE "mscore.app/Contents/MacOS/mscore")
|
||||
else()
|
||||
fn__set_default(MSCORE_EXECUTABLE "bin/mscore")
|
||||
endif()
|
||||
|
||||
# make paths absolute if they are not already
|
||||
get_filename_component(BUILD_PATH "${BUILD_PATH}" ABSOLUTE BASE_DIR "${SOURCE_PATH}")
|
||||
get_filename_component(INSTALL_PATH "${INSTALL_PATH}" ABSOLUTE BASE_DIR "${BUILD_PATH}")
|
||||
get_filename_component(MSCORE_EXECUTABLE "${MSCORE_EXECUTABLE}" ABSOLUTE BASE_DIR "${INSTALL_PATH}")
|
||||
|
||||
message(STATUS "SOURCE_PATH: ${SOURCE_PATH}")
|
||||
message(STATUS "BUILD_PATH: ${BUILD_PATH}")
|
||||
message(STATUS "INSTALL_PATH: ${INSTALL_PATH}")
|
||||
message(STATUS "MSCORE_EXECUTABLE: ${MSCORE_EXECUTABLE}")
|
||||
message(STATUS "CPUS: ${CPUS}")
|
||||
message(STATUS "GENERATOR: ${GENERATOR}")
|
||||
message(STATUS "BUILD_TYPE: ${BUILD_TYPE}")
|
||||
|
||||
list(APPEND CONFIGURE_ARGS "-G" "${GENERATOR}")
|
||||
list(APPEND CONFIGURE_ARGS "-DCMAKE_INSTALL_PREFIX=${INSTALL_PATH}")
|
||||
list(APPEND CONFIGURE_ARGS "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}")
|
||||
|
||||
if(QT_COMPILER MATCHES "_64$")
|
||||
list(APPEND CONFIGURE_ARGS "-DBUILD_64=ON")
|
||||
else()
|
||||
list(APPEND CONFIGURE_ARGS "-DBUILD_64=OFF")
|
||||
endif()
|
||||
|
||||
#### ACTUAL BUILD STEPS START HERE ####
|
||||
|
||||
# Clean - delete an existing build directory.
|
||||
#
|
||||
# We usually avoid this because performing a clean build takes much longer
|
||||
# than an incremental build, but it is occassionally necessary. If you
|
||||
# encounter errors during a build then you should try doing a clean build.
|
||||
|
||||
if(ARG_CLEAN)
|
||||
message("~~~~ Actualizing Clean step ~~~~")
|
||||
message("Deleting ${BUILD_PATH}")
|
||||
file(REMOVE_RECURSE "${BUILD_PATH}")
|
||||
endif()
|
||||
|
||||
# Configure - generate build system for the native build tool.
|
||||
#
|
||||
# We only do this explicitly on the very first build. On subsequent builds
|
||||
# the native build tool will redo the configuration if any CMake files were
|
||||
# edited. You can force this to happen by deleting CMakeCache.txt.
|
||||
|
||||
if(ARG_CONFIGURE AND NOT EXISTS "${BUILD_PATH}/CMakeCache.txt")
|
||||
message("~~~~ Actualizing Configure step ~~~~")
|
||||
file(MAKE_DIRECTORY "${BUILD_PATH}")
|
||||
if(QT_COMPILER MATCHES "msvc")
|
||||
set(CMAKE_WRAPPER "${SOURCE_PATH}/build/cmake_wrapper.bat")
|
||||
else()
|
||||
set(CMAKE_WRAPPER "cmake")
|
||||
endif()
|
||||
fn__command_string(ARGS_STR ${CONFIGURE_ARGS})
|
||||
message("CONFIGURE_ARGS: ${ARGS_STR}")
|
||||
execute_process(
|
||||
# List of CMake arguments in CONFIGURE_ARGS variable. It must be unquoted here.
|
||||
COMMAND "${CMAKE_WRAPPER}" ${CONFIGURE_ARGS} -- "${SOURCE_PATH}"
|
||||
WORKING_DIRECTORY "${BUILD_PATH}"
|
||||
RESULT_VARIABLE EXIT_STATUS
|
||||
)
|
||||
if(NOT "${EXIT_STATUS}" EQUAL "0")
|
||||
file(REMOVE "${BUILD_PATH}/CMakeCache.txt") # need to configure again next time
|
||||
message(FATAL_ERROR "Configure step failed with status ${EXIT_STATUS}. See output above for details.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Build - compile code with the native build tool.
|
||||
#
|
||||
# We always do this. We can rely on the native build tool to be efficient and
|
||||
# only (re)compile source files that have been edited since the last build.
|
||||
|
||||
if(ARG_BUILD)
|
||||
message("~~~~ Actualizing Build step ~~~~")
|
||||
execute_process(
|
||||
COMMAND cmake --build . --config "${BUILD_TYPE}" --parallel "${CPUS}"
|
||||
WORKING_DIRECTORY "${BUILD_PATH}"
|
||||
RESULT_VARIABLE EXIT_STATUS
|
||||
)
|
||||
if(NOT "${EXIT_STATUS}" EQUAL "0")
|
||||
message(FATAL_ERROR "Build step failed with status ${EXIT_STATUS}. See output above for details.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Install - move compiled files to destination folders.
|
||||
#
|
||||
# Again, we always do this and rely on the tool itself to be efficient and
|
||||
# only install files that have changed since last time.
|
||||
|
||||
if(ARG_INSTALL)
|
||||
message("~~~~ Actualizing Install step ~~~~")
|
||||
execute_process(
|
||||
COMMAND cmake --install . --config "${BUILD_TYPE}"
|
||||
WORKING_DIRECTORY "${BUILD_PATH}"
|
||||
RESULT_VARIABLE EXIT_STATUS
|
||||
)
|
||||
if(NOT "${EXIT_STATUS}" EQUAL "0")
|
||||
message(FATAL_ERROR "Install step failed with status ${EXIT_STATUS}. See output above for details.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Run - attempt to run the compiled program within the installation folder.
|
||||
#
|
||||
# The working directory is unchanged. Use build_override.cmake to set the
|
||||
# CMake variable RUN_ARGS to contain a list of arguments to pass to MuseScore
|
||||
# on the command line. In addition, script arguments after "run" will be
|
||||
# appened to this list, but note that certain arguments cannot be passed this
|
||||
# way (e.g. --help, --version) because they cancel CMake script processing.
|
||||
|
||||
if(ARG_RUN)
|
||||
message("~~~~ Actualizing Run step ~~~~")
|
||||
if(WIN32)
|
||||
set(CMD "cmd.exe" "/c") # allow CMake to launch a GUI application
|
||||
else()
|
||||
set(CMD "") # not an issue on other platforms
|
||||
endif()
|
||||
fn__command_string(ARGS_STR ${RUN_ARGS})
|
||||
message("RUN_ARGS: ${ARGS_STR}")
|
||||
execute_process(
|
||||
# List of MuseScore arguments in RUN_ARGS variable. It must be unquoted here.
|
||||
COMMAND ${CMD} "${MSCORE_EXECUTABLE}" ${RUN_ARGS}
|
||||
RESULT_VARIABLE EXIT_STATUS
|
||||
)
|
||||
if(NOT "${EXIT_STATUS}" EQUAL "0")
|
||||
message(FATAL_ERROR "Run step failed with status ${EXIT_STATUS}. See output above for details.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Package - create installer archive for distribution to end users.
|
||||
# TODO
|
|
@ -1,26 +1,3 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
# MIT License (a.k.a. the "Expat License")
|
||||
#
|
||||
# Copyright (c) 2019 Peter Jonas
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
###############################################################################
|
||||
# This file contains generic functions that are useful for any CMake project.
|
||||
# Function names start with "fn__" so you can recognise them in other files.
|
||||
#
|
||||
|
@ -45,6 +22,61 @@
|
|||
set(_FUNCTIONS_FILE "${CMAKE_CURRENT_LIST_FILE}") # path to this file
|
||||
set(_FUNCTIONS_DIR "${CMAKE_CURRENT_LIST_DIR}") # path to this directory
|
||||
|
||||
# Set a variable to a value only if the variable is currently undefined.
|
||||
function(fn__set_default
|
||||
NAMEV # Name of the variable to set.
|
||||
VALUE # Value to assign to the variable.
|
||||
)
|
||||
if(NOT DEFINED "${NAMEV}")
|
||||
set("${NAMEV}" "${VALUE}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Set a variable to value of an option from a list of command line arguments.
|
||||
# The variable will only recieve a value if the relevant option was provided.
|
||||
function(fn__get_option
|
||||
VAR_NAME # Name of the variable to set.
|
||||
OPT_NAME # Name of the option to search for (e.g. "-foo").
|
||||
# ARGN... The command line arguments.
|
||||
)
|
||||
list(LENGTH ARGN LEN)
|
||||
set(i "0")
|
||||
while(i LESS "${LEN}")
|
||||
list(GET ARGN "${i}" ARG)
|
||||
if(ARG MATCHES "^${OPT_NAME}")
|
||||
if(ARG STREQUAL "${OPT_NAME}")
|
||||
# Option and value in separate arguments ("-o VALUE" or "--option VALUE")
|
||||
math(EXPR i "${i} + 1") # next argument (the value)
|
||||
list(GET ARGN "${i}" OPT_VAL)
|
||||
set("${VAR_NAME}" "${OPT_VAL}" PARENT_SCOPE)
|
||||
elseif("${OPT_NAME}" MATCHES "^-[a-zA-Z0-9]$")
|
||||
# Short option without equals sign before value ("-oVALUE")
|
||||
string(REGEX REPLACE "^${OPT_NAME}(.*)$" "\\1" OPT_VAL "${ARG}")
|
||||
set("${VAR_NAME}" "${OPT_VAL}" PARENT_SCOPE)
|
||||
elseif(ARG MATCHES "^${OPT_NAME}=")
|
||||
# Long option with equals sign before option value ("--option=VALUE")
|
||||
string(REGEX REPLACE "^${OPT_NAME}=(.*)$" "\\1" OPT_VAL "${ARG}")
|
||||
set("${VAR_NAME}" "${OPT_VAL}" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
math(EXPR i "${i} + 1") # next argument
|
||||
endwhile()
|
||||
endfunction()
|
||||
|
||||
# Turn a list of command line arguments into an escaped string
|
||||
function(fn__command_string
|
||||
VAR_NAME # The variable to store the final string.
|
||||
# ARGN ... The command line arguments.
|
||||
)
|
||||
foreach(ARG IN LISTS ARGN)
|
||||
if(ARG MATCHES " ")
|
||||
set(ARG "\"${ARG}\"")
|
||||
endif()
|
||||
set("${VAR_NAME}" "${${VAR_NAME}} ${ARG}")
|
||||
endforeach()
|
||||
set("${VAR_NAME}" "${${VAR_NAME}}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(fn__require_program # Ensure that a build dependency is installed.
|
||||
PATHV # Location of the program returned in this variable.
|
||||
PRETTY_NAME # Program name that users will recognize (e.g. "ImageMagick").
|
||||
|
@ -101,6 +133,22 @@ function(fn__require_program # Ensure that a build dependency is installed.
|
|||
endif(NOT ${PATHV})
|
||||
endfunction(fn__require_program)
|
||||
|
||||
# Get information about Qt based on the path to qmake executable
|
||||
function(fn__set_qt_variables
|
||||
QMAKE # Path to qmake executable
|
||||
)
|
||||
get_filename_component(dir "${QMAKE}" DIRECTORY)
|
||||
get_filename_component(dir "${dir}" DIRECTORY)
|
||||
set(ENV{QTDIR} "${dir}")
|
||||
get_filename_component(QT_COMPILER "${dir}" NAME)
|
||||
get_filename_component(dir "${dir}" DIRECTORY)
|
||||
get_filename_component(QT_VERSION "${dir}" NAME)
|
||||
get_filename_component(dir "${dir}" DIRECTORY)
|
||||
set(QT_LOCATION "${dir}" PARENT_SCOPE)
|
||||
set(QT_VERSION "${QT_VERSION}" PARENT_SCOPE)
|
||||
set(QT_COMPILER "${QT_COMPILER}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(fn__copy_during_build # copy a file at build time
|
||||
SOURCE_FILE # relative or absolute path to file being copied
|
||||
DEST_FILE # relative or absolute path to the new copy
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
@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 %*
|
|
@ -1,25 +1,25 @@
|
|||
@echo off
|
||||
|
||||
set OLD_DIR=%CD%
|
||||
|
||||
echo TRANSLATIONS = \
|
||||
for /r %1/share/locale/ %%a in (mscore_*.ts) do echo %%a \
|
||||
echo.
|
||||
|
||||
cd /d %1
|
||||
|
||||
echo FORMS = \
|
||||
for /r %1 %%a in (*.ui) do echo %%a \
|
||||
echo.
|
||||
|
||||
echo SOURCES = \
|
||||
for /r %1 %%a in (*.cpp) do echo %%a \
|
||||
echo.
|
||||
echo.
|
||||
|
||||
echo RESOURCES = \
|
||||
echo ./mu4/scenes/palette/palette.qrc \
|
||||
echo ./telemetry/telemetry_resources.qrc \
|
||||
echo.
|
||||
|
||||
cd /d %OLD_DIR%
|
||||
@echo off
|
||||
|
||||
set OLD_DIR=%CD%
|
||||
|
||||
echo TRANSLATIONS = \
|
||||
for /r %1/share/locale/ %%a in (mscore_*.ts) do echo %%a \
|
||||
echo.
|
||||
|
||||
cd /d %1
|
||||
|
||||
echo FORMS = \
|
||||
for /r %1 %%a in (*.ui) do echo %%a \
|
||||
echo.
|
||||
|
||||
echo SOURCES = \
|
||||
for /r %1 %%a in (*.cpp) do echo %%a \
|
||||
echo.
|
||||
echo.
|
||||
|
||||
echo RESOURCES = \
|
||||
echo ./mu4/scenes/palette/palette.qrc \
|
||||
echo ./telemetry/telemetry_resources.qrc \
|
||||
echo.
|
||||
|
||||
cd /d %OLD_DIR%
|
||||
|
|
Loading…
Reference in New Issue