Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,30 @@ if(APPLE AND ENABLE_MACOS_FRAMEWORK)
set(FRAMEWORK_NAME ChapterForge)
set(FRAMEWORK_DIR ${CMAKE_CURRENT_BINARY_DIR}/${FRAMEWORK_NAME}.framework)
set(FRAMEWORK_VER_DIR ${FRAMEWORK_DIR}/Versions/A)
set(FRAMEWORK_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/${FRAMEWORK_NAME}-Info.plist)
# Ship all public headers (developers can opt into lower-level APIs).
file(GLOB FRAMEWORK_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp)

# Generate the plist at configure time. A multiline echo inside the custom target produces
# invalid Makefiles because the generated recipe contains unindented lines.
file(WRITE ${FRAMEWORK_INFO_PLIST}
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
"<plist version=\"1.0\">\n"
"<dict>\n"
" <key>CFBundleIdentifier</key><string>com.chapterforge</string>\n"
" <key>CFBundleName</key><string>ChapterForge</string>\n"
" <key>CFBundleVersion</key><string>${CHAPTERFORGE_VERSION_DISPLAY}</string>\n"
" <key>CFBundleShortVersionString</key><string>${CHAPTERFORGE_VERSION_DISPLAY}</string>\n"
"</dict>\n"
"</plist>\n")

add_custom_target(ChapterForgeFramework ALL
DEPENDS chapterforge ${FRAMEWORK_HEADERS}
COMMAND ${CMAKE_COMMAND} -E make_directory ${FRAMEWORK_VER_DIR}/Headers
COMMAND ${CMAKE_COMMAND} -E make_directory ${FRAMEWORK_VER_DIR}/Resources
# Write a minimal Info.plist carrying our version strings.
COMMAND ${CMAKE_COMMAND} -E echo "<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\n<!DOCTYPE plist PUBLIC \\\"-//Apple//DTD PLIST 1.0//EN\\\" \\\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\\\"> \n<plist version=\\\"1.0\\\"> \n<dict> \n <key>CFBundleIdentifier</key><string>com.chapterforge</string> \n <key>CFBundleName</key><string>ChapterForge</string> \n <key>CFBundleVersion</key><string>${CHAPTERFORGE_VERSION_DISPLAY}</string> \n <key>CFBundleShortVersionString</key><string>${CHAPTERFORGE_VERSION_DISPLAY}</string> \n</dict> \n</plist>" > ${FRAMEWORK_VER_DIR}/Resources/Info.plist
# Copy the generated Info.plist carrying our version strings.
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FRAMEWORK_INFO_PLIST} ${FRAMEWORK_VER_DIR}/Resources/Info.plist
# Copy the static lib into the bundle as the framework binary.
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:chapterforge> ${FRAMEWORK_VER_DIR}/${FRAMEWORK_NAME}
# Copy public headers.
Expand Down
Loading