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

Louis Dionne via libcxx-dev libcxx-dev at lists.llvm.org
Tue Sep 1 10:38:37 PDT 2020

> On Aug 18, 2020, at 11:10, Brian Cain via libcxx-dev <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.


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

More information about the libcxx-dev mailing list