Skip to content

Commit

Permalink
Support XIB compiling for non-Xcode projects
Browse files Browse the repository at this point in the history
  • Loading branch information
dpogue committed Nov 6, 2023
1 parent ba99ebc commit 4035cf6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cmake/PlasmaTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,31 @@ 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 (_pex_CLIENT 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()

foreach(SRCFILE IN LISTS _pex_SOURCES)
get_filename_component(SRCEXTENSION ${SRCFILE} LAST_EXT)
if (NOT ${SRCEXTENSION} STREQUAL ".xib")
continue()
endif()

get_filename_component(XIBFILENAME ${SRCFILE} NAME_WE)
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${IBTOOL} --output-format human-readable-text --compile "$<TARGET_BUNDLE_CONTENT_DIR:${TARGET}>/Resources/${XIBFILENAME}.nib" "${CMAKE_CURRENT_SOURCE_DIR}/${SRCFILE}"
COMMENT "Compiling ${SRCFILE} to ${XIBFILENAME}.nib"
VERBATIM
)
set_source_files_properties(${SRCFILE} PROPERTIES HEADER_FILE_ONLY ON)
endforeach()
endif()

if(DEFINED install_destination)
install(TARGETS ${TARGET} DESTINATION ${install_destination})
if(_pex_INSTALL_PDB AND WIN32 AND NOT MINGW)
Expand Down

0 comments on commit 4035cf6

Please sign in to comment.