microsoft / glTF-SDK

glTF-SDK is a C++ Software Development Kit for glTF (GL Transmission Format -https://github.com/KhronosGroup/glTF).
MIT License
535 stars 100 forks source link

cmake documentation, install for iOS app #87

Open ArMouReR opened 2 years ago

ArMouReR commented 2 years ago

Hi,

I am missing any documentation how to compile to static/dynamic lib to use inside iOS app.

I have tried to compile in the usual way, e.g.:

git clone https://github.com/microsoft/glTF-SDK.git
cd glTF-SDK/Build/
cmake ..
cmake --build . --target install

It worked, but install was done in: glTF-SDK/Built/Out/macOS/RelWithDebInfo/GLTFSDK/libGLTFSDK.a

How can I configure cmake to install it into /usr/local/include/ in order to use later in Xcode inside iPhone app ?

kokuda commented 2 years ago

Take a look at the macinit.ps1 and macbuild.ps1 PowerShell scripts for the commands needed to build for iOS.

ArMouReR commented 2 years ago

@kokuda Thanks for pointing out, tried to run init, it stopped with the following error:

CMake Error at Build/CMake/Modules/GLTFPlatform.cmake:88 (target_link_libraries):
  The keyword signature for target_link_libraries has already been used with
  the target "GLTFSDK.Test".  All uses of target_link_libraries with a target
  must be either all-keyword or all-plain.

  The uses of the keyword signature are here:

   * GLTFSDK.Test/CMakeLists.txt:37 (target_link_libraries)

Call Stack (most recent call first):
  GLTFSDK.Test/CMakeLists.txt:46 (AddGLTFIOSAppProperties)

-- Configuring incomplete, errors occurred!

Then started the build script and got the following:

xcodebuild: error: 'GLTFSDK.xcodeproj' does not exist.
Attempting to build package from 'GLTFSDK.macOS.CPP.nuspec'.
WARNING: NU5125: The 'licenseUrl' element will be deprecated. Consider using the 'license' element instead.
WARNING: NU5048: The 'PackageIconUrl'/'iconUrl' element is deprecated. Consider using the 'PackageIcon'/'icon' element instead. Learn more at https://aka.ms/deprecateIconUrl
Successfully created package '/Users/admin/dev/ios/lib/glTF-SDK/Built/Out/NuGet/Microsoft.glTF.macOS.CPP.0.0.0.nupkg'.
Attempting to build package from 'GLTFSDK.iOS.CPP.nuspec'.
Could not find a part of the path '/Users/admin/dev/ios/lib/glTF-SDK/Built/Out/iOS/Debug/GLTFSDK'.

So, what is the general flow ? All I need is to use it inside iOS app (C++ part), so in my understanding I need an inc folder with all the headers and .a lib that I can add as custom framework in Xcode.

What is the fastest route to get there ? Any hints are really appreciated.

BTW, what about prebuild nuget package ? I don't think that I need the latest version and existing package may work for me...

kokuda commented 2 years ago

Unfortunately, it has been a long time since I ran a mac or iOS build and don't recall the details. I just remembered that those scripts existed (I think I wrote them, but that was over 3 years ago and don't remember much) and thought they would help. You could try dissecting the commands within those scripts and run just the ones you need for iOS.

Take a look at GenerateProjectsIOS() in macinit.ps1 for how to build the xcode project. I don't know if it still works but it might help. I believe that once the xcode project is generated you can build the library using xcode.

bghgary commented 9 months ago

Dupe or at least related: #70