[cmake] Move options, correct install include path. fix libxml2-config.cmake #25
+60
−110
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Move the options for dependencies to the top of
find_package
Reason: Automatically setting options for dependencies based on the search results of dependencies is an inappropriate thing: it may cause actual results to be inconsistent with expectations. So when the option is set to ON but the corresponding dependency cannot be found, it should report the error "Dependency not found".
Provide macro
LIBXML2_INCLUDE_DIR
Reason: Since libxml2 did not provide cmake export function before, most libraries use FindLibxml2.cmake in cmake, and some libraries use the
LIBXML2_INCLUDE_DIR
macro provided by cmake. Add this macro to better adapt to existing scenes.Use the attributes of the target
LibXml2::LibXml2
inlibxml2-config.cmake
instead of manually setting some macros (such asLIBXML2_INCLUDE_DIRS
andLIBXML2_LIBRARIES
).Reason: Since libxml2 now provides cmake building methods, we should trust the attributes automatically exported by cmake rather than manually implement them. In this way, when we modify the code in
CMakeLists.txt
, we do not need to modifylibxml2.config.cmake.cmake.in
synchronously.Related: microsoft/vcpkg#14588