-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake updates #1454
CMake updates #1454
Conversation
- Use lowercase names for commands. - Remove extra whitespace. - Remove conditions from endif commands. - Update a few unindented lines.
Commit b91c515 (update to create config file which is independent from actual install location, 2017-03-14) introduced two different config files, one for the "build tree" (<binary_dir>/RapidJSONConfig.cmake) and one for the "install tree" (<binary_dir>/CMakeFiles/RapidJSONConfig.cmake). But there was already an install command installing <binary_dir>/RapidJSONConfig.cmake as the config file for the "install tree", and that commit did not update the command to account for the new location of the "install tree" config file. It also introduced the CMAKECONFIG_INSTALL_DIR variable for the install location of the config files, but there is a cache variable for that: CMAKE_INSTALL_DIR. Commit 8d272e5 (CMake: remove hardcoded CMAKECONFIG_INSTALL_DIR path, 2019-01-24) didn't figure out that neither. This commit ensures the proper config file is installed. It also removes CMAKECONFIG_INSTALL_DIR and uses the existing cache variables to refer to the install locations.
The configure_package_config_file helper should be preferred when creating the config file, to ensure the package is relocatable. The current calculation of the relative path between CMAKE_INSTALL_DIR and INCLUDE_INSTALL_DIR is not robust (they may be relative or absolute path, and all cases should be considered). The helper provides a macro that takes care of using the correct paths relative to the install prefix of the package. The set_and_check macro is also recommended to set variables inside the config file, to ensure the paths exist. When exporting the package to the CMake registry, the helper will just use the full paths to the include directory in the sources.
The different cache variables for the install directories should all be relative to the install prefix by default. CMake will prepend the value of CMAKE_INSTALL_PREFIX automatically.
Instead of typing the build type manually, the user can choose between the list of available types.
Detect if RapidJSON is included as a subproject and set less intrusive options for the parent project: - Disable building docs, examples and test by default. - Do not force ccache usage. - Do not export to the package registry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a clear improvement to me.
PR #1519 also shows the list of build types as options in the UI, as commit 960ff92 in this PR (we followed the same advice from the same blog), but I didn't want to set a default build type or consider "multiple configuration generators" in this PR, as I think it should be in its own PR. If both PR are accepted, then there would be a merge conflict. |
I'm still hoping my PR #1519 is going to make it in :-) |
Why is this still open? |
Mainly, add a check to detect when the project is used as a subproject to avoid compiling/installing extra stuff by default, and avoid changing global properties. This is similar to what fmtlib/fmt does.
The README and the examples are still installed unconditionally though. I am inclined to add check to disable that when used as a subproject, but I am not sure what other people thinks.
There were also some issues when installing the package configuration file, so I did some fixes. The commit messages have more details.