Question about CMAKE_CXX_ABI_COMPILED Flag Variable

I am attempting to cross-compile gRPC (https://github.com/grpc/grpc) from Windows to Linux as a third-party dependency using CMake and the Clang compiler, and I am also attempting to link to a pre-compiled version of libc++.

Here is what I believe is the relevant section of my toolchain file:

set(CMAKE_CXX_ABI_COMPILED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${LIBCXX_DIR}/include/c++/v1")
add_compile_options(--target=${triple} --sysroot=${CMAKE_SYSROOT})

add_link_options(-v --target=${triple} --sysroot=${CMAKE_SYSROOT} -L${LIBCXX_DIR}/lib/Linux/${triple})

If I execute this, then I am able to compile and link successfully; however, the following line does not seem like it should be necessary: set(CMAKE_CXX_ABI_COMPILED ON). If I do not include this line in my toolchain file, then I get the following error:

-- Detecting CXX compiler ABI info - failed

Is it OK for me to set the CMAKE_CXX_ABI_COMPILED flag variable or am I masking an issue in my toolchain file? I am using cmake version 3.18.4.

Here is where I got the idea to implement this workaround in case it helps: https://github.com/ruslo/polly/issues/152.

@brad.king

CMAKE_CXX_ABI_COMPILED is an internal implementation detail that should not be set by projects. Don’t try to skip CMake’s toolchain initialization checks. They are important for CMake to detect things it needs to know to generate a proper buildsystem.

Detecting CXX compiler ABI info - failed

There should be more information about that failure in the CMakeFiles/CMakeError.log file.