commit 2a80ce043ba3cf880b33c1fa01ec37796a703ace
parent 3c4cfa730280cac0a671f18b526ba32a951782ed
Author: Jean Pierre Cimalando <jp-dev@inbox.ru>
Date: Mon, 24 May 2021 02:42:34 +0200
cmake: generate the macOS namespace for pugl
Diffstat:
3 files changed, 85 insertions(+), 14 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
@@ -14,7 +14,7 @@ env:
BUILD_TYPE: Release
jobs:
- build_for_linux:
+ cmake_linux:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
@@ -40,9 +40,45 @@ jobs:
working-directory: ${{runner.workspace}}/build
run: |
cmake "$GITHUB_WORKSPACE" -G Ninja \
- -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
- -DDPF_EXAMPLES=ON
+ -DCMAKE_BUILD_TYPE="$BUILD_TYPE"
- name: Build all
shell: bash
working-directory: ${{runner.workspace}}/build
run: cmake --build . --config "$BUILD_TYPE" -j 2
+ - name: Display built files
+ shell: bash
+ working-directory: ${{runner.workspace}}/build/bin
+ run: ls -lFR
+ - uses: actions/upload-artifact@v2
+ with:
+ name: Linux artifacts
+ path: ${{runner.workspace}}/build/bin/
+
+ cmake_macos:
+ runs-on: macos-10.15
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ submodules: recursive
+ - name: Create Build Environment
+ shell: bash
+ working-directory: ${{runner.workspace}}
+ run: cmake -E make_directory build
+ - name: Configure CMake
+ shell: bash
+ working-directory: ${{runner.workspace}}/build
+ run: |
+ cmake "$GITHUB_WORKSPACE" \
+ -DCMAKE_BUILD_TYPE="$BUILD_TYPE"
+ - name: Build all
+ shell: bash
+ working-directory: ${{runner.workspace}}/build
+ run: cmake --build . --config "$BUILD_TYPE" -j 2
+ - name: Display built files
+ shell: bash
+ working-directory: ${{runner.workspace}}/build/bin
+ run: ls -lFR
+ - uses: actions/upload-artifact@v2
+ with:
+ name: macOS artifacts
+ path: ${{runner.workspace}}/build/bin/
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -7,6 +7,11 @@ cmake_minimum_required(VERSION 3.7)
project(DPF)
+# ensure c++11 at minimum, the parent project can override
+if(NOT CMAKE_CXX_STANDARD)
+ set(CMAKE_CXX_STANDARD 11)
+endif()
+
# check if we are building from this project, or are imported by another
if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(DPF_BUILD_FROM_HERE TRUE)
@@ -24,12 +29,16 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(DPF-plugin)
if(DPF_LIBRARIES)
- dpf__add_dgl_cairo()
+ if(NOT (MSVC OR APPLE)) # TODO skip this one for now
+ dpf__add_dgl_cairo()
+ endif()
dpf__add_dgl_opengl()
endif()
if(DPF_EXAMPLES)
- add_subdirectory("examples/CairoUI")
+ if(NOT (MSVC OR APPLE)) # TODO skip this one for now
+ add_subdirectory("examples/CairoUI")
+ endif()
#add_subdirectory("examples/ExternalUI")
add_subdirectory("examples/FileHandling")
add_subdirectory("examples/Info")
diff --git a/cmake/DPF-plugin.cmake b/cmake/DPF-plugin.cmake
@@ -135,6 +135,8 @@ function(dpf_add_plugin NAME)
if(_dgl_library)
dpf__add_static_library("${NAME}-ui" ${_dpf_plugin_FILES_UI})
target_link_libraries("${NAME}-ui" PUBLIC "${NAME}" ${_dgl_library})
+ # add the files containing Objective-C classes, recompiled under namespace
+ dpf__add_plugin_specific_ui_sources("${NAME}-ui")
else()
add_library("${NAME}-ui" INTERFACE)
endif()
@@ -347,13 +349,13 @@ function(dpf__add_dgl_cairo)
if(NOT APPLE)
target_sources(dgl-cairo PRIVATE
"${DPF_ROOT_DIR}/dgl/src/pugl.cpp")
- else()
- target_sources(dgl-cairo PRIVATE
- "${DPF_ROOT_DIR}/dgl/src/pugl.mm")
+ else() # Note: macOS pugl will be built as part of DistrhoUI_macOS.mm
+ #target_sources(dgl-opengl PRIVATE
+ # "${DPF_ROOT_DIR}/dgl/src/pugl.mm")
endif()
target_include_directories(dgl-cairo PUBLIC
"${DPF_ROOT_DIR}/dgl")
- target_include_directories(dgl-cairo PRIVATE
+ target_include_directories(dgl-cairo PUBLIC
"${DPF_ROOT_DIR}/dgl/src/pugl-upstream/include")
dpf__add_dgl_system_libs()
@@ -403,15 +405,19 @@ function(dpf__add_dgl_opengl)
if(NOT APPLE)
target_sources(dgl-opengl PRIVATE
"${DPF_ROOT_DIR}/dgl/src/pugl.cpp")
- else()
- target_sources(dgl-opengl PRIVATE
- "${DPF_ROOT_DIR}/dgl/src/pugl.mm")
+ else() # Note: macOS pugl will be built as part of DistrhoUI_macOS.mm
+ #target_sources(dgl-opengl PRIVATE
+ # "${DPF_ROOT_DIR}/dgl/src/pugl.mm")
endif()
target_include_directories(dgl-opengl PUBLIC
"${DPF_ROOT_DIR}/dgl")
- target_include_directories(dgl-opengl PRIVATE
+ target_include_directories(dgl-opengl PUBLIC
"${DPF_ROOT_DIR}/dgl/src/pugl-upstream/include")
+ if(APPLE)
+ target_compile_definitions(dgl-opengl PUBLIC "GL_SILENCE_DEPRECATION")
+ endif()
+
dpf__add_dgl_system_libs()
target_link_libraries(dgl-opengl PRIVATE dgl-system-libs)
@@ -422,6 +428,25 @@ function(dpf__add_dgl_opengl)
target_link_libraries(dgl-opengl PRIVATE dgl-opengl-definitions "${OPENGL_gl_LIBRARY}")
endfunction()
+# dpf__add_plugin_specific_ui_sources
+# ------------------------------------------------------------------------------
+#
+# Compile plugin-specific UI sources into the target designated by the given
+# name. There are some special considerations here:
+# - On most platforms, sources can be compiled only once, as part of DGL;
+# - On macOS, for any sources which define Objective-C interfaces, these must
+# be recompiled for each plugin under a unique namespace. In this case, the
+# name must be a plugin-specific identifier, and it will be used for computing
+# the unique ID along with the project version.
+function(dpf__add_plugin_specific_ui_sources NAME)
+ if(APPLE)
+ target_sources("${NAME}" PRIVATE
+ "${DPF_ROOT_DIR}/distrho/DistrhoUI_macOS.mm")
+ string(SHA256 _hash "${NAME}:${PROJECT_VERSION}")
+ target_compile_definitions("${NAME}" PUBLIC "PUGL_NAMESPACE=${_hash}")
+ endif()
+endfunction()
+
# dpf__add_dgl_system_libs
# ------------------------------------------------------------------------------
#
@@ -439,7 +464,8 @@ function(dpf__add_dgl_system_libs)
target_link_libraries(dgl-system-libs INTERFACE "gdi32" "comdlg32")
elseif(APPLE)
find_library(APPLE_COCOA_FRAMEWORK "Cocoa")
- target_link_libraries(dgl-system-libs INTERFACE "${APPLE_COCOA_FRAMEWORK}")
+ find_library(APPLE_COREVIDEO_FRAMEWORK "CoreVideo")
+ target_link_libraries(dgl-system-libs INTERFACE "${APPLE_COCOA_FRAMEWORK}" "${APPLE_COREVIDEO_FRAMEWORK}")
else()
find_package(X11 REQUIRED)
target_include_directories(dgl-system-libs INTERFACE "${X11_INCLUDE_DIR}")