mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-15 20:03:15 +02:00
[Conan] add iOS support
This commit is contained in:
@@ -138,6 +138,6 @@ vcmi_set_output_dir(Nullkiller "AI")
|
|||||||
enable_pch(Nullkiller)
|
enable_pch(Nullkiller)
|
||||||
|
|
||||||
install(TARGETS Nullkiller RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR})
|
install(TARGETS Nullkiller RUNTIME DESTINATION ${AI_LIB_DIR} LIBRARY DESTINATION ${AI_LIB_DIR})
|
||||||
if(APPLE_IOS)
|
if(APPLE_IOS AND NOT USING_CONAN)
|
||||||
install(IMPORTED_RUNTIME_ARTIFACTS TBB::tbb LIBRARY DESTINATION ${LIB_DIR}) # CMake 3.21+
|
install(IMPORTED_RUNTIME_ARTIFACTS TBB::tbb LIBRARY DESTINATION ${LIB_DIR}) # CMake 3.21+
|
||||||
endif()
|
endif()
|
||||||
|
14
CI/conan/ios-arm64
Normal file
14
CI/conan/ios-arm64
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[settings]
|
||||||
|
os=iOS
|
||||||
|
os.version=12.0
|
||||||
|
os.sdk=iphoneos
|
||||||
|
arch=armv8
|
||||||
|
compiler=apple-clang
|
||||||
|
compiler.version=13
|
||||||
|
compiler.libcxx=libc++
|
||||||
|
build_type=Release
|
||||||
|
[options]
|
||||||
|
[build_requires]
|
||||||
|
[env]
|
||||||
|
[conf]
|
||||||
|
tools.cmake.cmaketoolchain:generator = Ninja
|
14
CI/conan/ios-armv7
Normal file
14
CI/conan/ios-armv7
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[settings]
|
||||||
|
os=iOS
|
||||||
|
os.version=10.0
|
||||||
|
os.sdk=iphoneos
|
||||||
|
arch=armv7
|
||||||
|
compiler=apple-clang
|
||||||
|
compiler.version=13
|
||||||
|
compiler.libcxx=libc++
|
||||||
|
build_type=Release
|
||||||
|
[options]
|
||||||
|
[build_requires]
|
||||||
|
[env]
|
||||||
|
[conf]
|
||||||
|
tools.cmake.cmaketoolchain:generator = Ninja
|
@@ -180,9 +180,11 @@ if(APPLE_IOS)
|
|||||||
set(CMAKE_MACOSX_RPATH 1)
|
set(CMAKE_MACOSX_RPATH 1)
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0)
|
set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0)
|
||||||
|
|
||||||
list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_PREFIX_PATH}") # required for Boost
|
if(NOT USING_CONAN)
|
||||||
set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH FALSE)
|
list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_PREFIX_PATH}") # required for Boost
|
||||||
set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE)
|
set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH FALSE)
|
||||||
|
set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED NO)
|
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED NO)
|
||||||
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED_FOR_APPS YES)
|
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED_FOR_APPS YES)
|
||||||
@@ -294,7 +296,7 @@ if(TARGET zlib::zlib)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(FFMPEG_COMPONENTS avutil swscale avformat avcodec)
|
set(FFMPEG_COMPONENTS avutil swscale avformat avcodec)
|
||||||
if(APPLE_IOS)
|
if(APPLE_IOS AND NOT USING_CONAN)
|
||||||
list(APPEND FFMPEG_COMPONENTS swresample)
|
list(APPEND FFMPEG_COMPONENTS swresample)
|
||||||
endif()
|
endif()
|
||||||
find_package(ffmpeg COMPONENTS ${FFMPEG_COMPONENTS})
|
find_package(ffmpeg COMPONENTS ${FFMPEG_COMPONENTS})
|
||||||
@@ -309,6 +311,9 @@ endif()
|
|||||||
|
|
||||||
find_package(SDL2 REQUIRED)
|
find_package(SDL2 REQUIRED)
|
||||||
find_package(SDL2_image REQUIRED)
|
find_package(SDL2_image REQUIRED)
|
||||||
|
if(TARGET SDL2_image::SDL2_image)
|
||||||
|
add_library(SDL2::Image ALIAS SDL2_image::SDL2_image)
|
||||||
|
endif()
|
||||||
find_package(SDL2_mixer REQUIRED)
|
find_package(SDL2_mixer REQUIRED)
|
||||||
if(TARGET SDL2_mixer::SDL2_mixer)
|
if(TARGET SDL2_mixer::SDL2_mixer)
|
||||||
add_library(SDL2::Mixer ALIAS SDL2_mixer::SDL2_mixer)
|
add_library(SDL2::Mixer ALIAS SDL2_mixer::SDL2_mixer)
|
||||||
|
@@ -268,6 +268,7 @@ vcmi_set_output_dir(vcmiclient "")
|
|||||||
enable_pch(vcmiclient)
|
enable_pch(vcmiclient)
|
||||||
|
|
||||||
if(APPLE_IOS)
|
if(APPLE_IOS)
|
||||||
|
vcmi_install_conan_deps("\${CMAKE_INSTALL_PREFIX}")
|
||||||
add_custom_command(TARGET vcmiclient POST_BUILD
|
add_custom_command(TARGET vcmiclient POST_BUILD
|
||||||
COMMAND ios/set_build_version.sh "$<TARGET_BUNDLE_CONTENT_DIR:vcmiclient>"
|
COMMAND ios/set_build_version.sh "$<TARGET_BUNDLE_CONTENT_DIR:vcmiclient>"
|
||||||
COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}" --component "${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}" --config "$<CONFIG>" --prefix "$<TARGET_BUNDLE_CONTENT_DIR:vcmiclient>"
|
COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}" --component "${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}" --config "$<CONFIG>" --prefix "$<TARGET_BUNDLE_CONTENT_DIR:vcmiclient>"
|
||||||
|
@@ -134,3 +134,16 @@ function(install_vcpkg_imported_tgt tgt)
|
|||||||
message("${tgt_name}: ${TGT_DLL}")
|
message("${tgt_name}: ${TGT_DLL}")
|
||||||
install(FILES ${TGT_DLL} DESTINATION ${BIN_DIR})
|
install(FILES ${TGT_DLL} DESTINATION ${BIN_DIR})
|
||||||
endfunction(install_vcpkg_imported_tgt)
|
endfunction(install_vcpkg_imported_tgt)
|
||||||
|
|
||||||
|
# install dependencies from Conan, install_dir should contain \${CMAKE_INSTALL_PREFIX}
|
||||||
|
function(vcmi_install_conan_deps install_dir)
|
||||||
|
if(NOT USING_CONAN)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
install(CODE "
|
||||||
|
execute_process(COMMAND
|
||||||
|
conan imports \"${CMAKE_SOURCE_DIR}\" --install-folder \"${CMAKE_SOURCE_DIR}/conan-generated\" --import-folder \"${install_dir}\"
|
||||||
|
)
|
||||||
|
file(REMOVE \"${install_dir}/conan_imports_manifest.txt\")
|
||||||
|
")
|
||||||
|
endfunction()
|
||||||
|
@@ -500,7 +500,7 @@ macro(add_main_lib TARGET_NAME LIBRARY_TYPE)
|
|||||||
if("${LIBRARY_TYPE}" STREQUAL SHARED)
|
if("${LIBRARY_TYPE}" STREQUAL SHARED)
|
||||||
install(TARGETS ${TARGET_NAME} RUNTIME DESTINATION ${LIB_DIR} LIBRARY DESTINATION ${LIB_DIR})
|
install(TARGETS ${TARGET_NAME} RUNTIME DESTINATION ${LIB_DIR} LIBRARY DESTINATION ${LIB_DIR})
|
||||||
endif()
|
endif()
|
||||||
if(APPLE_IOS)
|
if(APPLE_IOS AND NOT USING_CONAN)
|
||||||
get_target_property(LINKED_LIBS ${TARGET_NAME} LINK_LIBRARIES)
|
get_target_property(LINKED_LIBS ${TARGET_NAME} LINK_LIBRARIES)
|
||||||
foreach(LINKED_LIB IN LISTS LINKED_LIBS)
|
foreach(LINKED_LIB IN LISTS LINKED_LIBS)
|
||||||
if(NOT TARGET ${LINKED_LIB})
|
if(NOT TARGET ${LINKED_LIB})
|
||||||
|
33
conanfile.py
33
conanfile.py
@@ -1,13 +1,14 @@
|
|||||||
from conan import ConanFile
|
from conan import ConanFile
|
||||||
from conan.tools.apple import is_apple_os
|
from conan.tools.apple import is_apple_os
|
||||||
from conan.tools.cmake import CMakeDeps
|
from conan.tools.cmake import CMakeDeps, CMakeToolchain
|
||||||
from conans import tools
|
from conans import tools
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
required_conan_version = ">=1.51.3"
|
||||||
|
|
||||||
class VCMI(ConanFile):
|
class VCMI(ConanFile):
|
||||||
settings = "os", "compiler", "build_type", "arch"
|
settings = "os", "compiler", "build_type", "arch"
|
||||||
generators = "CMakeToolchain"
|
|
||||||
requires = [
|
requires = [
|
||||||
"boost/1.80.0",
|
"boost/1.80.0",
|
||||||
"ffmpeg/4.4.3",
|
"ffmpeg/4.4.3",
|
||||||
@@ -57,10 +58,8 @@ class VCMI(ConanFile):
|
|||||||
default_options = {
|
default_options = {
|
||||||
# shared libs
|
# shared libs
|
||||||
"boost/*:shared": True,
|
"boost/*:shared": True,
|
||||||
"libpng/*:shared": True, # SDL_image and Qt depend on it
|
|
||||||
"minizip/*:shared": True,
|
"minizip/*:shared": True,
|
||||||
"onetbb/*:shared": True,
|
"onetbb/*:shared": True,
|
||||||
"qt/*:shared": True,
|
|
||||||
|
|
||||||
# we need only the following Boost parts:
|
# we need only the following Boost parts:
|
||||||
# date_time filesystem locale program_options system thread
|
# date_time filesystem locale program_options system thread
|
||||||
@@ -108,7 +107,6 @@ class VCMI(ConanFile):
|
|||||||
|
|
||||||
"sdl/*:vulkan": False,
|
"sdl/*:vulkan": False,
|
||||||
|
|
||||||
"sdl_image/*:imageio": True,
|
|
||||||
"sdl_image/*:lbm": False,
|
"sdl_image/*:lbm": False,
|
||||||
"sdl_image/*:pnm": False,
|
"sdl_image/*:pnm": False,
|
||||||
"sdl_image/*:svg": False,
|
"sdl_image/*:svg": False,
|
||||||
@@ -129,7 +127,6 @@ class VCMI(ConanFile):
|
|||||||
"sdl_mixer/*:wav": False,
|
"sdl_mixer/*:wav": False,
|
||||||
|
|
||||||
"qt/*:config": " ".join(_qtOptions),
|
"qt/*:config": " ".join(_qtOptions),
|
||||||
"qt/*:openssl": False,
|
|
||||||
"qt/*:qttools": True,
|
"qt/*:qttools": True,
|
||||||
"qt/*:with_freetype": False,
|
"qt/*:with_freetype": False,
|
||||||
"qt/*:with_libjpeg": False,
|
"qt/*:with_libjpeg": False,
|
||||||
@@ -144,6 +141,19 @@ class VCMI(ConanFile):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def configure(self):
|
def configure(self):
|
||||||
|
# SDL_image and Qt depend on it, in iOS both are static
|
||||||
|
self.options["libpng"].shared = self.settings.os != "iOS"
|
||||||
|
|
||||||
|
self.options["qt"].openssl = not is_apple_os(self)
|
||||||
|
self.options["qt"].shared = self.settings.os != "iOS"
|
||||||
|
if self.settings.os == "iOS":
|
||||||
|
self.options["qt"].opengl = "es2"
|
||||||
|
|
||||||
|
self.options["sdl"].sdl2main = self.settings.os != "iOS"
|
||||||
|
|
||||||
|
if is_apple_os(self):
|
||||||
|
self.options["sdl_image"].imageio = True
|
||||||
|
|
||||||
# workaround: macOS deployment target isn't passed to linker when building Boost
|
# workaround: macOS deployment target isn't passed to linker when building Boost
|
||||||
# TODO: remove when https://github.com/conan-io/conan-center-index/pull/12468 is merged
|
# TODO: remove when https://github.com/conan-io/conan-center-index/pull/12468 is merged
|
||||||
if is_apple_os(self):
|
if is_apple_os(self):
|
||||||
@@ -159,6 +169,7 @@ class VCMI(ConanFile):
|
|||||||
self.options["boost"].extra_b2_flags = f"linkflags={deploymentTargetFlag}"
|
self.options["boost"].extra_b2_flags = f"linkflags={deploymentTargetFlag}"
|
||||||
|
|
||||||
def requirements(self):
|
def requirements(self):
|
||||||
|
# TODO: will no longer be needed after merging https://github.com/conan-io/conan-center-index/pull/13399
|
||||||
self.requires("libpng/1.6.38", override=True) # freetype / Qt
|
self.requires("libpng/1.6.38", override=True) # freetype / Qt
|
||||||
|
|
||||||
# use Apple system libraries instead of external ones
|
# use Apple system libraries instead of external ones
|
||||||
@@ -170,13 +181,17 @@ class VCMI(ConanFile):
|
|||||||
"zlib/1.2.12",
|
"zlib/1.2.12",
|
||||||
]
|
]
|
||||||
for lib in systemLibsOverrides:
|
for lib in systemLibsOverrides:
|
||||||
self.requires(f"{lib}@kambala/apple", override=True)
|
self.requires(f"{lib}@vcmi/apple", override=True)
|
||||||
|
|
||||||
# TODO: the latest official release of LuaJIT (which is quite old) can't be built for arm Mac
|
# TODO: the latest official release of LuaJIT (which is quite old) can't be built for arm
|
||||||
if self.settings.os != "Macos" or self.settings.arch != "armv8":
|
if not str(self.settings.arch).startswith("arm"):
|
||||||
self.requires("luajit/2.0.5")
|
self.requires("luajit/2.0.5")
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
|
tc = CMakeToolchain(self)
|
||||||
|
tc.variables["USING_CONAN"] = True
|
||||||
|
tc.generate()
|
||||||
|
|
||||||
deps = CMakeDeps(self)
|
deps = CMakeDeps(self)
|
||||||
if os.getenv("USE_CONAN_WITH_ALL_CONFIGS", "0") == "0":
|
if os.getenv("USE_CONAN_WITH_ALL_CONFIGS", "0") == "0":
|
||||||
deps.generate()
|
deps.generate()
|
||||||
|
@@ -8,3 +8,4 @@ target_link_libraries(iOS_utils PRIVATE
|
|||||||
target_include_directories(iOS_utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(iOS_utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
vcmi_set_output_dir(iOS_utils "")
|
vcmi_set_output_dir(iOS_utils "")
|
||||||
|
install(TARGETS iOS_utils RUNTIME DESTINATION ${LIB_DIR} LIBRARY DESTINATION ${LIB_DIR})
|
||||||
|
@@ -119,6 +119,18 @@ enable_pch(vcmilauncher)
|
|||||||
|
|
||||||
if(APPLE_IOS)
|
if(APPLE_IOS)
|
||||||
set(ICONS_DESTINATION ${DATA_DIR})
|
set(ICONS_DESTINATION ${DATA_DIR})
|
||||||
|
|
||||||
|
# workaround https://github.com/conan-io/conan-center-index/issues/13332
|
||||||
|
if(USING_CONAN)
|
||||||
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/QIOSIntegrationPlugin.h
|
||||||
|
"#include <QtPlugin>\nQ_IMPORT_PLUGIN(QIOSIntegrationPlugin)"
|
||||||
|
)
|
||||||
|
# target_include_directories(vcmilauncher PRIVATE ${CMAKE_BINARY_DIR})
|
||||||
|
target_link_libraries(vcmilauncher
|
||||||
|
Qt${QT_VERSION_MAJOR}::QIOSIntegrationPlugin
|
||||||
|
qt::QIOSIntegrationPlugin
|
||||||
|
)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
set(ICONS_DESTINATION ${DATA_DIR}/launcher)
|
set(ICONS_DESTINATION ${DATA_DIR}/launcher)
|
||||||
|
|
||||||
|
@@ -12,6 +12,13 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
|
// Conan workaround https://github.com/conan-io/conan-center-index/issues/13332
|
||||||
|
#ifdef VCMI_IOS
|
||||||
|
#if __has_include("QIOSIntegrationPlugin.h")
|
||||||
|
#include "QIOSIntegrationPlugin.h"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
@@ -38,12 +38,7 @@ if(APPLE_MACOS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# deploy other dylibs with conan
|
# deploy other dylibs with conan
|
||||||
install(CODE "
|
vcmi_install_conan_deps("${bundleContentsDir}")
|
||||||
execute_process(COMMAND
|
|
||||||
conan imports \"${CMAKE_SOURCE_DIR}\" --install-folder \"${CMAKE_SOURCE_DIR}/conan-generated\" --import-folder \"${bundleContentsDir}\"
|
|
||||||
)
|
|
||||||
file(REMOVE \"${bundleContentsDir}/conan_imports_manifest.txt\")
|
|
||||||
")
|
|
||||||
|
|
||||||
# perform ad-hoc codesigning
|
# perform ad-hoc codesigning
|
||||||
set(codesignCommand "codesign --verbose=4 --force --options=runtime --timestamp=none --sign -")
|
set(codesignCommand "codesign --verbose=4 --force --options=runtime --timestamp=none --sign -")
|
||||||
|
Reference in New Issue
Block a user