From 7472a681d0e3d22879024e1aff28e62cf6f7c80d Mon Sep 17 00:00:00 2001 From: Boying Xu Date: Wed, 13 Mar 2024 22:00:25 +0800 Subject: [PATCH] Simplify hello_imgui_add_app win32 implementation Before passing source list to add_executable function: * HELLOIMGUI_WIN32_NO_CONSOLE: Prepending "WIN32" flag to the source list * HELLOIMGUI_WIN32_AUTO_WINMAIN: Appending HelloImGui_WinMain.cpp file to the source list --- hello_imgui_cmake/hello_imgui_add_app.cmake | 26 +++++++++------------ 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/hello_imgui_cmake/hello_imgui_add_app.cmake b/hello_imgui_cmake/hello_imgui_add_app.cmake index be08db6d..9cc9d8ce 100644 --- a/hello_imgui_cmake/hello_imgui_add_app.cmake +++ b/hello_imgui_cmake/hello_imgui_add_app.cmake @@ -52,30 +52,26 @@ function(hello_imgui_add_app) ") ############################################################################# - - # Add the target for the application - if (ANDROID) - add_library(${app_name} SHARED ${app_sources}) - else() - add_executable(${app_name} ${app_sources}) - endif() - # If windows, and if the user wants to, we can make this an app without console # and provide a WinMain entry point if (WIN32) if (HELLOIMGUI_WIN32_NO_CONSOLE) - # Make this an app without console, and use HelloImGui_WinMain.cpp - if (MINGW) - target_link_options(${app_name} PRIVATE -Wl,--subsystem,windows) - else() # If MSVC - target_link_options(${app_name} PRIVATE /SUBSYSTEM:WINDOWS) - endif() + # Make this an app without console + list(PREPEND app_sources WIN32) endif() if (HELLOIMGUI_WIN32_AUTO_WINMAIN) - target_sources(${app_name} PRIVATE ${HELLOIMGUI_CMAKE_PATH}/HelloImGui_WinMain.cpp) + # Use HelloImGui_WinMain.cpp + list(APPEND app_sources ${HELLOIMGUI_CMAKE_PATH}/HelloImGui_WinMain.cpp) endif() endif() + # Add the target for the application + if (ANDROID) + add_library(${app_name} SHARED ${app_sources}) + else() + add_executable(${app_name} ${app_sources}) + endif() + hello_imgui_prepare_app(${app_name} ${assets_location}) endfunction()