From 4b193d43fa57192197a0c334be3e7a0914fd7fad Mon Sep 17 00:00:00 2001 From: Mark Claydon Date: Wed, 14 Nov 2018 12:44:29 +0000 Subject: [PATCH 1/2] Static build on mac building but not running --- README.md | 4 ++++ editor/CMakeLists.txt | 44 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 33619b9a..24dd8485 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,10 @@ If you want to build it statically-linked, pass the `AXIOM_STATIC_LINK` flag: ``` cmake ../path/to/source -DAXIOM_STATIC_LINK=ON -DVST2_SDK_ROOT=/path/to/vst/sdk ``` +For static linking on macOS [compile Qt statically](http://doc.qt.io/qt-5/osx-deployment.html) and install HarfBuzz, libpng and PCRE2: +``` +brew install harfbuzz libpng pcre2 +``` CMake will setup files necessary for building. If this fails, make sure you've got Cargo, Qt, LLVM, and the VST SDK installed correctly. Once complete, you can choose which backend to build: diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index 99b8716e..63511c73 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -4,7 +4,16 @@ if (AXIOM_STATIC_LINK) set(Qt5_USE_STATIC_LIBS ON) set(Qt5_USE_STATIC_RUNTIME ON) add_definitions(-DAXIOM_STATIC_BUILD=1) - set(AXIOM_LINK_FLAGS -static -static-libgcc -static-libstdc++) + + find_library(OpenGL_LIBRARY OpenGL) + set(STATIC_LIBS ${OpenGL_LIBRARY}) + + if (APPLE) + set(AXIOM_LINK_FLAGS "") + else () + set(AXIOM_LINK_FLAGS -static -static-libgcc -static-libstdc++) + endif () + else () set(AXIOM_LINK_FLAGS "") endif () @@ -36,6 +45,39 @@ add_library(axiom_editor backend/AudioConfiguration.h backend/AudioConfiguration.cpp backend/PersistentParameters.h) target_link_libraries(axiom_editor axiom_widgets axiom_model axiom_common maxim_compiler Qt5::Widgets) +if (AXIOM_STATIC_LINK) + if (APPLE) + FIND_PACKAGE(PNG REQUIRED) + list(APPEND STATIC_LIBS PNG::PNG) + + FIND_PACKAGE(harfbuzz REQUIRED) + list(APPEND STATIC_LIBS harfbuzz::harfbuzz) + + list(APPEND STATIC_LIBS /usr/local/Cellar/pcre2/10.32/lib/libpcre2-16.a) + + find_library(QTFREETYPE NAMES qtfreetype) + set_target_properties(Qt5::Core PROPERTIES INTERFACE_LINK_LIBRARIES "${QTFREETYPE}") + + list(APPEND STATIC_LIBS /usr/local/Qt-5.11.2/lib/libQt5AccessibilitySupport.a + /usr/local/Qt-5.11.2/lib/libQt5ClipboardSupport.a + /usr/local/Qt-5.11.2/lib/libQt5FontDatabaseSupport.a + /usr/local/Qt-5.11.2/lib/libQt5GraphicsSupport.a + /usr/local/Qt-5.11.2/lib/libQt5ThemeSupport.a) + + + find_package(Qt5Svg REQUIRED) + find_package(Qt5PrintSupport REQUIRED) + list(APPEND AXIOM_LINK_FLAGS -lcups) # CUPS printer interface + find_package(Qt5OpenGL REQUIRED) + qt5_use_modules(axiom_editor PrintSupport) + list(APPEND STATIC_LIBS Qt5::Core Qt5::QCocoaIntegrationPlugin + Qt5::QCocoaPrinterSupportPlugin Qt5::OpenGL Qt5::Svg) + target_link_libraries(axiom_editor "-framework Carbon" "-framework CoreFoundation" "-framework CoreServices" "-framework CoreText" "-framework Cocoa" "-framework QuartzCore" "-framework IOKit" "-framework Security") + + target_link_libraries(axiom_editor ${STATIC_LIBS}) + + endif () +endif () add_subdirectory(backend) From 33653941459eb0220ba3264af194e0b94a95667f Mon Sep 17 00:00:00 2001 From: Mark Claydon Date: Wed, 28 Nov 2018 18:01:18 +0000 Subject: [PATCH 2/2] Removed format setForeground and setFontWeight to allow static linking on macOS --- editor/CMakeLists.txt | 1 - editor/widgets/node/SyntaxHighlighter.cpp | 21 +++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index 63511c73..5396eb23 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -64,7 +64,6 @@ if (AXIOM_STATIC_LINK) /usr/local/Qt-5.11.2/lib/libQt5GraphicsSupport.a /usr/local/Qt-5.11.2/lib/libQt5ThemeSupport.a) - find_package(Qt5Svg REQUIRED) find_package(Qt5PrintSupport REQUIRED) list(APPEND AXIOM_LINK_FLAGS -lcups) # CUPS printer interface diff --git a/editor/widgets/node/SyntaxHighlighter.cpp b/editor/widgets/node/SyntaxHighlighter.cpp index ae607c81..c01a7933 100644 --- a/editor/widgets/node/SyntaxHighlighter.cpp +++ b/editor/widgets/node/SyntaxHighlighter.cpp @@ -23,8 +23,9 @@ class CachedHighlightRules { // control formatting HighlightRule controlRule; controlRule.pattern = QRegExp(R"(:(num|num\[\]|midi|midi\[\]|graph|roll|scope)\b)"); - controlRule.format.setForeground(QColor(234, 106, 89)); // red - controlRule.format.setFontWeight(QFont::Bold); + // TODO Uncomment all the *Rule.format.set* . They do not work with static linking on macOS + //controlRule.format.setForeground(QColor(234, 106, 89)); // red + //controlRule.format.setFontWeight(QFont::Bold); highlightRules.push_back(std::move(controlRule)); // function formatting @@ -36,27 +37,27 @@ class CachedHighlightRules { } HighlightRule functionRule; functionRule.pattern = QRegExp(R"(\b()" % list.join('|') % R"()\b)"); - functionRule.format.setForeground(QColor(123, 181, 247)); // blue - functionRule.format.setFontWeight(QFont::Bold); + //functionRule.format.setForeground(QColor(123, 181, 247)); // blue + //functionRule.format.setFontWeight(QFont::Bold); highlightRules.push_back(std::move(functionRule)); // number formatting HighlightRule numberRule; numberRule.pattern = QRegExp(R"(\b([0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?)\s*[kmgt]?\s*(hz|db|q|s|b)?\b)", Qt::CaseInsensitive); - numberRule.format.setForeground(QColor(193, 127, 226)); // purple - numberRule.format.setFontWeight(QFont::Bold); + //numberRule.format.setForeground(QColor(193, 127, 226)); // purple + //numberRule.format.setFontWeight(QFont::Bold); highlightRules.push_back(std::move(numberRule)); // form formatting HighlightRule formRule; formRule.pattern = QRegExp(R"(\b(none|control|osc|note|freq|beats|secs|samples|db|amp|q)\b)"); - formRule.format.setForeground(QColor(101, 216, 105)); // green - formRule.format.setFontWeight(QFont::Bold); + //formRule.format.setForeground(QColor(101, 216, 105)); // green + //formRule.format.setFontWeight(QFont::Bold); highlightRules.push_back(std::move(formRule)); - commentFormat.setForeground(QColor(121, 121, 121)); // grey - commentFormat.setFontWeight(QFont::StyleItalic); + //commentFormat.setForeground(QColor(121, 121, 121)); // grey + //commentFormat.setFontWeight(QFont::StyleItalic); // comment (single line) formatting HighlightRule commentRule;