From 3f4bbc2c5d20695416edd6b42865707f56ae3e16 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 2 Apr 2020 22:18:46 +0100 Subject: [PATCH 1/4] Add some options to DoConfig's CMake --- DoConfig/CMakeLists.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/DoConfig/CMakeLists.txt b/DoConfig/CMakeLists.txt index 2491d399..6df9ec78 100644 --- a/DoConfig/CMakeLists.txt +++ b/DoConfig/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION 3.12) +option(PKG_CONFIG_STATIC_LIBS "On platforms with pkg-config, static-link the dependencies (good for Windows builds, so you don't need to bundle DLL files)" OFF) +option(MSVC_LINK_STATIC_RUNTIME "Link the static MSVC runtime library (Visual Studio only)" OFF) + option(FORCE_LOCAL_LIBS "Compile the built-in version of GLFW3 instead of using the system-provided one" OFF) project(DoConfig LANGUAGES C CXX) @@ -40,12 +43,27 @@ target_link_libraries(DoConfig PRIVATE ${CMAKE_DL_LIBS}) target_include_directories(DoConfig PRIVATE "../external/glad/include") target_compile_definitions(DoConfig PRIVATE IMGUI_IMPL_OPENGL_LOADER_GLAD) +if(PKG_CONFIG_STATIC_LIBS) + target_link_options(DoConfig PRIVATE "-static") +endif() + if(MSVC) # Disable warnings that normally fire up on MSVC when using "unsafe" functions instead of using MSVC's "safe" _s functions target_compile_definitions(DoConfig PRIVATE _CRT_SECURE_NO_WARNINGS) # Use `main` instead of `WinMain` set_target_properties(DoConfig PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup") + + # This is messy as hell, and has been replaced by CMAKE_MSVC_RUNTIME_LIBRARY, + # but that's a very recent CMake addition, so we're still doing it this way for now + if(MSVC_LINK_STATIC_RUNTIME) + # Statically-link the CRT (vcpkg static libs do this) + foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag_var} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + endif() + endforeach() + endif() endif() From ef00bbcdd421fa9e6bd9e554ccd76e3635b98f56 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 2 Apr 2020 22:03:08 +0100 Subject: [PATCH 2/4] Get window icon working in GLFW Amazingly, this actually works in SDL2, so now they both use this method. --- assets/resources/CSE2.rc | 3 +-- assets/resources/ICON/0.ico | Bin 766 -> 0 bytes assets/resources/ICON/GLFW_ICON.ico | Bin 0 -> 1078 bytes assets/resources/ICON/ICON_MINI.ico | Bin 318 -> 0 bytes src/Backends/Platform/SDL2.cpp | 5 ----- src/Main.cpp | 1 - 6 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 assets/resources/ICON/0.ico create mode 100644 assets/resources/ICON/GLFW_ICON.ico delete mode 100644 assets/resources/ICON/ICON_MINI.ico diff --git a/assets/resources/CSE2.rc b/assets/resources/CSE2.rc index 48848b9a..02239a9d 100644 --- a/assets/resources/CSE2.rc +++ b/assets/resources/CSE2.rc @@ -66,8 +66,7 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. -101 ICON "ICON/0.ico" -102 ICON "ICON/ICON_MINI.ico" +GLFW_ICON ICON "ICON/GLFW_ICON.ico" #endif // Japanese resources ///////////////////////////////////////////////////////////////////////////// diff --git a/assets/resources/ICON/0.ico b/assets/resources/ICON/0.ico deleted file mode 100644 index 33fc2aa3c0323cfa9877ff309e47b8640446278d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 766 zcmcgqF>b>!45XU^DzcJmLhP-N5X)!N}xWrimU53(mT(crs$X#f%;d ziyJ=xM!=rFV=K8NIe91@|zdUj7{GRqJQx% zPxN8AXem12Wh}W~GeRFHv(uiu5PEJryRJvGV>WuF*qPYMZU?UwX_^MM#RYN( zAq0^D_7MD~nXvH1X8&f+ixj@Mch0y-O<|q^6j*L^-oF3X$8a-W=e$ngb|IpQ$_r1x zxki2|$o)kD3^pe=vyt(JmR#$4XIS)S9o$nH~~C_v4($L-I)Is^iIY9pyZ7D?6V; z)D3G*p9|;k#MJ7cEr9Z`rGMdNNB$Am57Wk!0*aRTFb;U)+^h$eywiDi)G@T_!E}rb lYW+>eC&d8H2Oh=RbEb9pJ^@QIXmSGaN@i3Bc}j~C+7^0 zQvwdoOz#|-2|FSnfgOC-UwAEjC=xr4lxVGyDPVD7=8DPVErO~715vduL0W2OtM3pm vUt;|DzK;?ZeIRtPLG`(st)GoAdX>p+I_s?f^GxSbJt!XB4};BxANnJ{3z1#C diff --git a/src/Backends/Platform/SDL2.cpp b/src/Backends/Platform/SDL2.cpp index b24deb70..1c221881 100644 --- a/src/Backends/Platform/SDL2.cpp +++ b/src/Backends/Platform/SDL2.cpp @@ -27,11 +27,6 @@ void PlatformBackend_Init(void) { SDL_Init(SDL_INIT_EVENTS); -#ifdef _WIN32 // On Windows, we use native icons instead (so we can give the taskbar and window separate icons, like the original EXE does) - SDL_SetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON, "101"); - SDL_SetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL, "102"); -#endif - SDL_InitSubSystem(SDL_INIT_VIDEO); puts("Available SDL2 video drivers:"); diff --git a/src/Main.cpp b/src/Main.cpp index 8f577866..50b7dc06 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -273,7 +273,6 @@ int main(int argc, char *argv[]) #endif // Set up window icon - // TODO - GLFW_ICON #ifndef _WIN32 // On Windows, we use native icons instead (so we can give the taskbar and window separate icons, like the original EXE does) size_t window_icon_resource_size; const unsigned char *window_icon_resource_data = FindResource("ICON_MINI", "ICON", &window_icon_resource_size); From 54797a05f8563ebd6ad7d85cabadc30a3b94686a Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 2 Apr 2020 22:14:36 +0100 Subject: [PATCH 3/4] Do not create `imgui.ini` --- DoConfig/DoConfig.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DoConfig/DoConfig.cpp b/DoConfig/DoConfig.cpp index 179b4826..1909c222 100644 --- a/DoConfig/DoConfig.cpp +++ b/DoConfig/DoConfig.cpp @@ -75,6 +75,8 @@ int main(int argc, char *argv[]) IMGUI_CHECKVERSION(); ImGui::CreateContext(); + ImGuiIO &io = ImGui::GetIO(); + io.IniFilename = NULL; // Disable `imgui.ini` ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init(glsl_version); From 0846a1b3b92d2dd949cf29cb34d59d8e801cc631 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 2 Apr 2020 22:14:55 +0100 Subject: [PATCH 4/4] Make DoConfig icon appear in window on Windows --- DoConfig/icon.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DoConfig/icon.rc b/DoConfig/icon.rc index 8431cd4b..657ee6c7 100644 --- a/DoConfig/icon.rc +++ b/DoConfig/icon.rc @@ -1 +1 @@ -102 ICON "1.ico" +GLFW_ICON ICON "1.ico"