From f188e6eb1cee5c1dc85a474c14f512e57c8212ad Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sat, 31 Oct 2020 19:59:46 +0100 Subject: [PATCH] Fix osx compilation and CI --- .gitlab-ci.yml | 4 ++-- CMakeLists.txt | 13 +++++++++++-- ScreenPlay/CMakeLists.txt | 7 +++++-- ScreenPlay/app.cpp | 6 +++++- ScreenPlayWallpaper/CMakeLists.txt | 6 +++++- Tools/build.py | 4 ++-- 6 files changed, 30 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ca641879..9d76abf2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -55,7 +55,7 @@ build:osx_debug: - check script: - cd Tools - - python build.py -t debug + - python3 build.py -t debug artifacts: expire_in: '4 weeks' paths: @@ -70,7 +70,7 @@ build:osx_release: - check script: - cd Tools - - python build.py -t release + - python3 build.py -t release artifacts: expire_in: '4 weeks' paths: diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ce3fe9e..9041b3a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,15 @@ elseif(APPLE) set(VCPKG_ARCH "x64-osx") endif() +# assume built-in pthreads on MacOS https://stackoverflow.com/questions/54587052/cmake-on-mac-could-not-find-threads-missing-threads-found +if(APPLE) + set(CMAKE_THREAD_LIBS_INIT "-lpthread") + set(CMAKE_HAVE_THREADS_LIBRARY 1) + set(CMAKE_USE_WIN32_THREADS_INIT 0) + set(CMAKE_USE_PTHREADS_INIT 1) + set(THREADS_PREFER_PTHREAD_FLAG ON) +endif() + set(VCPKG_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../ScreenPlay-vcpkg") set(VCPKG_INSTALLED_PATH "${VCPKG_PATH}/installed/${VCPKG_ARCH}") set(QT_TELEMTRY_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/Common/qt-google-analytics/) @@ -48,8 +57,8 @@ execute_process( add_compile_definitions(COMPILE_INFO="${BUILD_DATE} + ${GIT_COMMIT_HASH}") -if(UNIX) - # Fixes QWebEngine linker errors +if(UNIX AND NOT APPLE) + # Fixes QWebEngine linker errors on Ubuntu 20.04 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold") endif() diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index 30a78486..1bf5ef68 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -120,6 +120,9 @@ if(WIN32) configure_file(${VCPKG_INSTALLED_PATH}/tools/sentry-native/crashpad_handler.exe ${CMAKE_BINARY_DIR}/bin/ COPYONLY) elseif(APPLE) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffmpeg ${CMAKE_BINARY_DIR}/bin/ COPYONLY) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffprobe ${CMAKE_BINARY_DIR}/bin/ COPYONLY) + # cmake-format: off + # Auto ffmpeg download missing for osx + #configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffmpeg ${CMAKE_BINARY_DIR}/bin/ COPYONLY) + #configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffprobe ${CMAKE_BINARY_DIR}/bin/ COPYONLY) + # cmake-format: on endif() diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index e76e2e3d..4a54cb71 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -217,16 +217,20 @@ void App::exit() bool App::loadSteamPlugin() { + #ifdef Q_OS_MACOS const QString fileSuffix = ".dylib"; #endif + #ifdef Q_OS_WIN #ifdef QT_NO_DEBUG const QString fileSuffix = ".dll"; #else const QString fileSuffix = "d.dll"; #endif -#else +#endif + +#ifdef Q_OS_LINUX const QString fileSuffix = ".so"; #endif diff --git a/ScreenPlayWallpaper/CMakeLists.txt b/ScreenPlayWallpaper/CMakeLists.txt index 12deffb6..b3709cee 100644 --- a/ScreenPlayWallpaper/CMakeLists.txt +++ b/ScreenPlayWallpaper/CMakeLists.txt @@ -13,7 +13,7 @@ if(WIN32) set(headers_plattform src/windowsdesktopproperties.h src/winwindow.h) elseif(APPLE) set(src_plattform src/macintegration.cpp src/macwindow.cpp) - set(headers_plattform src/macintegration.h src/macbridge.h src/macwindow.h) + set(headers_plattform src/macintegration.h src/macbridge.h src/macwindow.h src/MacBridge.mm) elseif(UNIX) set(src_plattform main.cpp src/linuxwindow.cpp) set(headers_plattform src/linuxwindow.h) @@ -35,3 +35,7 @@ add_executable(${PROJECT_NAME} ${src} ${headers} ${src_plattform} ${headers_plat set_property(TARGET ${PROJECT_NAME} PROPERTY WIN32_EXECUTABLE true) target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Quick Qt5::Gui Qt5::Widgets Qt5::Core Qt5::WebEngine ScreenPlaySDK) + +if(APPLE) + target_link_libraries(${PROJECT_NAME} PRIVATE "-framework Cocoa") +endif() diff --git a/Tools/build.py b/Tools/build.py index db8260c1..3549b782 100644 --- a/Tools/build.py +++ b/Tools/build.py @@ -56,14 +56,14 @@ elif platform == "darwin": cmake_target_triplet = "x64-osx" print("Executing install_dependencies_linux_mac.sh") os.system("chmod +x install_dependencies_linux_mac.sh") - os.system("install_dependencies_linux_mac.sh") + os.system("./install_dependencies_linux_mac.sh") elif platform == "linux": deploy_executable = "linuxdeployqt" cmake_prefix_path = "~/Qt/" cmake_target_triplet = "x64-linux" print("Executing install_dependencies_linux_mac.sh") os.system("chmod +x install_dependencies_linux_mac.sh") - os.system("install_dependencies_linux_mac.sh") + os.system("./install_dependencies_linux_mac.sh") # REMOVE OLD BUILD FOLDER cwd = os.getcwd()