Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
harden
✓ include(cmake-harden)
harden(my_target CXX RUNTIME)
✗ find_package(cmake-harden) or include(cmake-harden) without find_package path
Requires find_package with PATHS node_modules/cmake-harden if installed via npm. The harden macro is defined after inclusion.
find_package(cmake-harden)
✓ find_package(cmake-harden REQUIRED PATHS node_modules/cmake-harden)
✗ find_package(cmake-harden) without PATHS
The module is not installed system-wide; must specify path to node_modules.
include(cmake-harden)
✓ include(cmake-harden/cmake-harden.cmake)
✗ include(cmake-harden) without full path or with find_package
If using include directly, the file path must be correct after find_package resolves the location.
Shows how to include the cmake-harden module and apply hardening to a C executable target.
find_package(cmake-harden REQUIRED PATHS node_modules/cmake-harden)
add_executable(myapp main.c)
harden(myapp C)
target_compile_options(myapp PRIVATE -Wall -Wextra)
Debug
Known issues
gotchafind_package must specify PATHS to node_modules when installed via npmfixUse find_package(cmake-harden REQUIRED PATHS node_modules/cmake-harden)
affects: *
gotchaThe module does not set CMAKE_CXX_FLAGS or CMAKE_C_FLAGS globally; it applies to specific targetsfixCall harden() on each target you want to harden
affects: *
gotchaThe RUNTIME argument only adds runtime hardening flags (e.g., -D_FORTIFY_SOURCE=2), not compile-timefixUse harden(target CXX RUNTIME) to also add runtime flags
affects: *
deprecatedNo deprecated features known
Errors
Common errors & fixes
CMake Error at CMakeLists.txt:1 (find_package):
By not providing "Findcmake-harden.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"cmake-harden", but CMake did not find one.
Missing PATHS argument or cmake-harden not installed
fixEnsure npm install cmake-harden is run, then add PATHS node_modules/cmake-harden to find_package
CMake Error at CMakeLists.txt:5 (harden):
Unknown CMake command "harden".
Module not included before calling harden()
fixAdd include(cmake-harden/cmake-harden.cmake) or use find_package and then include the module file
npm WARN cmake-harden@1.1.2 requires a peer of cmake but none is installed.
cmake is not listed as a peer dependency but npm may warn
fixEnsure cmake is available in the system or project (not an npm issue)
Audit
Dependencies
No dependency data recorded yet.