When using
set(var "Example")
if (${var})
CMake will first resolve the if-argument to
if (Example)
And what then happens depends on the existance of a variable with the
name "Example":
1. If instead of "Example", a truth constant is used ("TRUE", "FALSE",
"ON", "OFF", "", "-NOTFOUND" ...), it is prioritized
(https://cmake.org/cmake/help/latest/command/if.html#constant)
2. If a variable with the name "Example" exists: Use the truthiness of
its content
(https://cmake.org/cmake/help/latest/command/if.html#variable)
3. Otherwise, it is false-y
That is, the the result of the conditional does not only depend on the
content of `var`, but also some other variable. This is usually
unintended and leads to problems such as addressed with #154537. The
only case where this is intended is when passing an expression to be
evaluated such as with `pythonize_bool`, `append_if` and
`libomp_append`. In all other cases, using `${var}` without quotes is a
pattern to be avoided.
Remark:
If `${var}` is not one of the values considered a [truthiness
constant](https://cmake.org/cmake/help/latest/command/if.html#constant),
the result of `if (var)` and `if ("${var}")` is different:
* `if (var)` is true-ish
(https://cmake.org/cmake/help/latest/command/if.html#variable)
* `if ("Example")` and therefore `if ("${var}")` are false-y
(https://cmake.org/cmake/help/latest/command/if.html#string)
In this PR I am preferring `if (var)` over `if ("${var}")` because has
less clutter, resembles Python's behaviour, and problably what most
users are expecting, even though `if (${var})` in most cases would
evaluate to false-y because a variable does not exist. This ambiguity
does not exist for STREQUAL and MATCHES.
The LLVM Compiler Infrastructure
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called "LLVM". This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Getting the Source Code and Building LLVM
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Getting in touch
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.