Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Setup for macOS framework and app bundle
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Jun 6, 2023
1 parent 2f92bc7 commit 96c8070
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
45 changes: 36 additions & 9 deletions CMakeLists.txt
Expand Up @@ -17,8 +17,12 @@ set_property(GLOBAL PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
#######################################################################################################################
# Find Qt

if(APPLE)
set(MODULES_FIXME PrintSupport)
endif()

find_package(PkgConfig REQUIRED)
find_package(Qt5 COMPONENTS REQUIRED Core Widgets)
find_package(Qt5 COMPONENTS REQUIRED Core Widgets ${MODULES_FIXME})

if(NOT (APPLE OR WIN32))
find_package(X11 REQUIRED)
Expand All @@ -30,13 +34,23 @@ endif()
#######################################################################################################################
# Import carla stuff

set(CARLA_BUILD_FRAMEWORKS TRUE CACHE BOOL "Build Carla libs as frameworks")
add_subdirectory(carla/cmake)

#######################################################################################################################
# Setup Chibi target

add_executable(Chibi)

set_target_properties(Chibi
PROPERTIES
AUTOMOC ON
AUTOUIC ON
AUTORCC ON
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)

target_compile_definitions(Chibi
PRIVATE
$<$<BOOL:${X11_FOUND}>:HAVE_X11>
Expand All @@ -61,8 +75,9 @@ target_link_libraries(Chibi
carla::utils
Qt5::Core
Qt5::Widgets
$<$<BOOL:${APPLE}>:$<LINK_LIBRARY:Qt5::PrintSupport>>
$<$<BOOL:${APPLE}>:$<LINK_LIBRARY:FRAMEWORK,Cocoa.framework>>
$<$<BOOL:${X11_FOUND}>:Qt::X11Extras>
$<$<BOOL:${X11_FOUND}>:Qt5::X11Extras>
$<$<BOOL:${X11_FOUND}>:X11>
)

Expand All @@ -78,15 +93,27 @@ target_sources(Chibi
$<$<BOOL:${WIN32}>:carla/resources/ico/carla.rc>
)

set_target_properties(Chibi
PROPERTIES
AUTOMOC ON
AUTOUIC ON
AUTORCC ON
)

if(APPLE)
set_source_files_properties(
chibiembedwidget.cpp
PROPERTIES COMPILE_FLAGS -ObjC++)

get_target_property(QtWidgetsLocation Qt5::Widgets LIB_LOCATION)
get_filename_component(QtPluginsDir "${QtWidgetsLocation}/../../qt5/plugins" ABSOLUTE)

add_custom_command(TARGET Chibi POST_BUILD
COMMAND ln -sf cmake "${CMAKE_CURRENT_BINARY_DIR}/carla/lib"
)
add_custom_command(TARGET Chibi POST_BUILD
COMMAND macdeployqt $<TARGET_BUNDLE_DIR:Chibi>
)
add_custom_command(TARGET Chibi POST_BUILD
COMMAND mkdir -p "$<TARGET_BUNDLE_DIR:Chibi>/Contents/PlugIns/platforms" "$<TARGET_BUNDLE_DIR:Chibi>/Contents/PlugIns/styles"
)
add_custom_command(TARGET Chibi POST_BUILD
COMMAND cp "${QtPluginsDir}/platforms/libqcocoa.dylib" "$<TARGET_BUNDLE_DIR:Chibi>/Contents/PlugIns/platforms/"
)
add_custom_command(TARGET Chibi POST_BUILD
COMMAND cp "${QtPluginsDir}/styles/libqmacstyle.dylib" "$<TARGET_BUNDLE_DIR:Chibi>/Contents/PlugIns/styles/"
)
endif()

0 comments on commit 96c8070

Please sign in to comment.