diff options
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | buildtools/cmake/Win32Subsystem.cmake | 31 | ||||
-rw-r--r-- | source/Level.cpp | 6 |
3 files changed, 37 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 4800935..7d4ecf6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() include(buildtools/cmake/RTTI.cmake) +include(buildtools/cmake/Win32Subsystem.cmake) find_package(OpenGL REQUIRED) add_subdirectory(3rdparty/glfw) @@ -141,6 +142,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE things_codegen_base ) +target_use_windows_subsystem(${PROJECT_NAME}) + option(BRUSSEL_ENABLE_PROFILING "Whether profiling support is enabled or not." OFF) if(BRUSSEL_ENABLE_PROFILING) target_compile_definitions(${PROJECT_NAME} diff --git a/buildtools/cmake/Win32Subsystem.cmake b/buildtools/cmake/Win32Subsystem.cmake new file mode 100644 index 0000000..8546fd9 --- /dev/null +++ b/buildtools/cmake/Win32Subsystem.cmake @@ -0,0 +1,31 @@ +function(target_use_windows_subsystem TARGET_NAME) + if(WIN32) + function(handle_msvc_style_compiler) + target_link_options(${TARGET_NAME} PRIVATE /SUBSYSTEM:windows /ENTRY:mainCRTStartup) + endfunction() + + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # GCC (MinGW) + # Supposedly the flag -mwindows would automatically make the executable use GUI subsystem + # But, when subsystem is set to GUI, linker will only search WinMain and wWinMain but not the standard main (it seems like) + # so creating GUI executable fails and the linker silently reverts to the default, CUI subsystem + target_link_options(${TARGET_NAME} PRIVATE -Wl,-subsystem,windows) + target_link_options(${TARGET_NAME} PRIVATE -Wl,-entry,mainCRTStartup) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") + # MSVC-style argument clang (clang-cl.exe) + handle_msvc_style_compiler() + elseif(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") + # GNU-style argument clang (clang.exe and clang++.exe) + target_link_options(${TARGET_NAME} PRIVATE -Wl,-subsystem:windows) + target_link_options(${TARGET_NAME} PRIVATE -Wl,-entry:mainCRTStartup) + endif() + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + handle_msvc_style_compiler() + + # Use updated __cplusplus macro + # https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus + target_compile_options(${TARGET_NAME} PUBLIC /Zc:__cplusplus) + endif() + endif() +endfunction() diff --git a/source/Level.cpp b/source/Level.cpp index ea3e9a9..5881084 100644 --- a/source/Level.cpp +++ b/source/Level.cpp @@ -68,7 +68,7 @@ Level* LevelManager::FindLevel(const Uid& uid) const { } #define BRUSSEL_DEF_LEVEL_NAME "New Level" -#define BRUSSEl_DEF_LEVEL_DESC "No description." +#define BRUSSEL_DEF_LEVEL_DESC "No description." Level* LevelManager::LoadLevel(const Uid& uid) { auto iter = mObjByUid.find(uid); @@ -95,7 +95,7 @@ Level* LevelManager::LoadLevel(const Uid& uid) { #if defined(BRUSSEL_DEV_ENV) BRUSSEL_JSON_GET_DEFAULT(root, "Name", std::string, ldObj.name, BRUSSEL_DEF_LEVEL_NAME); - BRUSSEL_JSON_GET_DEFAULT(root, "Description", std::string, ldObj.description, BRUSSEl_DEF_LEVEL_DESC) + BRUSSEL_JSON_GET_DEFAULT(root, "Description", std::string, ldObj.description, BRUSSEL_DEF_LEVEL_DESC) #endif auto rvEntries = rapidjson::GetProperty(root, rapidjson::kArrayType, "DataEntries"sv); @@ -127,7 +127,7 @@ LevelManager::LoadableObject& LevelManager::AddLevel(const Uid& uid) { auto& ldObj = iter->second; #if defined(BRUSSEL_DEV_ENV) ldObj.name = BRUSSEL_DEF_LEVEL_NAME; - ldObj.description = BRUSSEl_DEF_LEVEL_DESC; + ldObj.description = BRUSSEL_DEF_LEVEL_DESC; #endif return ldObj; } |