diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e4e208..2503bad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,19 @@ set_target_properties( #target_compile_options(ninja-clown PRIVATE "-fsanitize=address") #target_link_options(ninja-clown PRIVATE "-fsanitize=address") +# Do not open console on Windows +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")) + # https://learn.microsoft.com/en-us/cpp/build/reference/subsystem-specify-subsystem + # https://learn.microsoft.com/en-us/cpp/build/reference/entry-entry-point-symbol + target_link_options(ninja-clown PRIVATE + "/SUBSYSTEM:WINDOWS" + "/ENTRY:mainCRTStartup" + ) +elseif(MINGW) + # https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/x86-Windows-Options.html + target_link_options(ninja-clown PRIVATE "-mwindows") +endif() + target_include_directories(ninja-clown PUBLIC ${CMAKE_CURRENT_LIST_DIR}/src/ ${CMAKE_CURRENT_LIST_DIR}/bindings/c/) target_include_directories(ninja-clown SYSTEM PUBLIC ${IMGUI_SFML_INCLUDE_DIR} diff --git a/src/main.cpp b/src/main.cpp index 77224c4..f06c51e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,49 +5,13 @@ #include "state_holder.hpp" -int actual_main(std::vector &args); - -#ifdef USE_WINMAIN -#include -#include -#include - -INT WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, INT) { - - int argc; - LPWSTR *lpArgv = CommandLineToArgvW(GetCommandLineW(), &argc); - - std::vector args; - args.reserve(argc); - for (int i = 0; i < argc; ++i) { - size_t size = wcslen(lpArgv[i]) + 1; - std::string arg; - arg.resize(size); - wcstombs_s(nullptr, arg.data(), arg.size(), lpArgv[i], size); - args.emplace_back(std::move(arg)); - } - LocalFree(lpArgv); - return actual_main(args); -} -#else -int main(int argc, char *argv[]) { - std::vector args; - args.reserve(argc); - while ((argc--) != 0) { - args.emplace_back(*argv++); - } - return actual_main(args); -} -#endif - -int actual_main([[maybe_unused]] std::vector &args) { +int main() { spdlog::default_logger()->set_level(spdlog::level::trace); + // TODO: ajouter un logger à spdlog qui fait des popups pour les erreurs state::holder game{"resources/autorun.ncs"}; game.run(); game.wait(); return 0; - - // todo : ajouter un logger à spdlog qui fait des popups pour les erreurs }