Enable compilation with Make on macOS

• Jan 9, 2019 - 22:31
Reported version
3.x-dev
Type
Development
Frequency
Once
Severity
S5 - Suggestion
Reproducibility
Always
Status
closed
Regression
No
Workaround
No
Project

The full Xcode IDE is currently required for compilation on macOS, but it should be possible to build MuseScore with only the command line tools, which are a much smaller download than the full IDE. This means enabling support for other CMake generators on macOS (i.e. Make or Ninja).

Discussion here: https://musescore.org/en/node/281490


Comments

If you disable the precompiled headers (PCH) generation, then it basically works out of the box if the generators are set to Unix Makefiles. See for example https://github.com/AntonioBL/MuseScore/commit/cbfb86d3a7d60c259877b59de… if -DBUILD_PCH="ON" is changed to -DBUILD_PCH="OFF".
I tried to enable the compilation also with PCH, but I came to a halt when compiling mscore/macos/cocoabridge.mm
Here are my changes for the PCH:
https://github.com/AntonioBL/MuseScore/commit/cbfb86d3a7d60c259877b59de…
If I compile one of the command-line targets "release-cl" or "debug-cl", the error is:
error: Objective-C 1 was disabled in PCH file but is currently enabled
1 error generated.
make[3]: *** [mscore/CMakeFiles/mscoreapp.dir/macos/cocoabridge.mm.o] Error 1

I tried to see if it was somehow possible to "enable" the Objective-C 1 with a clang flag, but I couldn't find anything.
If I enable verbose output and manually compile cocoabridge.mm by taking the relative command and simply removing the inclusion of all.h ("-include [MuseScore build dir]/all.h"), it compiles and the whole compilation succeeds.
I thus think that a simlpe solution would be to remove the PCH for cocoabridge.mm compilation, but I do not have enough CMake experience to understand how this can be done only for this single file. I tried to fiddle with compile_flags in set_source_files_properties, but apparently it only considers the compile_flags of its parent (mscoreapp).
I fear that a CMakeLists.txt should be included in mscore/macos folder, but I don't know how to then add the cocoabridge library to the mscoreapp library, and I don't know if such a CMakeLists.txt would affect also mscore/macos/SparkleAutoUpdater.mm.

Any help, please?

P.S: I change the std from c++11 to gnu++11 because when compiling mscoreapp, CMake automatically adds "-fPIC -std=gnu++11", which are probably required by some of the library it is linked against, so there was a clash with the PCH compiled with only -std=c++11 (an error about trigraphs enabled/disabled)

Fix version
3.6.0