UseInCMake - npackd/npackd GitHub Wiki

Using Npackd with CMake

CMake is a build script generator. Once a project is configured, exact paths to the required libraries are stored in cache. This is why it is recommended to find the paths via NpackdCL and then start CMake. Using NpackdCL within FindXXX.cmake scripts is possible, but would lead to finding inexact dependencies as each C++/C library can be compiled in many different ways.

Here is how you can install MinGW-w64 7.2, CMake and precompiled Zlib for static linking, find the paths to the installed packages, start CMake, ane build the project. All commands should be executed from a new build directory.

ncl.exe add -p mingw-w64-x86_64-seh-posix -v 7.2 -p org.cmake.CMake -r [3,4) -p z-dev-x86_64-w64_seh_posix_7.2-static -v 1.2.11
if %errorlevel% neq 0 exit /b %errorlevel%

set onecmd=ncl.exe path -p mingw-w64-x86_64-seh-posix -v 7.2
for /f "usebackq delims=" %%x in (`%%onecmd%%`) do set mingw=%%x

set onecmd=ncl.exe path -p org.cmake.CMake -r [3,4)
for /f "usebackq delims=" %%x in (`%%onecmd%%`) do set cmake=%%x

set onecmd=ncl.exe path -p z-dev-x86_64-w64_seh_posix_7.2-static -v 1.2.11
for /f "usebackq delims=" %%x in (`%%onecmd%%`) do set zlib=%%x

set path=%mingw%\bin;%cmake%\bin
cmake . -G "MinGW Makefiles" "-DZLIB_ROOT:PATH=%zlib%"
if %errorlevel% neq 0 exit /b %errorlevel%

mingw32-make.exe install
if %errorlevel% neq 0 exit /b %errorlevel%