From ecc60303da117c8f14bf288a5712da28e14899a2 Mon Sep 17 00:00:00 2001 From: Liangliang Nan Date: Wed, 28 Sep 2022 19:49:01 +0200 Subject: [PATCH] add with/without console option --- .../CMakeLists.txt | 16 +++++----- .../Tutorial_203_Viewer_wxWidgets/main.cpp | 29 ++++++++++--------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/tutorials/Tutorial_203_Viewer_wxWidgets/CMakeLists.txt b/tutorials/Tutorial_203_Viewer_wxWidgets/CMakeLists.txt index d12366f1f..e105140b6 100644 --- a/tutorials/Tutorial_203_Viewer_wxWidgets/CMakeLists.txt +++ b/tutorials/Tutorial_203_Viewer_wxWidgets/CMakeLists.txt @@ -42,16 +42,16 @@ set(SRC_FILES ) if (WIN32 OR MSVC) - option(EASY3D_wxWidget_Viewer_with_console "Build the wxWidget viewer with a console window" ON) + option(WIN32_wxWidget_Viewer_No_Console "Build the wxWidget viewer without a console window" ON) list(APPEND SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Resources/sample.rc) # Include a RC file for windows - if (EASY3D_wxWidget_Viewer_with_console) - add_executable(${PROJECT_NAME} ${SRC_FILES}) - target_compile_definitions(${PROJECT_NAME} PRIVATE VIEWER_WITH_CONSOLE_WINDOW) - message(STATUS "Creating the wxWidgets viewer with a console window") - else () - add_executable(${PROJECT_NAME} WIN32 ${SRC_FILES}) - message(STATUS "Creating the wxWidgets viewer without a console window") + if (WIN32_wxWidget_Viewer_No_Console) + add_executable(${PROJECT_NAME} WIN32 ${SRC_FILES}) + message(STATUS "Creating the wxWidgets viewer without a console window") + else () + add_executable(${PROJECT_NAME} ${SRC_FILES}) + target_compile_definitions(${PROJECT_NAME} PRIVATE WIN32_VIEWER_WITHOUT_CONSOLE) + message(STATUS "Creating the wxWidgets viewer with a console window") endif () elseif (APPLE) set(${PROJECT_NAME}_ICON ${CMAKE_CURRENT_SOURCE_DIR}/Resources/sample.icns) diff --git a/tutorials/Tutorial_203_Viewer_wxWidgets/main.cpp b/tutorials/Tutorial_203_Viewer_wxWidgets/main.cpp index 1f8f590df..62be72b5e 100644 --- a/tutorials/Tutorial_203_Viewer_wxWidgets/main.cpp +++ b/tutorials/Tutorial_203_Viewer_wxWidgets/main.cpp @@ -48,28 +48,29 @@ class Easy3DApp : public wxApp { -#if 0 - -#ifdef VIEWER_WITH_CONSOLE_WINDOW -wxIMPLEMENT_APP_CONSOLE(Easy3DApp); -#else -wxIMPLEMENT_APP(Easy3DApp); -#endif +#if 1 +#ifdef WIN32_VIEWER_WITHOUT_CONSOLE +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, wxCmdLineArgType lpCmdLine, int nCmdShow) { + wxDisableAsserts(); + return wxEntry(hInstance, hPrevInstance, lpCmdLine, nCmdShow); +} #else - -#ifdef VIEWER_WITH_CONSOLE_WINDOW int main(int argc, char **argv) { wxDisableAsserts(); return wxEntry(argc, argv); } -#else -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, wxCmdLineArgType lpCmdLine, int nCmdShow) { - wxDisableAsserts(); - return wxEntry(hInstance, hPrevInstance, lpCmdLine, nCmdShow); -} #endif wxAppInitializer wxTheAppInitializer([]() -> wxAppConsole * { return new Easy3DApp; }); +#else // WIN32_VIEWER_WITHOUT_CONSOLE + +#ifdef WIN32_VIEWER_WITHOUT_CONSOLE +wxIMPLEMENT_APP(Easy3DApp); +#else +wxIMPLEMENT_APP_CONSOLE(Easy3DApp); + +#endif // WIN32_VIEWER_WITHOUT_CONSOLE + #endif