Files
stgsharp/src/Nitload.Native/README.md
T

2.0 KiB

Nitload.Native

COMPILE

Though this project do has a .vcxproj file,
you can only edit but not compile in visul studio.
Currently you can only compile this lib via Clang and cmake.

Build output and managed deployment

From the repository root:

cmake --preset clang-debug -S src/Nitload.Native
cmake --build cmake_build/clang-debug --target Nitload.Native

CMake writes Nitload.Native.dll and its linker PDB to bin/win-x64 on Windows x64 (Linux uses bin/linux-x64/libNitload.Native.so). Debug and release presets currently share this platform directory; the most recent native build is the deployed version. NIF_BUILD_OUTPUT_DIR can override the destination. Managed builds pass their expected RID as NIF_EXPECTED_RID so an incompatible native target is rejected before deployment.

StgSharpDebug.csproj enables BuildNativeBeforeManaged and RequireNativeLibrary. Its build runs the incremental CMake build (clang-debug for Debug, clang-release otherwise), then deploys the native library to the executable's actual TargetDir. Other managed projects copy an existing native artifact without invoking CMake. Managed-output staging never copies deployed native files back over the CMake artifact.

To use a prebuilt native artifact, pass -p:BuildNativeBeforeManaged=false. A matching Clang/Ninja environment and the local GLFW static library are required for native builds. Cross-target builds require a matching toolchain/preset; changing a managed platform alone does not cross-compile the C library.

Code Layout

Conventions:

  • src/ : project C sources and CMakeLists.txt calling add_library/add_executable
  • include/ : public headers (if used)
  • external/ : third-party libraries, each library lives in its own folder
    • libname/
      • head/ : header files for the library
      • lib/ : static or shared lib files (or CMake build for that lib)

The root CMakeLists.txt in this folder includes ExternalLibs.cmake if present.