Added a CMake profiling build type.

This commit is contained in:
Leon Styhre 2020-09-13 23:42:56 +02:00
parent 863063ee47
commit 4a13694794
2 changed files with 20 additions and 3 deletions

View file

@ -119,7 +119,7 @@ elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
endif()
endif()
# Set up compiler flags for debug or release builds.
# Set up compiler and linker flags for debug, profiling or release builds.
if(CMAKE_BUILD_TYPE MATCHES Debug)
# Enable the C++11 standard and disable optimizations as it's a debug build.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O0")
@ -132,6 +132,10 @@ if(CMAKE_BUILD_TYPE MATCHES Debug)
if(NOT APPLE AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_DEBUG")
endif()
elseif(CMAKE_BUILD_TYPE MATCHES Profiling)
# For the profiling build, we enable optimizations and supply the required profiler flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -pg -g")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O2 -pg")
else()
# Enable the C++11 standard and enable optimizations as it's a release build.
# This will also disable all assert() macros. Strip the binary as well.

View file

@ -47,14 +47,27 @@ cmake .
make
```
To generate a debug build, run this instead:
To create a debug build, run this instead:
```
cmake -DCMAKE_BUILD_TYPE=Debug .
make
```
Keep in mind though that a debug version will be much slower due to all compiler optimizations being disabled.
To build with CEC support, add the corresponding option, for example:
To create a profiling build, run this:
```
cmake -DCMAKE_BUILD_TYPE=Profiling .
make
```
You can then profile the code with valgrind:
```
valgrind --tool=callgrind ./emulationstation
```
The output file from valgrind can be loaded into a tool such as KCachegrind for data analysis.
To build ES with CEC support, add the corresponding option, for example:
```
cmake -DCMAKE_BUILD_TYPE=Debug -DCEC=on .