diff options
| author | manuel <manuel@mausz.at> | 2020-07-02 23:09:26 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2020-07-02 23:09:26 +0200 |
| commit | 5f8335c1e49ce108ef3481863833c98efa00411b (patch) | |
| tree | f02b5c1c9765bb6a14c8eb42bb4f81b9face0b55 /cmake/scripts/darwin_embedded | |
| parent | e317daf081a1048904fdf0b548946fa3ba6593a7 (diff) | |
| download | kodi-pvr-build-master.tar.gz kodi-pvr-build-master.tar.bz2 kodi-pvr-build-master.zip | |
Diffstat (limited to 'cmake/scripts/darwin_embedded')
| -rw-r--r-- | cmake/scripts/darwin_embedded/ArchSetup.cmake | 65 | ||||
| -rw-r--r-- | cmake/scripts/darwin_embedded/ExtraTargets.cmake | 25 | ||||
| -rw-r--r-- | cmake/scripts/darwin_embedded/Install.cmake | 135 | ||||
| -rw-r--r-- | cmake/scripts/darwin_embedded/Macros.cmake | 118 | ||||
| -rw-r--r-- | cmake/scripts/darwin_embedded/PathSetup.cmake | 7 |
5 files changed, 350 insertions, 0 deletions
diff --git a/cmake/scripts/darwin_embedded/ArchSetup.cmake b/cmake/scripts/darwin_embedded/ArchSetup.cmake new file mode 100644 index 0000000..7160da9 --- /dev/null +++ b/cmake/scripts/darwin_embedded/ArchSetup.cmake | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | if(NOT CMAKE_TOOLCHAIN_FILE) | ||
| 2 | message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE required for ios/tvos. See ${CMAKE_SOURCE_DIR}/cmake/README.md") | ||
| 3 | endif() | ||
| 4 | |||
| 5 | set(CORE_MAIN_SOURCE ${CMAKE_SOURCE_DIR}/xbmc/platform/darwin/${CORE_PLATFORM_NAME_LC}/XBMCApplication.mm) | ||
| 6 | set(PLATFORM_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/xbmc/platform/darwin/${CORE_PLATFORM_NAME_LC}/Info.plist.in) | ||
| 7 | |||
| 8 | set(ARCH_DEFINES -DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_EMBEDDED) | ||
| 9 | if(CORE_PLATFORM_NAME_LC STREQUAL tvos) | ||
| 10 | list(APPEND ARCH_DEFINES -DTARGET_DARWIN_TVOS) | ||
| 11 | else() | ||
| 12 | list(APPEND ARCH_DEFINES -DTARGET_DARWIN_IOS) | ||
| 13 | endif() | ||
| 14 | set(SYSTEM_DEFINES -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE | ||
| 15 | -D__STDC_CONSTANT_MACROS -DHAS_IOS_NETWORK -DHAS_ZEROCONF) | ||
| 16 | set(PLATFORM_DIR platform/darwin) | ||
| 17 | set(PLATFORMDEFS_DIR platform/posix) | ||
| 18 | set(CMAKE_SYSTEM_NAME Darwin) | ||
| 19 | if(WITH_ARCH) | ||
| 20 | set(ARCH ${WITH_ARCH}) | ||
| 21 | else() | ||
| 22 | if(CPU STREQUAL arm64) | ||
| 23 | set(ARCH aarch64) | ||
| 24 | else() | ||
| 25 | message(SEND_ERROR "Unknown CPU: ${CPU}") | ||
| 26 | endif() | ||
| 27 | set(CMAKE_OSX_ARCHITECTURES ${CPU}) | ||
| 28 | set(NEON True) | ||
| 29 | endif() | ||
| 30 | |||
| 31 | list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${NATIVEPREFIX}) | ||
| 32 | |||
| 33 | list(APPEND DEPLIBS "-framework CoreFoundation" "-framework CoreVideo" | ||
| 34 | "-framework CoreAudio" "-framework AudioToolbox" | ||
| 35 | "-framework QuartzCore" "-framework MediaPlayer" | ||
| 36 | "-framework CFNetwork" "-framework CoreGraphics" | ||
| 37 | "-framework Foundation" "-framework UIKit" | ||
| 38 | "-framework CoreMedia" "-framework AVFoundation" | ||
| 39 | "-framework VideoToolbox" "-lresolv" "-ObjC" | ||
| 40 | "-framework AVKit" "-framework GameController") | ||
| 41 | |||
| 42 | set(ENABLE_OPTICAL OFF CACHE BOOL "" FORCE) | ||
| 43 | |||
| 44 | # AppleTV already has built-in AirPlay support | ||
| 45 | if(CORE_PLATFORM_NAME_LC STREQUAL tvos) | ||
| 46 | set(ENABLE_AIRTUNES OFF CACHE BOOL "" FORCE) | ||
| 47 | endif() | ||
| 48 | set(CMAKE_XCODE_ATTRIBUTE_INLINES_ARE_PRIVATE_EXTERN OFF) | ||
| 49 | set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN OFF) | ||
| 50 | set(CMAKE_XCODE_ATTRIBUTE_COPY_PHASE_STRIP OFF) | ||
| 51 | |||
| 52 | include(cmake/scripts/darwin/Macros.cmake) | ||
| 53 | enable_arc() | ||
| 54 | |||
| 55 | # Xcode strips dead code by default which breaks wrapping | ||
| 56 | set(CMAKE_XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING OFF) | ||
| 57 | |||
| 58 | option(ENABLE_XCODE_ADDONBUILD "Enable Xcode automatic addon building?" OFF) | ||
| 59 | |||
| 60 | # Unify output directories for iOS/tvOS packaging scripts | ||
| 61 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CORE_BUILD_DIR}/${CORE_BUILD_CONFIG}) | ||
| 62 | foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) | ||
| 63 | string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) | ||
| 64 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CORE_BUILD_DIR}/${CORE_BUILD_CONFIG}) | ||
| 65 | endforeach() | ||
diff --git a/cmake/scripts/darwin_embedded/ExtraTargets.cmake b/cmake/scripts/darwin_embedded/ExtraTargets.cmake new file mode 100644 index 0000000..2b9980a --- /dev/null +++ b/cmake/scripts/darwin_embedded/ExtraTargets.cmake | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | if(CORE_PLATFORM_NAME_LC STREQUAL tvos) | ||
| 2 | # top shelf extension | ||
| 3 | set(TOPSHELF_EXTENSION_NAME "${APP_NAME_LC}-topshelf") | ||
| 4 | set(TOPSHELF_BUNDLE_EXTENSION appex) | ||
| 5 | set(TOPSHELF_DIR "${CMAKE_SOURCE_DIR}/xbmc/platform/darwin/tvos/TopShelf") | ||
| 6 | # same path as the output Info.plist, taken from cmGlobalXCodeGenerator::ComputeInfoPListLocation() | ||
| 7 | set(ENTITLEMENTS_OUT_PATH "${CMAKE_BINARY_DIR}/CMakeFiles/${TOPSHELF_EXTENSION_NAME}.dir/TopShelf.entitlements") | ||
| 8 | |||
| 9 | set(SOURCES | ||
| 10 | ${TOPSHELF_DIR}/ServiceProvider.m | ||
| 11 | ${TOPSHELF_DIR}/../tvosShared.m) | ||
| 12 | set(HEADERS | ||
| 13 | ${TOPSHELF_DIR}/ServiceProvider.h | ||
| 14 | ${TOPSHELF_DIR}/../tvosShared.h) | ||
| 15 | add_executable(${TOPSHELF_EXTENSION_NAME} MACOSX_BUNDLE ${SOURCES} ${HEADERS}) | ||
| 16 | |||
| 17 | configure_file(${TOPSHELF_DIR}/TopShelf.entitlements.in ${ENTITLEMENTS_OUT_PATH} @ONLY) | ||
| 18 | set_target_properties(${TOPSHELF_EXTENSION_NAME} PROPERTIES BUNDLE_EXTENSION ${TOPSHELF_BUNDLE_EXTENSION} | ||
| 19 | MACOSX_BUNDLE_INFO_PLIST ${TOPSHELF_DIR}/Info.plist.in | ||
| 20 | XCODE_PRODUCT_TYPE com.apple.product-type.tv-app-extension | ||
| 21 | XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS ${ENTITLEMENTS_OUT_PATH}) | ||
| 22 | target_link_libraries(${TOPSHELF_EXTENSION_NAME} "-framework TVServices" "-framework Foundation") | ||
| 23 | |||
| 24 | add_dependencies(${APP_NAME_LC} ${TOPSHELF_EXTENSION_NAME}) | ||
| 25 | endif() | ||
diff --git a/cmake/scripts/darwin_embedded/Install.cmake b/cmake/scripts/darwin_embedded/Install.cmake new file mode 100644 index 0000000..af18277 --- /dev/null +++ b/cmake/scripts/darwin_embedded/Install.cmake | |||
| @@ -0,0 +1,135 @@ | |||
| 1 | # IOS/TVOS packaging | ||
| 2 | if(CORE_PLATFORM_NAME_LC STREQUAL tvos) | ||
| 3 | # asset catalog | ||
| 4 | set(ASSET_CATALOG "${CMAKE_SOURCE_DIR}/xbmc/platform/darwin/tvos/Assets.xcassets") | ||
| 5 | set(ASSET_CATALOG_ASSETS Assets) | ||
| 6 | set(ASSET_CATALOG_LAUNCH_IMAGE LaunchImage) | ||
| 7 | |||
| 8 | message("generating missing asset catalog images...") | ||
| 9 | execute_process(COMMAND ${CMAKE_SOURCE_DIR}/tools/darwin/Support/GenerateMissingImages-tvos.py "${ASSET_CATALOG}" ${ASSET_CATALOG_ASSETS} ${ASSET_CATALOG_LAUNCH_IMAGE}) | ||
| 10 | |||
| 11 | target_sources(${APP_NAME_LC} PRIVATE "${ASSET_CATALOG}") | ||
| 12 | set_source_files_properties("${ASSET_CATALOG}" PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") # adds to Copy Bundle Resources build phase | ||
| 13 | |||
| 14 | # entitlements | ||
| 15 | set(ENTITLEMENTS_OUT_PATH "${CMAKE_BINARY_DIR}/CMakeFiles/${APP_NAME_LC}.dir/Kodi.entitlements") | ||
| 16 | configure_file(${CMAKE_SOURCE_DIR}/xbmc/platform/darwin/tvos/Kodi.entitlements.in ${ENTITLEMENTS_OUT_PATH} @ONLY) | ||
| 17 | |||
| 18 | set_target_properties(${APP_NAME_LC} PROPERTIES XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME ${ASSET_CATALOG_ASSETS} | ||
| 19 | XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME ${ASSET_CATALOG_LAUNCH_IMAGE} | ||
| 20 | XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS ${ENTITLEMENTS_OUT_PATH}) | ||
| 21 | |||
| 22 | else() | ||
| 23 | set(BUNDLE_RESOURCES ${CMAKE_SOURCE_DIR}/media/splash.jpg | ||
| 24 | ${CMAKE_SOURCE_DIR}/tools/darwin/packaging/media/ios/rounded/AppIcon29x29.png | ||
| 25 | ${CMAKE_SOURCE_DIR}/tools/darwin/packaging/media/ios/rounded/AppIcon29x29@2x.png | ||
| 26 | ${CMAKE_SOURCE_DIR}/tools/darwin/packaging/media/ios/rounded/AppIcon40x40.png | ||
| 27 | ${CMAKE_SOURCE_DIR}/tools/darwin/packaging/media/ios/rounded/AppIcon40x40@2x.png | ||
| 28 | ${CMAKE_SOURCE_DIR}/tools/darwin/packaging/media/ios/rounded/AppIcon50x50.png | ||
| 29 | ${CMAKE_SOURCE_DIR}/tools/darwin/packaging/media/ios/rounded/AppIcon50x50@2x.png | ||
| 30 | ${CMAKE_SOURCE_DIR}/tools/darwin/packaging/media/ios/rounded/AppIcon57x57.png | ||
| 31 | ${CMAKE_SOURCE_DIR}/tools/darwin/packaging/media/ios/rounded/AppIcon57x57@2x.png | ||
| 32 | ${CMAKE_SOURCE_DIR}/tools/darwin/packaging/media/ios/rounded/AppIcon60x60.png | ||
| 33 | ${CMAKE_SOURCE_DIR}/tools/darwin/packaging/media/ios/rounded/AppIcon60x60@2x.png | ||
| 34 | ${CMAKE_SOURCE_DIR}/tools/darwin/packaging/media/ios/rounded/AppIcon72x72.png | ||
| 35 | ${CMAKE_SOURCE_DIR}/tools/darwin/packaging/media/ios/rounded/AppIcon72x72@2x.png | ||
| 36 | ${CMAKE_SOURCE_DIR}/tools/darwin/packaging/media/ios/rounded/AppIcon76x76.png | ||
| 37 | ${CMAKE_SOURCE_DIR}/tools/darwin/packaging/media/ios/rounded/AppIcon76x76@2x.png) | ||
| 38 | |||
| 39 | target_sources(${APP_NAME_LC} PRIVATE ${BUNDLE_RESOURCES}) | ||
| 40 | foreach(file IN LISTS BUNDLE_RESOURCES) | ||
| 41 | set_source_files_properties(${file} PROPERTIES MACOSX_PACKAGE_LOCATION .) | ||
| 42 | endforeach() | ||
| 43 | |||
| 44 | target_sources(${APP_NAME_LC} PRIVATE ${CMAKE_SOURCE_DIR}/xbmc/platform/darwin/ios/LaunchScreen.storyboard) | ||
| 45 | set_source_files_properties(${CMAKE_SOURCE_DIR}/xbmc/platform/darwin/ios/LaunchScreen.storyboard PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") | ||
| 46 | |||
| 47 | endif() | ||
| 48 | |||
| 49 | # setup code signing | ||
| 50 | # dev team ID / identity (certificate) | ||
| 51 | set(DEVELOPMENT_TEAM "" CACHE STRING "Development Team") | ||
| 52 | set(CODE_SIGN_IDENTITY $<IF:$<BOOL:${DEVELOPMENT_TEAM}>,iPhone\ Developer,> CACHE STRING "Code Sign Identity") | ||
| 53 | |||
| 54 | # app provisioning profile | ||
| 55 | set(CODE_SIGN_STYLE_APP Automatic) | ||
| 56 | set(PROVISIONING_PROFILE_APP "" CACHE STRING "Provisioning profile name for the Kodi app") | ||
| 57 | if(PROVISIONING_PROFILE_APP) | ||
| 58 | set(CODE_SIGN_STYLE_APP Manual) | ||
| 59 | endif() | ||
| 60 | |||
| 61 | # top shelf provisioning profile | ||
| 62 | if(CORE_PLATFORM_NAME_LC STREQUAL tvos) | ||
| 63 | set(CODE_SIGN_STYLE_TOPSHELF Automatic) | ||
| 64 | set(PROVISIONING_PROFILE_TOPSHELF "" CACHE STRING "Provisioning profile name for the Top Shelf") | ||
| 65 | if(PROVISIONING_PROFILE_TOPSHELF) | ||
| 66 | set(CODE_SIGN_STYLE_TOPSHELF Manual) | ||
| 67 | endif() | ||
| 68 | set_target_properties(${TOPSHELF_EXTENSION_NAME} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "${CODE_SIGN_IDENTITY}" | ||
| 69 | XCODE_ATTRIBUTE_CODE_SIGN_STYLE ${CODE_SIGN_STYLE_TOPSHELF} | ||
| 70 | XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "${DEVELOPMENT_TEAM}" | ||
| 71 | XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER "${PROVISIONING_PROFILE_TOPSHELF}") | ||
| 72 | # copy extension inside PlugIns dir of the app bundle | ||
| 73 | add_custom_command(TARGET ${APP_NAME_LC} POST_BUILD | ||
| 74 | COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory $<TARGET_BUNDLE_DIR:${TOPSHELF_EXTENSION_NAME}> | ||
| 75 | $<TARGET_BUNDLE_DIR:${APP_NAME_LC}>/PlugIns/${TOPSHELF_EXTENSION_NAME}.${TOPSHELF_BUNDLE_EXTENSION} | ||
| 76 | MAIN_DEPENDENCY ${TOPSHELF_EXTENSION_NAME}) | ||
| 77 | endif() | ||
| 78 | set_target_properties(${APP_NAME_LC} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "${CODE_SIGN_IDENTITY}" | ||
| 79 | XCODE_ATTRIBUTE_CODE_SIGN_STYLE ${CODE_SIGN_STYLE_APP} | ||
| 80 | XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "${DEVELOPMENT_TEAM}" | ||
| 81 | XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER "${PROVISIONING_PROFILE_APP}") | ||
| 82 | |||
| 83 | # Create xcode target that allows to build binary-addons. | ||
| 84 | if(ADDONS_TO_BUILD) | ||
| 85 | set(_addons "ADDONS=${ADDONS_TO_BUILD}") | ||
| 86 | endif() | ||
| 87 | add_custom_target(binary-addons | ||
| 88 | COMMAND $(MAKE) -C ${CMAKE_SOURCE_DIR}/tools/depends/target/binary-addons clean | ||
| 89 | COMMAND $(MAKE) -C ${CMAKE_SOURCE_DIR}/tools/depends/target/binary-addons VERBOSE=1 V=99 | ||
| 90 | INSTALL_PREFIX="${CMAKE_BINARY_DIR}/addons" CROSS_COMPILING=yes ${_addons}) | ||
| 91 | if(ENABLE_XCODE_ADDONBUILD) | ||
| 92 | add_dependencies(${APP_NAME_LC} binary-addons) | ||
| 93 | endif() | ||
| 94 | unset(_addons) | ||
| 95 | |||
| 96 | add_custom_command(TARGET ${APP_NAME_LC} POST_BUILD | ||
| 97 | # TODO: Remove in sync with CopyRootFiles-darwin_embedded expecting the ".bin" file | ||
| 98 | COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${APP_NAME_LC}> | ||
| 99 | $<TARGET_FILE_DIR:${APP_NAME_LC}>/${APP_NAME}.bin | ||
| 100 | |||
| 101 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/DllPaths_generated.h | ||
| 102 | ${CMAKE_BINARY_DIR}/xbmc/DllPaths_generated.h | ||
| 103 | COMMAND "ACTION=build" | ||
| 104 | "APP_NAME=${APP_NAME}" | ||
| 105 | "XBMC_DEPENDS=${DEPENDS_PATH}" | ||
| 106 | ${CMAKE_SOURCE_DIR}/tools/darwin/Support/CopyRootFiles-darwin_embedded.command | ||
| 107 | COMMAND "XBMC_DEPENDS=${DEPENDS_PATH}" | ||
| 108 | "PYTHON_VERSION=${PYTHON_VERSION}" | ||
| 109 | ${CMAKE_SOURCE_DIR}/tools/darwin/Support/copyframeworks-darwin_embedded.command | ||
| 110 | COMMAND ${CMAKE_SOURCE_DIR}/tools/darwin/Support/copyframeworks-dylibs2frameworks.command | ||
| 111 | COMMAND "XBMC_DEPENDS=${DEPENDS_PATH}" | ||
| 112 | "NATIVEPREFIX=${NATIVEPREFIX}" | ||
| 113 | ${CMAKE_SOURCE_DIR}/tools/darwin/Support/Codesign.command | ||
| 114 | ) | ||
| 115 | |||
| 116 | if(CORE_PLATFORM_NAME_LC STREQUAL tvos) | ||
| 117 | add_custom_command(TARGET ${APP_NAME_LC} POST_BUILD | ||
| 118 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${DEPENDS_PATH}/share/${APP_NAME_LC} $<TARGET_FILE_DIR:${APP_NAME_LC}>/AppData/AppHome | ||
| 119 | ) | ||
| 120 | endif() | ||
| 121 | |||
| 122 | set(DEPENDS_ROOT_FOR_XCODE ${NATIVEPREFIX}/..) | ||
| 123 | configure_file(${CMAKE_SOURCE_DIR}/tools/darwin/packaging/darwin_embedded/mkdeb-darwin_embedded.sh.in | ||
| 124 | ${CMAKE_BINARY_DIR}/tools/darwin/packaging/darwin_embedded/mkdeb-darwin_embedded.sh @ONLY) | ||
| 125 | |||
| 126 | if(CORE_PLATFORM_NAME_LC STREQUAL ios) | ||
| 127 | configure_file(${CMAKE_SOURCE_DIR}/tools/darwin/packaging/darwin_embedded/migrate_to_kodi.sh.in | ||
| 128 | ${CMAKE_BINARY_DIR}/tools/darwin/packaging/darwin_embedded/migrate_to_kodi.sh @ONLY) | ||
| 129 | endif() | ||
| 130 | |||
| 131 | add_custom_target(deb | ||
| 132 | COMMAND sh ./mkdeb-darwin_embedded.sh ${CORE_BUILD_CONFIG} | ||
| 133 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tools/darwin/packaging/darwin_embedded) | ||
| 134 | add_dependencies(deb ${APP_NAME_LC}) | ||
| 135 | |||
diff --git a/cmake/scripts/darwin_embedded/Macros.cmake b/cmake/scripts/darwin_embedded/Macros.cmake new file mode 100644 index 0000000..91f2d86 --- /dev/null +++ b/cmake/scripts/darwin_embedded/Macros.cmake | |||
| @@ -0,0 +1,118 @@ | |||
| 1 | function(core_link_library lib wraplib) | ||
| 2 | if(CMAKE_GENERATOR MATCHES "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL Ninja) | ||
| 3 | set(wrapper_obj cores/dll-loader/exports/CMakeFiles/wrapper.dir/wrapper.c.o) | ||
| 4 | elseif(CMAKE_GENERATOR MATCHES "Xcode") | ||
| 5 | set(wrapper_obj cores/dll-loader/exports/kodi.build/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/wrapper.build/Objects-$(CURRENT_VARIANT)/$(CURRENT_ARCH)/wrapper.o) | ||
| 6 | else() | ||
| 7 | message(FATAL_ERROR "Unsupported generator in core_link_library") | ||
| 8 | endif() | ||
| 9 | |||
| 10 | set(export -bundle -undefined dynamic_lookup | ||
| 11 | -Wl,-alias_list,${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/cores/dll-loader/exports/wrapper.def | ||
| 12 | ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/${wrapper_obj}) | ||
| 13 | set(extension ${CMAKE_SHARED_MODULE_SUFFIX}) | ||
| 14 | set(check_arg "") | ||
| 15 | if(TARGET ${lib}) | ||
| 16 | set(target ${lib}) | ||
| 17 | set(link_lib $<TARGET_FILE:${lib}>) | ||
| 18 | set(check_arg ${ARGV2}) | ||
| 19 | set(data_arg ${ARGV3}) | ||
| 20 | |||
| 21 | # iOS: EFFECTIVE_PLATFORM_NAME is not resolved | ||
| 22 | # http://public.kitware.com/pipermail/cmake/2016-March/063049.html | ||
| 23 | if(CORE_SYSTEM_NAME STREQUAL darwin_embedded) | ||
| 24 | get_target_property(dir ${lib} BINARY_DIR) | ||
| 25 | set(link_lib ${dir}/${CORE_BUILD_CONFIG}/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
| 26 | endif() | ||
| 27 | else() | ||
| 28 | set(target ${ARGV2}) | ||
| 29 | set(link_lib ${lib}) | ||
| 30 | set(check_arg ${ARGV3}) | ||
| 31 | set(data_arg ${ARGV4}) | ||
| 32 | endif() | ||
| 33 | if(check_arg STREQUAL export) | ||
| 34 | set(export ${export} | ||
| 35 | -Wl,--version-script=${ARGV3}) | ||
| 36 | elseif(check_arg STREQUAL extras) | ||
| 37 | foreach(arg ${data_arg}) | ||
| 38 | list(APPEND export ${arg}) | ||
| 39 | endforeach() | ||
| 40 | elseif(check_arg STREQUAL archives) | ||
| 41 | set(extra_libs ${data_arg}) | ||
| 42 | endif() | ||
| 43 | get_filename_component(dir ${wraplib} DIRECTORY) | ||
| 44 | |||
| 45 | # We can't simply pass the linker flags to the args section of the custom command | ||
| 46 | # because cmake will add quotes around it (and the linker will fail due to those). | ||
| 47 | # We need to do this handstand first ... | ||
| 48 | string(REPLACE " " ";" CUSTOM_COMMAND_ARGS_LDFLAGS ${CMAKE_SHARED_LINKER_FLAGS}) | ||
| 49 | |||
| 50 | add_custom_command(OUTPUT ${wraplib}-${ARCH}${extension} | ||
| 51 | COMMAND ${CMAKE_COMMAND} -E make_directory ${dir} | ||
| 52 | COMMAND ${CMAKE_C_COMPILER} | ||
| 53 | ARGS ${CUSTOM_COMMAND_ARGS_LDFLAGS} ${export} -Wl,-force_load ${link_lib} ${extra_libs} | ||
| 54 | -o ${CMAKE_BINARY_DIR}/${wraplib}-${ARCH}${extension} | ||
| 55 | DEPENDS ${target} wrapper.def wrapper | ||
| 56 | VERBATIM) | ||
| 57 | |||
| 58 | get_filename_component(libname ${wraplib} NAME_WE) | ||
| 59 | add_custom_target(wrap_${libname} ALL DEPENDS ${wraplib}-${ARCH}${extension}) | ||
| 60 | set_target_properties(wrap_${libname} PROPERTIES FOLDER lib/wrapped) | ||
| 61 | add_dependencies(${APP_NAME_LC}-libraries wrap_${libname}) | ||
| 62 | |||
| 63 | set(LIBRARY_FILES ${LIBRARY_FILES} ${CMAKE_BINARY_DIR}/${wraplib}-${ARCH}${extension} CACHE STRING "" FORCE) | ||
| 64 | endfunction() | ||
| 65 | |||
| 66 | function(find_soname lib) | ||
| 67 | cmake_parse_arguments(arg "REQUIRED" "" "" ${ARGN}) | ||
| 68 | |||
| 69 | string(TOLOWER ${lib} liblow) | ||
| 70 | if(${lib}_LDFLAGS) | ||
| 71 | set(link_lib "${${lib}_LDFLAGS}") | ||
| 72 | else() | ||
| 73 | set(link_lib "${${lib}_LIBRARIES}") | ||
| 74 | endif() | ||
| 75 | |||
| 76 | execute_process(COMMAND ${CMAKE_C_COMPILER} -print-search-dirs | ||
| 77 | COMMAND fgrep libraries: | ||
| 78 | COMMAND sed "s/[^=]*=\\(.*\\)/\\1/" | ||
| 79 | COMMAND sed "s/:/ /g" | ||
| 80 | ERROR_QUIET | ||
| 81 | OUTPUT_VARIABLE cc_lib_path | ||
| 82 | OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 83 | execute_process(COMMAND echo ${link_lib} | ||
| 84 | COMMAND sed "s/-L[ ]*//g" | ||
| 85 | COMMAND sed "s/-l[^ ]*//g" | ||
| 86 | ERROR_QUIET | ||
| 87 | OUTPUT_VARIABLE env_lib_path | ||
| 88 | OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 89 | |||
| 90 | foreach(path ${cc_lib_path} ${env_lib_path}) | ||
| 91 | if(IS_DIRECTORY ${path}) | ||
| 92 | execute_process(COMMAND ls -- ${path}/lib${liblow}.dylib | ||
| 93 | ERROR_QUIET | ||
| 94 | OUTPUT_VARIABLE lib_file | ||
| 95 | OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 96 | else() | ||
| 97 | set(lib_file ${path}) | ||
| 98 | endif() | ||
| 99 | if(lib_file) | ||
| 100 | # we want the path/name that is embedded in the dylib | ||
| 101 | execute_process(COMMAND otool -L ${lib_file} | ||
| 102 | COMMAND grep -v lib${liblow}.dylib | ||
| 103 | COMMAND grep ${liblow} | ||
| 104 | COMMAND awk "{V=1; print $V}" | ||
| 105 | ERROR_QUIET | ||
| 106 | OUTPUT_VARIABLE filename | ||
| 107 | OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 108 | get_filename_component(${lib}_SONAME "${filename}" NAME) | ||
| 109 | if(VERBOSE) | ||
| 110 | message(STATUS "${lib} soname: ${${lib}_SONAME}") | ||
| 111 | endif() | ||
| 112 | endif() | ||
| 113 | endforeach() | ||
| 114 | if(arg_REQUIRED AND NOT ${lib}_SONAME) | ||
| 115 | message(FATAL_ERROR "Could not find dynamically loadable library ${lib}") | ||
| 116 | endif() | ||
| 117 | set(${lib}_SONAME ${${lib}_SONAME} PARENT_SCOPE) | ||
| 118 | endfunction() | ||
diff --git a/cmake/scripts/darwin_embedded/PathSetup.cmake b/cmake/scripts/darwin_embedded/PathSetup.cmake new file mode 100644 index 0000000..efaca0b --- /dev/null +++ b/cmake/scripts/darwin_embedded/PathSetup.cmake | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | set(BUNDLE_IDENTIFIER_DESC "Bundle ID") | ||
| 2 | if(CORE_PLATFORM_NAME_LC STREQUAL tvos) | ||
| 3 | string(CONCAT BUNDLE_IDENTIFIER_DESC "${BUNDLE_IDENTIFIER_DESC}" " (app, top shelf, group ID)") | ||
| 4 | endif() | ||
| 5 | set(PLATFORM_BUNDLE_IDENTIFIER "${APP_PACKAGE}-${CORE_PLATFORM_NAME_LC}" CACHE STRING "${BUNDLE_IDENTIFIER_DESC}") | ||
| 6 | list(APPEND final_message "Bundle ID: ${PLATFORM_BUNDLE_IDENTIFIER}") | ||
| 7 | include(cmake/scripts/osx/PathSetup.cmake) | ||
