Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#
#-------------------------------------------------
cmake_minimum_required(VERSION 3.13)
cmake_policy(SET CMP0144 NEW)
project(
MrDocs
VERSION 0.8.0
Expand Down Expand Up @@ -550,11 +551,15 @@ if (MRDOCS_BUILD_TESTS)
#-------------------------------------------------
# XML lint
#-------------------------------------------------
if (MRDOCS_BUILD_STRICT_TESTS)
# Strict mode expects xml-lint to run; require LibXml2.
find_package(LibXml2 REQUIRED)
else()
find_package(LibXml2)
# Try config mode first (e.g. libxml2 installed by bootstrap.py),
# then fall back to module mode (e.g. system libxml2-dev on Linux).
find_package(LibXml2 CONFIG)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, but I think there's a way to make config fall back to regular mode. If so, it would be more like:

if (MRDOCS_BUILD_STRICT_TESTS)
    # Strict mode expects xml-lint to run; require LibXml2.
    find_package(LibXml2 CONFIG REQUIRED)
else()
    find_package(LibXml2 CONFIG)
 endif()

If we use this pattern often, we can also create a REQUIRED_IF_STRICT_TESTS variable.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do:

set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
if (MRDOCS_BUILD_STRICT_TESTS)
    find_package(LibXml2 REQUIRED)
else()
    find_package(LibXml2)
endif()

The variable is documented since CMake 3.15. MrDocs requires CMake >= 3.13, though, so we'd need to check if 3.15 is acceptable; but, realistically, any current toolchain has it.

Downside: CMAKE_FIND_PACKAGE_PREFER_CONFIG is global, so it would affect all subsequent find_package calls in the same scope. We could use a save/restore.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. Great idea.

I'm looking at this again, and I suspect #1168 will end up obsoleting this PR, though. Because the new bootstrap script had to cover all of that to actually work in CI. So it had to fix the root of the problem.

if (NOT LibXml2_FOUND)
if (MRDOCS_BUILD_STRICT_TESTS)
find_package(LibXml2 REQUIRED)
else()
find_package(LibXml2)
endif()
endif()
if (LibXml2_FOUND)
find_package(Java REQUIRED Runtime)
Expand Down
2 changes: 0 additions & 2 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion util/bootstrap/src/recipes/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def recipe_placeholders(
Returns:
Dictionary mapping placeholder names to values.
"""
host_suffix = "windows" if is_windows() else "unix"
host_suffix = "win" if is_windows() else "unix"
return {
"BOOTSTRAP_BUILD_TYPE": recipe.build_type,
"BOOTSTRAP_BUILD_TYPE_LOWER": recipe.build_type.lower(),
Expand Down
Loading