Add macOS Cocoa port and CEF helper support
Introduce a macOS Cocoa-based UI and CEF helper subprocess support. CMake: enable OBJCXX on Apple, treat mac sources as .mm, set -fobjc-arc, link Cocoa frameworks, and generate helper app targets using a mac Info.plist template; keep libcef logical target off macOS. Implementation: add Objective-C++ implementations for browser_host and nebula_window, convert startup to ObjC++ (prepare NSApplication), add process_helper_mac (CEF helper entry) and load CEF library from main/main_bigpicture on mac. Tooling/docs: add .clangd fallback flags, compile_commands symlink helper, update cross-platform docs for mac status. Misc: add menu-popup UI page, define UNREFERENCED_PARAMETER in platform/types.h, small code cleanups (use (void)layout, include platform/types.h) and update .gitignore.
This commit is contained in:
+89
-12
@@ -1,6 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
|
||||
project(NebulaBrowser LANGUAGES CXX)
|
||||
# Enable OBJCXX early on macOS for Cocoa integration
|
||||
if(APPLE)
|
||||
project(NebulaBrowser LANGUAGES CXX OBJCXX)
|
||||
else()
|
||||
project(NebulaBrowser LANGUAGES CXX)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
@@ -56,9 +61,16 @@ if(OS_WINDOWS)
|
||||
elseif(OS_MACOSX)
|
||||
set(NEBULA_PLATFORM_SOURCES
|
||||
src/platform/mac/paths_mac.cpp
|
||||
src/platform/mac/startup_mac.cpp
|
||||
src/platform/mac/browser_host_mac.cpp
|
||||
src/platform/mac/nebula_window_mac.cpp
|
||||
src/platform/mac/startup_mac.mm
|
||||
src/platform/mac/browser_host_mac.mm
|
||||
src/platform/mac/nebula_window_mac.mm
|
||||
)
|
||||
set_source_files_properties(
|
||||
src/platform/mac/startup_mac.mm
|
||||
src/platform/mac/browser_host_mac.mm
|
||||
src/platform/mac/nebula_window_mac.mm
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-fobjc-arc"
|
||||
)
|
||||
elseif(OS_LINUX)
|
||||
set(NEBULA_PLATFORM_SOURCES
|
||||
@@ -71,7 +83,11 @@ else()
|
||||
message(FATAL_ERROR "Unsupported platform.")
|
||||
endif()
|
||||
|
||||
ADD_LOGICAL_TARGET("libcef_lib" "${CEF_LIB_RELEASE}" "${CEF_LIB_DEBUG}")
|
||||
# On macOS, CEF is a framework linked via CEF_STANDARD_LIBS.
|
||||
# On Windows/Linux, we create a logical target for libcef.
|
||||
if(NOT OS_MACOSX)
|
||||
ADD_LOGICAL_TARGET("libcef_lib" "${CEF_LIB_RELEASE}" "${CEF_LIB_DEBUG}")
|
||||
endif()
|
||||
|
||||
if(OS_LINUX)
|
||||
FIND_LINUX_LIBRARIES("X11")
|
||||
@@ -107,11 +123,19 @@ function(add_nebula_app_target nebula_target entry_source)
|
||||
"${CEF_ROOT}/include"
|
||||
)
|
||||
|
||||
target_link_libraries(${nebula_target} PRIVATE
|
||||
libcef_lib
|
||||
libcef_dll_wrapper
|
||||
${CEF_STANDARD_LIBS}
|
||||
)
|
||||
if(OS_MACOSX)
|
||||
# On macOS, CEF is a framework; don't link libcef_lib
|
||||
target_link_libraries(${nebula_target} PRIVATE
|
||||
libcef_dll_wrapper
|
||||
${CEF_STANDARD_LIBS}
|
||||
)
|
||||
else()
|
||||
target_link_libraries(${nebula_target} PRIVATE
|
||||
libcef_lib
|
||||
libcef_dll_wrapper
|
||||
${CEF_STANDARD_LIBS}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set_property(TARGET ${nebula_target} PROPERTY
|
||||
@@ -135,12 +159,19 @@ function(add_nebula_app_target nebula_target entry_source)
|
||||
COPY_FILES("${nebula_target}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR_RELEASE}" "${CEF_TARGET_OUT_DIR}")
|
||||
COPY_FILES("${nebula_target}" "${CEF_RESOURCE_FILES}" "${CEF_RESOURCE_DIR}" "${CEF_TARGET_OUT_DIR}")
|
||||
elseif(OS_MACOSX)
|
||||
target_link_libraries(${nebula_target} PRIVATE
|
||||
"-framework Cocoa"
|
||||
"-framework ApplicationServices"
|
||||
)
|
||||
set(NEBULA_APP "${CEF_TARGET_OUT_DIR}/${nebula_target}.app")
|
||||
set(NEBULA_HELPER_TARGET "${nebula_target}_Helper")
|
||||
set(NEBULA_HELPER_OUTPUT_NAME "${nebula_target} Helper")
|
||||
string(TOLOWER "${nebula_target}" NEBULA_HELPER_BUNDLE_NAME)
|
||||
|
||||
COPY_MAC_FRAMEWORK(
|
||||
"${nebula_target}"
|
||||
"Chromium Embedded Framework"
|
||||
"${CEF_BINARY_DIR_RELEASE}"
|
||||
"${NEBULA_APP}/Contents/Frameworks"
|
||||
"${NEBULA_APP}"
|
||||
)
|
||||
COPY_FILES(
|
||||
"${nebula_target}"
|
||||
@@ -154,6 +185,52 @@ function(add_nebula_app_target nebula_target entry_source)
|
||||
"${CEF_RESOURCE_DIR}"
|
||||
"${NEBULA_APP}/Contents/Resources"
|
||||
)
|
||||
|
||||
foreach(_suffix_list ${CEF_HELPER_APP_SUFFIXES})
|
||||
string(REPLACE ":" ";" _suffix_list ${_suffix_list})
|
||||
list(GET _suffix_list 0 _name_suffix)
|
||||
list(GET _suffix_list 1 _target_suffix)
|
||||
list(GET _suffix_list 2 _plist_suffix)
|
||||
|
||||
set(_helper_target "${NEBULA_HELPER_TARGET}${_target_suffix}")
|
||||
set(_helper_output_name "${NEBULA_HELPER_OUTPUT_NAME}${_name_suffix}")
|
||||
set(_helper_info_plist "${CMAKE_CURRENT_BINARY_DIR}/${_helper_target}-Info.plist")
|
||||
|
||||
file(READ "${CMAKE_SOURCE_DIR}/cmake/mac-helper-Info.plist.in" _plist_contents)
|
||||
string(REPLACE "\${EXECUTABLE_NAME}" "${_helper_output_name}" _plist_contents "${_plist_contents}")
|
||||
string(REPLACE "\${PRODUCT_NAME}" "${_helper_output_name}" _plist_contents "${_plist_contents}")
|
||||
string(REPLACE "\${HELPER_BUNDLE_NAME}" "${NEBULA_HELPER_BUNDLE_NAME}" _plist_contents "${_plist_contents}")
|
||||
string(REPLACE "\${BUNDLE_ID_SUFFIX}" "${_plist_suffix}" _plist_contents "${_plist_contents}")
|
||||
file(WRITE "${_helper_info_plist}" "${_plist_contents}")
|
||||
|
||||
add_executable(${_helper_target} MACOSX_BUNDLE
|
||||
app/process_helper_mac.cc
|
||||
src/cef/nebula_app.cpp
|
||||
)
|
||||
SET_EXECUTABLE_TARGET_PROPERTIES(${_helper_target})
|
||||
add_dependencies(${_helper_target} libcef_dll_wrapper)
|
||||
target_include_directories(${_helper_target} PRIVATE
|
||||
"${CMAKE_SOURCE_DIR}/src"
|
||||
"${CEF_ROOT}"
|
||||
"${CEF_ROOT}/include"
|
||||
)
|
||||
target_link_libraries(${_helper_target} PRIVATE
|
||||
libcef_dll_wrapper
|
||||
${CEF_STANDARD_LIBS}
|
||||
)
|
||||
set_target_properties(${_helper_target} PROPERTIES
|
||||
MACOSX_BUNDLE_INFO_PLIST "${_helper_info_plist}"
|
||||
OUTPUT_NAME "${_helper_output_name}"
|
||||
)
|
||||
|
||||
add_dependencies(${nebula_target} "${_helper_target}")
|
||||
add_custom_command(TARGET ${nebula_target} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"${CEF_TARGET_OUT_DIR}/${_helper_output_name}.app"
|
||||
"${NEBULA_APP}/Contents/Frameworks/${_helper_output_name}.app"
|
||||
VERBATIM
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# ------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user