Skip to content

Commit

Permalink
feat: improve development experience for demo project on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
tishion committed Jan 17, 2025
1 parent b72c428 commit bc4f52a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# The main config file for QCefView
#
cmake_minimum_required(VERSION 3.18)
cmake_minimum_required(VERSION 3.21)
project(QCefView)

set(CMAKE_FOLDER "QCefView")
Expand Down
20 changes: 9 additions & 11 deletions example/QCefViewTest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 3.18)
project(QCefViewTest)

set(CMAKE_FOLDER "Example")
Expand Down Expand Up @@ -156,7 +155,7 @@ if(OS_LINUX)
PRIVATE

# On linux platform and debug mode, libcef.so MUST be loaded before libc.so.
# Gnerally we can achive this by using LD_PRELOAD=libcef.so, but this is not
# Generally we can achieve this by using LD_PRELOAD=libcef.so, but this is not
# convenience for debugging.
# Thus, here we do a trick to make sure the load order
"-Wl,--no-as-needed $<TARGET_FILE_DIR:QCefView>/$<TARGET_FILE_NAME:libcef_lib>"
Expand Down Expand Up @@ -220,10 +219,9 @@ if(OS_MACOS)
MACOSX_BUNDLE_INFO_PLIST "${QCefViewTest_INFO_PLIST_FILE}"
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.cefview.qcefviewtest"
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/../Frameworks"

# the below two properties need CMake >= 3.20.0, we just copy the framework by post build command
# XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY "YES"
# XCODE_EMBED_FRAMEWORKS "${CMAKE_BINARY_DIR}/output/${CMAKE_BUILD_TYPE}/bin/QCefView.framework"
XCODE_LINK_BUILD_PHASE_MODE "KNOWN_LOCATION"
XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY "YES"
XCODE_EMBED_FRAMEWORKS "${CMAKE_BINARY_DIR}/output/${CMAKE_BUILD_TYPE}/bin/QCefView.framework"
)

add_custom_command(TARGET ${PROJECT_NAME}
Expand All @@ -232,10 +230,10 @@ if(OS_MACOS)
# remove the old framework from the bundle if exists then copy the new one
# the below tow commands can be removed if you use CMake >= 3.20.0 and set the
# following target propertis XCODE_EMBED_FRAMEWORKS, XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY
COMMAND rm -fr "$<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/Frameworks/QCefView.framework"
COMMAND ${CMAKE_COMMAND} -E copy_directory
"$<TARGET_BUNDLE_DIR:QCefView>"
"$<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/Frameworks/QCefView.framework"
# COMMAND rm -fr "$<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/Frameworks/QCefView.framework"
# COMMAND ${CMAKE_COMMAND} -E copy_directory
# "$<TARGET_BUNDLE_DIR:QCefView>"
# "$<TARGET_BUNDLE_CONTENT_DIR:${PROJECT_NAME}>/Frameworks/QCefView.framework"

# copy the webres to the bundle
COMMAND ${CMAKE_COMMAND} -E copy_directory
Expand All @@ -259,7 +257,7 @@ if(OS_MACOS)
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
QCefView
$<TARGET_BUNDLE_DIR:QCefView>
)
endif()

Expand Down
13 changes: 0 additions & 13 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,6 @@ You can find the latest documentation here:

It can help you quickly understand how to use it.

## Note For Debugging With Xcode

if you want to debug the project with Xcode, you need to take some action to make sure the demo project could load QCefView at correct location.

1. Generate project with cmake
2. Build demo project with xcode, do not run (actually you will encounter errors if you run directly)
3. Go to the **Build Phases** for target QCefViewDemo and perform the actions below
- remove all items under **Target Dependencies**
- remove all items under **Link Binary With Libraries**
4. Now you can debug demo project in Xcode without errors

if you re-generated the project, please remember to re-do the instructions above

## About OSR mode

QCefView supports CEF offscreen rendering mode and this feature is enabled by default at runtime, to disable OSR mode you need to set the config item setWindowlessRenderingEnabled to false
Expand Down

0 comments on commit bc4f52a

Please sign in to comment.