Cmake: Difference between revisions
Jump to navigation
Jump to search
(Created page with "== Select toolchain == === On Windows === On Windows, cmake default to the latest Visual Studio version installed on the system. To select MinGW toolchain [https://stackoverfl...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 5: | Line 5: | ||
cmake -G "MinGW Makefiles" . |
cmake -G "MinGW Makefiles" . |
||
</source> |
</source> |
||
== Tips == |
|||
=== Print variables === |
|||
<source lang="cmake"> |
|||
# Using message |
|||
message(PROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}") |
|||
# Using helper: |
|||
include(CMakePrintHelpers) |
|||
cmake_print_variables(PROJECT_SOURCE_DIR ANOTHER_VARIABLE |
|||
</source> |
|||
=== Verbose build === |
|||
* Add <code>CMAKE_VERBOSE_MAKEFILE</code> to {{file|CMakeLists.txt}} (note: it only applies to current file): |
|||
<source lang="cmake"> |
|||
set(CMAKE_VERBOSE_MAKEFILE ON) |
|||
</source> |
|||
* Add <code>-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON</code> to cmake command to enable it for all files: |
|||
<source lang="bash"> |
|||
cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON .. |
|||
</source> |
|||
* Add <code>VERBOSE=1</code> to make command: |
|||
<source lang="bash"> |
|||
cmake ..; make VERBOSE=1 |
|||
</source> |
|||
See [https://bytefreaks.net/programming-2/make-building-with-cmake-verbose here] for more. |
Latest revision as of 09:51, 13 June 2023
Select toolchain
On Windows
On Windows, cmake default to the latest Visual Studio version installed on the system. To select MinGW toolchain [1]:
cmake -G "MinGW Makefiles" .
Tips
Print variables
# Using message
message(PROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}")
# Using helper:
include(CMakePrintHelpers)
cmake_print_variables(PROJECT_SOURCE_DIR ANOTHER_VARIABLE
Verbose build
- Add
CMAKE_VERBOSE_MAKEFILE
to CMakeLists.txt (note: it only applies to current file):
set(CMAKE_VERBOSE_MAKEFILE ON)
- Add
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
to cmake command to enable it for all files:
cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ..
- Add
VERBOSE=1
to make command:
cmake ..; make VERBOSE=1
See here for more.