Closed trevor-creator closed 1 year ago
Looking into nlohmann::json's history, it stopped installing by default when a submodule as of v3.10.0.
A workaround is to not set set(JSON_Install OFF CACHE INTERNAL "")
before including nlohmann::json if using v3.9.1 or earlier, or to set set(JSON_Install ON CACHE INTERNAL "")
if using a more recent version. If mandatory install will be kept, this should be documented.
What about we set install target only when JSON_VALIDATOR_IS_TOP_LEVEL
?
We already skip examples and tests if used as a submodule ...
What about we set install target only when
JSON_VALIDATOR_IS_TOP_LEVEL
? We already skip examples and tests if used as a submodule ...
Commented on the PR, but realized I maybe should reply here too: the PR that caused this regression came from requests to install when used as a submodule (#162, #164). It needs to be an option.
I think some (or all of) your issues are fixed now? Please re-open if still needed.
We are hoping to use nlohmann::json and json-schema-validator as submodules in our project. We are building for single-binary deployment, so our project is not meant to be installed using CMake. However, when I tried using master yesterday, I found that submodule use without installing no longer works. It appears that PR #165 has undone PR #81, re-causing error #79.
Example, using the demonstration from #79 and starting with its original json and validator versions:
The change responsible appears to be here:
https://github.com/pboettch/json-schema-validator/pull/165/files#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20aL144-R103
The new CMakeLists always attempts to install the library, even if JSON is not installed (because JSON only installs/exports if it is the top-level project or the install is explicitly enabled).
While I'm not that familiar with CMake installs, my first thought would be to emulate JSON's install conditions and only install if json-schema-validator is the top-level project with JSON installed, or if a variable is explicitly set to enable the install.