mapcreator git · master
SDL3 2.5D game and engine using assets, with map editor
C++ 99.3%git clone https://git.christianimmanuel.de/sdl-graphics/mapcreator.gitwget https://git.christianimmanuel.de/sdl-graphics/mapcreator/archive/mapcreator.tar.gzAdd super optimisation
CMakeLists.txt | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a8daf63..59ebc1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,12 +5,8 @@ set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(ENABLE_DEBUG "" CACHE STRING "Build mode: empty, NOOPT, DEBUG, or OPTIMIZED") -if(ENABLE_DEBUG) - set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) -endif() - -# Collect only the project's actual sources file(GLOB_RECURSE SRC_FILES ${CMAKE_SOURCE_DIR}/src/*.cpp ) @@ -34,7 +30,29 @@ target_link_libraries(map_editor target_compile_options(map_editor PRIVATE -Wall -Wextra) -if(ENABLE_DEBUG) +if(ENABLE_DEBUG STREQUAL "NOOPT") + target_compile_options(map_editor PRIVATE -O0) + target_compile_definitions(map_editor PRIVATE DEBUG_BUILD) + +elseif(ENABLE_DEBUG STREQUAL "DEBUG") + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE) target_compile_options(map_editor PRIVATE -g -O0) target_compile_definitions(map_editor PRIVATE DEBUG_BUILD) + +elseif(ENABLE_DEBUG STREQUAL "OPTIMIZED") + set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE) + + target_compile_options(map_editor PRIVATE + -O3 + -march=native + -mtune=native + -flto + -fomit-frame-pointer + ) + + target_link_options(map_editor PRIVATE + -flto + ) + + target_compile_definitions(map_editor PRIVATE NDEBUG) endif()