| 1 |
# check if Xcode and CMake have the same understanding of Bundle layout |
| 2 |
|
| 3 |
enable_language(C) |
| 4 |
|
| 5 |
if(CMAKE_SYSTEM_NAME STREQUAL "iOS") |
| 6 |
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") |
| 7 |
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") |
| 8 |
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") |
| 9 |
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO") |
| 10 |
endif() |
| 11 |
|
| 12 |
if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "visionOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS") |
| 13 |
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO") |
| 14 |
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO") |
| 15 |
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") |
| 16 |
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES") |
| 17 |
endif() |
| 18 |
|
| 19 |
# App Bundle |
| 20 |
|
| 21 |
add_executable(AppBundle MACOSX_BUNDLE main.m) |
| 22 |
|
| 23 |
add_custom_target(AppBundleTest ALL |
| 24 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 25 |
"$<TARGET_FILE:AppBundle>" "$<TARGET_FILE:AppBundle>.old") |
| 26 |
|
| 27 |
add_dependencies(AppBundleTest AppBundle) |
| 28 |
|
| 29 |
# with custom extension |
| 30 |
|
| 31 |
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") |
| 32 |
add_executable(AppBundleExt MACOSX_BUNDLE main.m) |
| 33 |
set_target_properties(AppBundleExt PROPERTIES BUNDLE_EXTENSION "foo") |
| 34 |
install(TARGETS AppBundleExt BUNDLE DESTINATION FooExtension) |
| 35 |
|
| 36 |
add_custom_target(AppBundleExtTest ALL |
| 37 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 38 |
"$<TARGET_FILE:AppBundleExt>" "$<TARGET_FILE:AppBundleExt>.old") |
| 39 |
|
| 40 |
add_dependencies(AppBundleExtTest AppBundleExt) |
| 41 |
endif() |
| 42 |
|
| 43 |
# Shared Framework (not supported for iOS on Xcode < 6) |
| 44 |
|
| 45 |
if(NOT CMAKE_SYSTEM_NAME STREQUAL "iOS" OR NOT XCODE_VERSION VERSION_LESS 6) |
| 46 |
add_library(SharedFramework SHARED main.c) |
| 47 |
set_target_properties(SharedFramework PROPERTIES FRAMEWORK TRUE) |
| 48 |
|
| 49 |
add_custom_target(SharedFrameworkTest ALL |
| 50 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 51 |
"$<TARGET_BUNDLE_DIR:SharedFramework>" "$<TARGET_BUNDLE_DIR:SharedFramework>.old" |
| 52 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 53 |
"$<TARGET_BUNDLE_CONTENT_DIR:SharedFramework>" "$<TARGET_BUNDLE_CONTENT_DIR:SharedFramework>.old" |
| 54 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 55 |
"$<TARGET_FILE:SharedFramework>" "$<TARGET_FILE:SharedFramework>.old") |
| 56 |
|
| 57 |
add_dependencies(SharedFrameworkTest SharedFramework) |
| 58 |
|
| 59 |
# with custom extension |
| 60 |
|
| 61 |
add_library(SharedFrameworkExt SHARED main.c) |
| 62 |
set_target_properties(SharedFrameworkExt PROPERTIES FRAMEWORK TRUE) |
| 63 |
set_target_properties(SharedFrameworkExt PROPERTIES BUNDLE_EXTENSION "foo") |
| 64 |
install(TARGETS SharedFrameworkExt FRAMEWORK DESTINATION FooExtension) |
| 65 |
|
| 66 |
add_custom_target(SharedFrameworkExtTest ALL |
| 67 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 68 |
"$<TARGET_BUNDLE_DIR:SharedFrameworkExt>" "$<TARGET_BUNDLE_DIR:SharedFrameworkExt>.old" |
| 69 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 70 |
"$<TARGET_BUNDLE_CONTENT_DIR:SharedFrameworkExt>" "$<TARGET_BUNDLE_CONTENT_DIR:SharedFrameworkExt>.old" |
| 71 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 72 |
"$<TARGET_FILE:SharedFrameworkExt>" "$<TARGET_FILE:SharedFrameworkExt>.old") |
| 73 |
|
| 74 |
add_dependencies(SharedFrameworkExtTest SharedFrameworkExt) |
| 75 |
endif() |
| 76 |
|
| 77 |
# Static Framework (not supported for Xcode < 6) |
| 78 |
|
| 79 |
if(NOT XCODE_VERSION VERSION_LESS 6) |
| 80 |
add_library(StaticFramework STATIC main.c) |
| 81 |
set_target_properties(StaticFramework PROPERTIES FRAMEWORK TRUE) |
| 82 |
|
| 83 |
add_custom_target(StaticFrameworkTest ALL |
| 84 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 85 |
"$<TARGET_BUNDLE_DIR:StaticFramework>" "$<TARGET_BUNDLE_DIR:StaticFramework>.old" |
| 86 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 87 |
"$<TARGET_BUNDLE_CONTENT_DIR:StaticFramework>" "$<TARGET_BUNDLE_CONTENT_DIR:StaticFramework>.old" |
| 88 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 89 |
"$<TARGET_FILE:StaticFramework>" "$<TARGET_FILE:StaticFramework>.old") |
| 90 |
|
| 91 |
add_dependencies(StaticFrameworkTest StaticFramework) |
| 92 |
|
| 93 |
# with custom extension |
| 94 |
|
| 95 |
add_library(StaticFrameworkExt STATIC main.c) |
| 96 |
set_target_properties(StaticFrameworkExt PROPERTIES FRAMEWORK TRUE) |
| 97 |
set_target_properties(StaticFrameworkExt PROPERTIES BUNDLE_EXTENSION "foo") |
| 98 |
install(TARGETS StaticFrameworkExt FRAMEWORK DESTINATION StaticFooExtension) |
| 99 |
|
| 100 |
add_custom_target(StaticFrameworkExtTest ALL |
| 101 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 102 |
"$<TARGET_BUNDLE_DIR:StaticFrameworkExt>" "$<TARGET_BUNDLE_DIR:StaticFrameworkExt>.old" |
| 103 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 104 |
"$<TARGET_BUNDLE_CONTENT_DIR:StaticFrameworkExt>" "$<TARGET_BUNDLE_CONTENT_DIR:StaticFrameworkExt>.old" |
| 105 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 106 |
"$<TARGET_FILE:StaticFrameworkExt>" "$<TARGET_FILE:StaticFrameworkExt>.old") |
| 107 |
|
| 108 |
add_dependencies(StaticFrameworkExtTest StaticFrameworkExt) |
| 109 |
endif() |
| 110 |
|
| 111 |
# Bundle |
| 112 |
|
| 113 |
if(NOT CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE) |
| 114 |
add_library(Bundle MODULE main.c) |
| 115 |
set_target_properties(Bundle PROPERTIES BUNDLE TRUE) |
| 116 |
|
| 117 |
add_custom_target(BundleTest ALL |
| 118 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 119 |
"$<TARGET_BUNDLE_DIR:Bundle>" "$<TARGET_BUNDLE_DIR:Bundle>.old" |
| 120 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 121 |
"$<TARGET_BUNDLE_CONTENT_DIR:Bundle>" "$<TARGET_BUNDLE_CONTENT_DIR:Bundle>.old" |
| 122 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 123 |
"$<TARGET_FILE:Bundle>" "$<TARGET_FILE:Bundle>.old") |
| 124 |
|
| 125 |
add_dependencies(BundleTest Bundle) |
| 126 |
|
| 127 |
# with custom extension |
| 128 |
|
| 129 |
add_library(BundleExt MODULE main.c) |
| 130 |
set_target_properties(BundleExt PROPERTIES BUNDLE TRUE) |
| 131 |
set_target_properties(BundleExt PROPERTIES BUNDLE_EXTENSION "foo") |
| 132 |
install(TARGETS BundleExt LIBRARY DESTINATION FooExtension) |
| 133 |
|
| 134 |
add_custom_target(BundleExtTest ALL |
| 135 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 136 |
"$<TARGET_BUNDLE_DIR:BundleExt>" "$<TARGET_BUNDLE_DIR:BundleExt>.old" |
| 137 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 138 |
"$<TARGET_BUNDLE_CONTENT_DIR:BundleExt>" "$<TARGET_BUNDLE_CONTENT_DIR:BundleExt>.old" |
| 139 |
COMMAND ${CMAKE_COMMAND} -E copy |
| 140 |
"$<TARGET_FILE:BundleExt>" "$<TARGET_FILE:BundleExt>.old") |
| 141 |
|
| 142 |
add_dependencies(BundleExtTest BundleExt) |
| 143 |
endif() |