From cdbcc0330df169c15b23769db27f9c6319004e00 Mon Sep 17 00:00:00 2001 From: Love Billenius Date: Mon, 29 Jan 2024 16:31:51 +0100 Subject: [PATCH] enable static linking if under release mode --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b9a920..d723c95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,11 @@ target_link_libraries(Pong ${SDL2_LIBRARIES} ${SDL2_GFX_LIBRARY} ${SDL2_TTF_LIBR # Set compiler optimization flags if (ENABLE_OPTIMIZATIONS) message(STATUS "Optimizations are enabled") + set_target_properties(Pong PROPERTIES LINK_SEARCH_START_STATIC 1) + set_target_properties(Pong PROPERTIES LINK_SEARCH_END_STATIC 1) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++") + if (MSVC) target_compile_options(Pong PRIVATE /O2) else ()