[llvm-dev] Leveraging newer CMake features for Language standards

Chuck Atkins via llvm-dev llvm-dev at lists.llvm.org
Thu Oct 20 08:49:12 PDT 2016


LLVM currently has CMake code to try to detect the various options needed
to compile with C++11 support that has been around since prior to the CMake
version bump.  One of the nicer features that came with the newer required
CMake version is that very thing. Rather than try to discern this yourself
CMake has the CXX_STANDARD and CXX_STANDARD_REQUIRED target properties.  If
set appropriately on a given target then the approiate compiler flags for
that language standard as known by CMake with be applied.  You can set the
global default for this by defining in teh cop level CMakeLists.txt:

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

Unrelated but in a similar situation is the -fPIC flag.  The
POSITION_INDEPENDENT_CODE target proeprty is available, which can be
initialized toa default value with:

set(CMAKE_POSITION_INDEPENDENT_CODE True)

What are peoples thoughts about reducing HandleLLVMOptions.cmake to factor
out and leverage options that CMake already knows about and knows how to
apply?  I wanted to put a bit of time into this but didn't want to spin my
wheels if there were major objections to idea.

----------
Chuck Atkins
Staff R&D Engineer, Scientific Computing
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161020/4902f020/attachment.html>


More information about the llvm-dev mailing list