Skip to content

Commit 0c9af66

Browse files
authored
Update README.md
1 parent ffebdf9 commit 0c9af66

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,47 @@ sources from the project tree.
7777

7878
### CMake Initialization
7979

80+
As with most CMake projects, cmake-init initializes the CMake environment. This includes the minimum required CMake version,
81+
82+
```cmake
83+
# CMake version
84+
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
85+
```
86+
87+
required policies,
88+
89+
```cmake
90+
# Set policies
91+
set_policy(CMP0054 NEW) # ENABLE CMP0054: Only interpret if() arguments as variables or keywords when unquoted.
92+
set_policy(CMP0042 NEW) # ENABLE CMP0042: MACOSX_RPATH is enabled by default.
93+
set_policy(CMP0063 NEW) # ENABLE CMP0063: Honor visibility properties for all target types.
94+
```
95+
96+
adaption of the cmake module path,
97+
98+
```cmake
99+
# Include cmake modules
100+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
101+
```
102+
103+
and an include of default modules that are typically required for each project.
104+
105+
```cpp
106+
include(GenerateExportHeader)
107+
include(WriteCompilerDetectionHeader)
108+
```
109+
110+
As some modules as `WriteCompilerDetectionHeader` may not be available, cmake-init suggests to use fallbacks and availability detection.
111+
112+
```cmake
113+
set(WriterCompilerDetectionHeaderFound NOTFOUND)
114+
# This module is only available with CMake >=3.1, so check whether it could be found
115+
# BUT in CMake 3.1 this module doesn't recognize AppleClang as compiler, so just use it as of CMake 3.2
116+
if (${CMAKE_VERSION} VERSION_GREATER "3.2")
117+
include(WriteCompilerDetectionHeader OPTIONAL RESULT_VARIABLE WriterCompilerDetectionHeaderFound)
118+
endif()
119+
```
120+
80121
### CMake Backward Compatibility
81122

82123
### Project Meta Information

0 commit comments

Comments
 (0)