diff --git a/Sources/Plasma/Apps/plClient/CMakeLists.txt b/Sources/Plasma/Apps/plClient/CMakeLists.txt index 3b5272fda3..72b9ace7a8 100644 --- a/Sources/Plasma/Apps/plClient/CMakeLists.txt +++ b/Sources/Plasma/Apps/plClient/CMakeLists.txt @@ -130,7 +130,10 @@ plasma_executable(plClient CLIENT INSTALL_PDB ) if(APPLE) - target_sources(plClient PRIVATE ${plClient_IBSOURCES}) + # We need to filter out the XIB files so the source XML files don't get bundled + set(plClient_XCODE_RESOURCES ${plClient_RESOURCES}) + list(FILTER plClient_XCODE_RESOURCES EXCLUDE REGEX "\\.xib$") + set_target_properties(plClient PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Mac-Cocoa/Info.plist.in" # Hard coding the app name here intentionally. @@ -142,7 +145,7 @@ if(APPLE) MACOSX_BUNDLE_GUI_IDENTIFIER org.Huru.UruExplorer MACOSX_BUNDLE_BUNDLE_VERSION "0.1" MACOSX_BUNDLE_SHORT_VERSION_STRING "0.1" - RESOURCE "${plClient_RESOURCES} ${plClient_IBSOURCES}" + RESOURCE "${plClient_XCODE_RESOURCES}" XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME AppIcon XCODE_ATTRIBUTE_MTL_FAST_MATH "YES" XCODE_ATTRIBUTE_MTL_ENABLE_DEBUG_INFO[variant=Debug] "INCLUDE_SOURCE" diff --git a/cmake/PlasmaTargets.cmake b/cmake/PlasmaTargets.cmake index d79fd1b1c2..dbdd6495ca 100644 --- a/cmake/PlasmaTargets.cmake +++ b/cmake/PlasmaTargets.cmake @@ -17,6 +17,13 @@ cmake_dependent_option( OFF ) +if(APPLE AND NOT CMAKE_GENERATOR STREQUAL "Xcode") + find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin") + if(NOT IBTOOL) + message(SEND_ERROR "Could not find Xcode's ibtool to process .xib files") + endif() +endif() + function(plasma_executable TARGET) cmake_parse_arguments(PARSE_ARGV 1 _pex "WIN32;CLIENT;TOOL;QT_GUI;EXCLUDE_FROM_ALL;NO_SANITIZE;INSTALL_PDB" @@ -65,6 +72,27 @@ function(plasma_executable TARGET) plasma_sanitize_target(${TARGET}) endif() + # Xcode will automatically run ibtool to compile the XIB files into NIB + # resources, but if we're generating Makefiles or Ninja projects then we + # need to handle that ourselves... + if(APPLE AND _pex_CLIENT) + foreach(SRCFILE IN LISTS _pex_SOURCES) + get_filename_component(SRCEXTENSION ${SRCFILE} LAST_EXT) + + if(CMAKE_GENERATOR STREQUAL "Xcode" AND ${SRCEXTENSION} STREQUAL ".xib") + set_source_files_properties(${SRCFILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + elseif(${SRCEXTENSION} STREQUAL ".xib") + set_source_files_properties(${SRCFILE} PROPERTIES HEADER_FILE_ONLY ON) + get_filename_component(XIBFILENAME ${SRCFILE} NAME_WE) + add_custom_command(TARGET ${TARGET} POST_BUILD + COMMAND ${IBTOOL} --output-format human-readable-text --compile "$/Resources/${XIBFILENAME}.nib" "${CMAKE_CURRENT_SOURCE_DIR}/${SRCFILE}" + COMMENT "Compiling ${SRCFILE} to ${XIBFILENAME}.nib" + VERBATIM + ) + endif() + endforeach() + endif() + if(DEFINED install_destination) install(TARGETS ${TARGET} DESTINATION ${install_destination}) if(_pex_INSTALL_PDB AND WIN32 AND NOT MINGW)