templates/cmake_templates
library
Constants
-
localNitroNativeCmakePath
→ const String
-
-
nitroSizeControlsPreamble
→ const String
-
Opt-in binary-size knobs, emitted once into the generated
src/CMakeLists.txt
preamble. nitro_apply_size_opts(<target>) is then called on each nitro
library (guarded by if(COMMAND …) so a standalone/retrofit append is a
no-op). Conservative by design: dead-code strip + section GC only remove
UNREFERENCED code, so every export you call survives; LTO is separate and
off by default. No visibility change (that needs a full export audit).
Functions
-
cmakeModuleTarget(String lib, {bool isCpp = false, bool isAndroidCpp = false})
→ String
-
Returns the CMake target block for a secondary module library.
-
generateCMakeContent(String pluginName, List<String> moduleLibs, String nitroNativePath, {List<({bool isAndroidCpp, bool isNativeCpp, String lib, String module})>? moduleInfos, String? linkChecksum})
→ String
-
Generates the full content of a fresh
src/CMakeLists.txt.
-
implSourcesBlock(String target, String className, {required bool unguarded})
→ String
-
Emits the target_sources call that adds the hand-maintained C++ impl file
to
target. Always prefers the caller-supplied nitroImplSrcVar CACHE
variable when defined — this is how windows/CMakeLists.txt and
linux/CMakeLists.txt (see _linkDesktopCMake in link_command.dart) point
this shared src/CMakeLists.txt at their OWN platform-specific impl file
instead of being forced to share one — falling back to the historical
Hybrid$className.cpp name so plugins that never set it (the vast
majority — anyone not targeting Windows-C++ AND Linux-C++
simultaneously) see byte-identical output to before this existed.
-
nitroImplSrcVar(String target)
→ String
-
The CMake CACHE variable name a Windows/Linux caller sets (before
add_subdirectory("../src")) to override which impl file gets compiled
for target — see _implSourcesBlock and _linkDesktopCMake /
needsSeparateWindowsImpl / needsSeparateLinuxImpl in link_command.dart.
Keyed per-target (not one global name) so multi-spec plugins with several
C++ module libraries in one src/CMakeLists.txt can override each
independently.