Skip to content

Commit 57a68e8

Browse files
armansitohollasch
authored andcommitted
[README] Update optimized build instructions
* Add instructions for optimized builds that work across Windows (MSVC) and Unix (Linux/macOS, using GCC/Clang). * Add log messages to CMakeLists.txt that prints out `CMAKE_CXX_FLAGS_DEBUG` and `CMAKE_CXX_FLAGS_RELEASE`. This seems to work on all platforms that I tested and profile useful information about the flags used by the underlying toolchain. Fixes #1432
1 parent 12d27c4 commit 57a68e8

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ include_directories(src)
9393
# different compiler or want to set different compiler options.
9494

9595
message (STATUS "Compiler ID: " ${CMAKE_CXX_COMPILER_ID})
96+
message (STATUS "Release flags: " ${CMAKE_CXX_FLAGS_RELEASE})
97+
message (STATUS "Debug flags: " ${CMAKE_CXX_FLAGS_DEBUG})
9698

9799
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
98100
add_compile_options("/we 4265") # Class has virtual functions, but its non-trivial destructor is not virtual

README.md

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,34 @@ You can specify the target with the `--target <program>` option, where the progr
145145

146146
$ cmake --build build --target inOneWeekend
147147

148-
You can build either `debug` (the default) or `release` (the optimized version). To specify this,
149-
use the `--config <debug|release>` option.
150-
151-
$ cmake --build build --config release
152-
153-
We recommend building and running the `release` version (especially before the final render) for
154-
fastest results, unless you need extra debugging information of the (default) debug build.
148+
### Optimized Builds
149+
CMake supports Release and Debug configurations. These require slightly different invocations
150+
across Windows (MSVC) and Linux/macOS (using GCC or Clang). The following instructions will place
151+
optimized binaries under `build/Release` and debug binaries (unoptimized and containing debug
152+
symbols) under `build/Debug`:
153+
154+
On Windows:
155+
156+
```shell
157+
$ cmake -B build
158+
$ cmake --build build --config Release # Create release binaries in `build/Release`
159+
$ cmake --build build --config Debug # Create release binaries in `build/Debug`
160+
```
161+
162+
On Linux / macOS:
163+
164+
```shell
165+
# Configure and build release binaries under `build/Release`
166+
$ cmake -B build/Release -DCMAKE_BUILD_TYPE=Release
167+
$ cmake --build build/Release
168+
169+
# Configure and build debug binaries under `build/Debug`
170+
$ cmake -B build/Debug -DCMAKE_BUILD_TYPE=Debug
171+
$ cmake --build build/Debug
172+
```
173+
174+
We recommend building and running the `Release` version (especially before the final render) for
175+
the fastest results, unless you need extra debugging information of the (default) debug build.
155176

156177
### CMake GUI on Windows
157178
You may choose to use the CMake GUI when building on windows.

0 commit comments

Comments
 (0)