I want to share little piece of work I did to ease MDL SDK integration into your projects.
I created a vcpkg port for the MDL-SDK project.
This allow to have a simple process to build MDL-SDK from sources for a variety of configurations and platforms, resulting in a CMake package which is easy to integrate into CMake projects. [1]
Here is the workflow to get, build and use the MDL-SDK with this :
set up vcpkg > git clone https://github.com/microsoft/vcpkg > <vcpkg>\vcpkg\bootstrap-vcpkg.bat
set up additional vcpkg ports git clone git@github.com:theblackunknown/vcpkg-ports.git <vcpkg-ports>
build mdl port vcpkg install --overlay-ports=<vcpkg-ports>\ports --triplet x64-windows mdl
After some time that all required dependencies and MDL-SDK is built, a message summarize how to integrate it into you CMake project.
Even if redundant, here are the step to complete to integrate the built port into your projects
Add -DCMAKE_TOOLCHAIN_FILE:PATH="<vcpkg>\scripts\buildsystems\vcpkg.cmake" to your CMake configure
Add find_package(mdl CONFIG REQUIRED)to your CMakeLists.txt to search for the mdl built port
Add target_link_libraries(<your target> PRIVATE mdl::sdk mdl::core mdl::headers) to link your target to the MDL SDK
And that’s it !
I have hooked this into Github Actions so that those get built for all currently supported configurations and platforms automatically examples here
Let me know if this is useful to anyone
NOTES:
There are a number of patches applied on top of the vanilla MDL-SDK repo, most of them were added so that built artefacts leverage the CMake install system and comply with the vcpkg convention for package.
But also to fix code (e.g. some missing includes) I have encoutered using Github Actions.
In the end, I made Windows and Linux pass, but not Apple as it required much more work.
[1] It is also possible to export built artefacts so that you can integrate it into any buildsystem if needed.
Thanks Andrea for sharing this. I will definitely have a look at your patches.
Our build systems do not use vcpkg AFAIK but for those who do this is valuable for sure.
Thanks
Is there any update on this thread? I am a newbie in MDL, and trying to run the MDL_renderer example from OptiX_Apps. Currently trying to follow the MDL-SDK/INSTALL.md at master · NVIDIA/MDL-SDK (github.com) instruction set and lost somewhere!
What exactly is unclear in the vcpkg installation descriptions?
Since I built the open-source MDL SDK for my OptiX applications following the MDL SDK and vcpkg installation descriptions by the letter, you should be able to do that same.
I downloaded the exact vcpkg commit version from github.com as specified inside the MDL SDK INSTALL.md and built the MDL SDK with MSVS 2019 for which I needed to add the set(VCPKG_PLATFORM_TOOLSET v142) to the vcpkg\triplets\x64-windows-static.cmake (and for peace of mind also in vcpkg\triplets\x64-windows.cmake), also as described inside the MDL SDK installation.
After that I downloaded the OpenImageIO and boost libraries with vcpkg, also as described inside the MDL SDK installation.
All other libraries are downloaded individually. Read the important part below before doing that!
After that is done, the MDL SDK CMake build scripts will ask you for all required library folder locations on each CMake GUI Configure step until all prerequisites are fulfilled.
Important: Since I only need the MDL SDK libraries for my OptiX examples and none of the MDL SDK examples, I disabled the build of all MDL SDK examples inside the CMake GUI once all MDL_BUILD_* CMake variables are shown, which greatly reduces the amount of third party libraries required for the build (especially Qt).
(Of course I can also build all MDL SDK examples except for the Qt ones because I also downloaded the other required libraries for those.)
If that is all not working for you, there is also the pre-built binary MDL SDK, as described in my README.md.
That contains all necessary headers in the include folder and required libraries inside the OS specific lib folders, e.g. in nt-x86-64\lib for Windows.