[libcxx-dev] cmake caches w/additional compile+link flags

Brian Cain via libcxx-dev libcxx-dev at lists.llvm.org
Tue Sep 1 11:12:46 PDT 2020


“trying to use CMake the wrong way, and that's why it gets in your way"

Yes that could very likely be the case.  I want to add compile flags to build with target-specific tuning options in order to build different versions of libcxx.  The driver picks the right version of the library given the corresponding link arguments.

It seems like if there were an empty-by-default-but-overridable-in-cache “LIBCXX_EXTRA_CFLAGS” (and LIBCXXABI_/LIBUNWIND_) it would be an effective way to get what I’m looking for.  But as you point out it might not be the Right Way.

-Brian

From: Louis Dionne <ldionne at apple.com>
Sent: Tuesday, September 1, 2020 12:39 PM
To: Brian Cain <bcain at quicinc.com>
Cc: libcxx-dev at lists.llvm.org
Subject: [EXT] Re: [libcxx-dev] cmake caches w/additional compile+link flags


On Aug 18, 2020, at 11:10, Brian Cain via libcxx-dev <libcxx-dev at lists.llvm.org<mailto:libcxx-dev at lists.llvm.org>> wrote:

In an internal project, we build libcxx+libcxxabi with many settings configured in a cmake cache file.  It gets invoked roughly like so:

cmake -DLLVM_ENABLE_PROJECTS=libcxx;libcxxabi;pstl -C./libcxx/xyz/target.cmake -DCMAKE_INSTALL_PREFIX=/target/install/path ../llvm-project/llvm

… I would prefer to include as many of the relevant build settings as possible in the ‘target.cmake’ file.  Today we clobber “CMAKE_CXX_FLAGS” with the required target-specific flags in that file and it’s effective.  But it doesn’t cooperate well with the rest of the libcxx/libcxxabi cmake configuration.

This seems really simple but I’ve never quite been able to figure out how to append flags to the build configuration from the cmake cache.  I’ve tried a few different ways of writing to LIBCXX_COMPILE_FLAGS (including with CACHE FORCE) but even if the value in LIBCXX_COMPILE_FLAGS persists in the CMakeCache.txt they don’t seem to be reflected in the flags used to build.  So it’s probably some cmake rules I don’t quite understand about the order or scope in which LIBCXX_COMPILE_FLAGS is defined.

I’m sure I’m missing something simple – can anyone share a good way to accomplish my goal of adding/removing compile+link flags in the preloaded cmake cache file?


I'm not sure there's a way to do that -- the question I'd have is what flags are you trying to set? At first sight, it looks to me like you're trying to use CMake the wrong way, and that's why it gets in your way :-). There might be another way of achieving what you're trying to do.

Louis

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libcxx-dev/attachments/20200901/6501208e/attachment-0001.html>


More information about the libcxx-dev mailing list