diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-12-06 11:52:26 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-12-06 11:52:26 +0200 |
commit | 6a565ea71745aaf4c91a7698bbf56f7d906fcaaa (patch) | |
tree | e68ed6140097be20ab51193dfd25ac1a4d1c502d /CMakeLists.txt | |
parent | e43ecd3eb279e117cbce8fd507ecef247938e4ac (diff) |
Added build option for sleeping while idle
It appears at least on macOS, SDL is doing a while lot of stuff while waiting for new events. Perhaps because it has some sort of high-frequency input/sensor processing? Not sure.
Now Lagrange will idle by polling events every 15 ms and sleeping in between. This reduces CPU time by an order of magnitude on macOS. Need to still test on other platforms.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 82d55590..0edfbed2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -30,6 +30,7 @@ option (ENABLE_X11_SWRENDER "Use software rendering under X11" OFF) | |||
30 | option (ENABLE_KERNING "Enable kerning in font renderer (slower)" ON) | 30 | option (ENABLE_KERNING "Enable kerning in font renderer (slower)" ON) |
31 | option (ENABLE_RESOURCE_EMBED "Embed resources inside the executable" OFF) | 31 | option (ENABLE_RESOURCE_EMBED "Embed resources inside the executable" OFF) |
32 | option (ENABLE_WINDOWPOS_FIX "Set position after showing window (workaround for SDL bug)" OFF) | 32 | option (ENABLE_WINDOWPOS_FIX "Set position after showing window (workaround for SDL bug)" OFF) |
33 | option (ENABLE_IDLE_SLEEP "While idle, sleep in the main thread instead of waiting for events" ON) | ||
33 | 34 | ||
34 | include (BuildType.cmake) | 35 | include (BuildType.cmake) |
35 | include (res/Embed.cmake) | 36 | include (res/Embed.cmake) |
@@ -219,6 +220,9 @@ if (ENABLE_MPG123 AND MPG123_FOUND) | |||
219 | target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_MPG123=1) | 220 | target_compile_definitions (app PUBLIC LAGRANGE_ENABLE_MPG123=1) |
220 | target_link_libraries (app PUBLIC PkgConfig::MPG123) | 221 | target_link_libraries (app PUBLIC PkgConfig::MPG123) |
221 | endif () | 222 | endif () |
223 | if (ENABLE_IDLE_SLEEP) | ||
224 | target_compile_definitions (app PUBLIC LAGRANGE_IDLE_SLEEP=1) | ||
225 | endif () | ||
222 | target_link_libraries (app PUBLIC the_Foundation::the_Foundation) | 226 | target_link_libraries (app PUBLIC the_Foundation::the_Foundation) |
223 | target_link_libraries (app PUBLIC ${SDL2_LDFLAGS}) | 227 | target_link_libraries (app PUBLIC ${SDL2_LDFLAGS}) |
224 | if (APPLE) | 228 | if (APPLE) |