... | ... | @@ -212,6 +212,20 @@ set `CMAKE_REQUIRED_LIBRARIES`, `CMAKE_REQUIRED_FLAGS` and |
|
|
`CMAKE_REQUIRED_INCLUDES` accordingly if additional libraries or
|
|
|
compiler flags are required.
|
|
|
|
|
|
-----
|
|
|
|
|
|
- Module: `include(CheckCCompilerFlag)`, `include(CheckCXXCompilerFlag)`
|
|
|
- Example:
|
|
|
```cmake
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
check_cxx_compiler_flag(-Wno-unused-local-typedefs CXX_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS)
|
|
|
|
|
|
if(CXX_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS)
|
|
|
string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-local-typedefs")
|
|
|
endif()
|
|
|
```
|
|
|
Checks whether a certain compiler flag is accepted by the current C or C++ compiler. This is useful if you want to safely use a compiler flag that only exists in certain compilers or certain versions of a compiler.
|
|
|
|
|
|
## Platform Checking
|
|
|
|
|
|
Sometimes, you will also want to have logic predicated on what operating system the build is being run on. This is important for things like which shell scripts to run, and where to look for dependencies. Luckily, CMake has several useful utilities for dealing with this.
|
... | ... | |