diff --git a/cmake/Modules/TinyInitDefaultVariables.cmake b/cmake/Modules/TinyInitDefaultVariables.cmake
index ae0ab705d..1332bcd05 100644
--- a/cmake/Modules/TinyInitDefaultVariables.cmake
+++ b/cmake/Modules/TinyInitDefaultVariables.cmake
@@ -6,20 +6,14 @@ macro(tiny_init_cmake_variables_pre)
# Set the CMAKE_EXPORT_PACKAGE_REGISTRY from the TINYORM_EXPORT_PACKAGE_REGISTRY
# environment variable
- set(environmentValue ON) # Default value
- if(DEFINED ENV{TINYORM_EXPORT_PACKAGE_REGISTRY})
- if($ENV{TINYORM_EXPORT_PACKAGE_REGISTRY})
- set(environmentValue ON)
- else()
- set(environmentValue OFF)
- endif()
+ if(NOT DEFINED CMAKE_EXPORT_PACKAGE_REGISTRY AND
+ DEFINED ENV{TINYORM_EXPORT_PACKAGE_REGISTRY}
+ )
+ set(CMAKE_EXPORT_PACKAGE_REGISTRY $ENV{TINYORM_EXPORT_PACKAGE_REGISTRY}
+ CACHE BOOL "Enables the export(PACKAGE) command, export packages \
+to the user package registry")
endif()
- set(CMAKE_EXPORT_PACKAGE_REGISTRY ${environmentValue} CACHE BOOL
- "Enables the export(PACKAGE) command, export packages to the user package \
-registry")
- unset(environmentValue)
-
endmacro()
# Initialize default CMake variables
diff --git a/docs/building/tinyorm.mdx b/docs/building/tinyorm.mdx
index 033cac1e3..58986c121 100644
--- a/docs/building/tinyorm.mdx
+++ b/docs/building/tinyorm.mdx
@@ -532,7 +532,7 @@ Important `CMake` options.
| `CMAKE_DISABLE_PRECOMPILE_HEADERS` | `OFF` | Disable precompiled headers. |
| `CMAKE_CXX_COMPILER` | `auto` | The full path to the `C++` compiler. |
| `CMAKE_CXX_COMPILER_LAUNCHER` | `-` | Default compiler launcher to use for the `C++` compiler.
Can be used to enable `ccache`, eg. `ccache.exe` on `MinGW` or `/usr/bin/ccache` on `Linux`. |
-| `CMAKE_EXPORT_PACKAGE_REGISTRY` | `ON` | Enable the `export(TinyOrm)` command.
`TinyORM` sets this variable to `ON` by default. |
+| `CMAKE_EXPORT_PACKAGE_REGISTRY` | `OFF` | Enable the `export(TinyOrm)` command.
`TinyORM` doesn't set this variable by default. Its initial value is taken from the `TINYORM_EXPORT_PACKAGE_REGISTRY` environment variable if not already defined. |
| `CMAKE_VERBOSE_MAKEFILE` | `OFF` | Enable verbose output from Makefile builds. |