2
0
Fork 0
mirror of https://github.com/bazel-contrib/rules_foreign_cc synced 2024-11-28 08:43:26 +00:00

Build msvc cmake with prebuilt cmake (#1148)

This commit is contained in:
Matt Smith 2024-01-13 08:37:09 +11:00 committed by GitHub
parent a87e7542ee
commit 930dcb97b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 4 deletions

View file

@ -1,14 +1,40 @@
""" Rule for building CMake from sources. """ """ Macro for building CMake from sources. """
load("//foreign_cc:defs.bzl", "configure_make") load("//foreign_cc:defs.bzl", "cmake_variant", "configure_make")
def cmake_tool(name, srcs, **kwargs): def cmake_tool(name, srcs, **kwargs):
"""Macro for building CMake
Args:
name: A unique name for this target
srcs: The target containing the build tool's sources
**kwargs: Remaining args
"""
tags = ["manual"] + kwargs.pop("tags", []) tags = ["manual"] + kwargs.pop("tags", [])
configure_make( native.alias(
name = "{}.build".format(name), name = "{}.build".format(name),
actual = select({
":msvc_compiler": "{}_msvc".format(name),
"//conditions:default": "{}_default".format(name),
}),
)
cmake_variant(
name = "{}_msvc".format(name),
# to prevent errors with incompatible _WIN32_WINNT in cmlibarchive
# override NTDDI_VERSION to match _WIN32_WINNT set in the default cc_toolchain
copts = ["/D NTDDI_VERSION=0x06010000"],
lib_source = srcs,
out_binaries = ["cmake.exe"],
toolchain = "@rules_foreign_cc//toolchains:preinstalled_cmake_toolchain",
tags = tags,
**kwargs
)
configure_make(
name = "{}_default".format(name),
configure_command = "bootstrap", configure_command = "bootstrap",
configure_options = ["--", "-DCMAKE_MAKE_PROGRAM=$$MAKE$$"],
# On macOS at least -DDEBUG gets set for a fastbuild # On macOS at least -DDEBUG gets set for a fastbuild
copts = ["-UDEBUG"], copts = ["-UDEBUG"],
lib_source = srcs, lib_source = srcs,

View file

@ -72,6 +72,9 @@ def _cmake_toolchain(version, register_toolchains):
sha256 = sha256, sha256 = sha256,
strip_prefix = prefix, strip_prefix = prefix,
urls = urls, urls = urls,
patches = [
Label("//toolchains:cmake-c++11.patch"),
],
) )
return return

View file

@ -0,0 +1,15 @@
See <https://discourse.cmake.org/t/cmake-error-at-cmakelists-txt-117-message-the-c-compiler-does-not-support-c-11-e-g-std-unique-ptr/3774/8>
--- CMakeLists.txt 2023-01-24 13:46:17.000000000 -0800
+++ CMakeLists.txt 2023-01-24 13:46:43.000000000 -0800
@@ -96,10 +96,6 @@
# check for available C++ features
include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx_features.cmake)
-
- if(NOT CMake_HAVE_CXX_UNIQUE_PTR)
- message(FATAL_ERROR "The C++ compiler does not support C++11 (e.g. std::unique_ptr).")
- endif()
endif()
# Inform STL library header wrappers whether to use system versions.