mirror of
https://github.com/lov3b/Pong.git
synced 2025-01-18 20:50:12 +01:00
optimizations
This commit is contained in:
parent
50f36d4926
commit
905d20efb6
@ -3,6 +3,9 @@ project(Pong)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
# Option for enabling optimizations
|
||||||
|
option(ENABLE_OPTIMIZATIONS "Enable compiler optimizations" OFF)
|
||||||
|
|
||||||
# Base SDL2
|
# Base SDL2
|
||||||
find_package(SDL2 REQUIRED)
|
find_package(SDL2 REQUIRED)
|
||||||
include_directories(${SDL2_INCLUDE_DIRS})
|
include_directories(${SDL2_INCLUDE_DIRS})
|
||||||
@ -33,3 +36,13 @@ add_executable(Pong src/main.cpp
|
|||||||
|
|
||||||
# Now link the libraries to the target
|
# Now link the libraries to the target
|
||||||
target_link_libraries(Pong ${SDL2_LIBRARIES} ${SDL2_GFX_LIBRARY} ${SDL2_TTF_LIBRARY})
|
target_link_libraries(Pong ${SDL2_LIBRARIES} ${SDL2_GFX_LIBRARY} ${SDL2_TTF_LIBRARY})
|
||||||
|
|
||||||
|
# Set compiler optimization flags
|
||||||
|
if(ENABLE_OPTIMIZATIONS)
|
||||||
|
message(STATUS "Optimizations are enabled")
|
||||||
|
if(MSVC)
|
||||||
|
target_compile_options(Pong PRIVATE /O2)
|
||||||
|
else()
|
||||||
|
target_compile_options(Pong PRIVATE -O3)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
# Pong
|
# Pong
|
||||||
|
|
||||||
A pong implementation in C++. You'll need cmake make, sdl2 sdl2-gfx and sdl2-ttf to compile.
|
A pong implementation in C++. You'll need cmake make, sdl2 sdl2-gfx and sdl2-ttf to compile.
|
||||||
|
|
||||||
|
To enable compiler optimizations pass `-DENABLE_OPTIMIZATIONS=ON` to cmake. You'll end up with the following command `cmake -DENABLE_OPTIMIZATIONS=ON`.
|
Loading…
x
Reference in New Issue
Block a user