summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVittorio Romeo <vittorio.romeo@outlook.com>2021-11-04 20:52:35 +0000
committerVittorio Romeo <vittorio.romeo@outlook.com>2021-11-04 20:52:35 +0000
commitd098090f03d45e875f6aad64f0d646c167de7380 (patch)
treefe2dc782eb8a006419121b9406ee8f29ca3431f2
parente80300c8ed030b0b7914014b255e9fada9d996b9 (diff)
Hide console and set window icon on WIN32 Releae
-rw-r--r--CMakeLists.txt35
-rw-r--r--src/SSVOpenHexagon/Core/main.cpp17
2 files changed, 40 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2531d551..148d9f08 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -287,6 +287,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS true)
# Flags and extlibs
# -----------------------------------------------------------------------------
+string(TOLOWER "${CMAKE_BUILD_TYPE}" vrm_cmake_build_type_lower)
vrm_cmake_include_vc_dependency_once(vc_detection)
# TODO: decide how to handle flags
@@ -298,17 +299,17 @@ vrm_cmake_include_vc_dependency_once(vc_detection)
# LTO
# -----------------------------------------------------------------------------
-include(CheckIPOSupported)
-check_ipo_supported(RESULT result)
-
-if(result)
- if("${vrm_cmake_build_type_lower}" STREQUAL "release")
- message(STATUS "Enabling LTO")
- set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
- endif()
-else()
- message(STATUS "LTO not supported")
-endif()
+# include(CheckIPOSupported)
+# check_ipo_supported(RESULT result)
+#
+# if(result)
+# if("${vrm_cmake_build_type_lower}" STREQUAL "release")
+# message(STATUS "Enabling LTO")
+# set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
+# endif()
+# else()
+# message(STATUS "LTO not supported")
+# endif()
#
#
@@ -318,7 +319,12 @@ endif()
add_library(SSVOpenHexagonLibC STATIC ${C_SRC_LIST})
add_library(SSVOpenHexagonLib STATIC ${SRC_LIST})
-add_executable(SSVOpenHexagon ${MAIN_FILE})
+
+if(WIN32 AND "${vrm_cmake_build_type_lower}" STREQUAL "release")
+ add_executable(SSVOpenHexagon WIN32 ${MAIN_FILE})
+else()
+ add_executable(SSVOpenHexagon ${MAIN_FILE})
+endif()
#
#
@@ -399,6 +405,11 @@ ssvoh_find_extlib_for_target(SSVOpenHexagonLib SSVStart)
target_link_libraries(SSVOpenHexagon SSVOpenHexagonLib SSVOpenHexagonLibC)
+if(WIN32 AND "${vrm_cmake_build_type_lower}" STREQUAL "release")
+ target_link_libraries(SSVOpenHexagon "C:/OHWorkspace/SSVOpenHexagon/art/icon.res" sfml-main)
+ target_compile_options(SSVOpenHexagon PRIVATE "-Wl,-subsystem,windows")
+endif()
+
target_include_directories(
SSVOpenHexagon SYSTEM PUBLIC ${SFML_SOURCE_DIR}/include
PUBLIC ${PUBLIC_INCLUDE_DIRS}
diff --git a/src/SSVOpenHexagon/Core/main.cpp b/src/SSVOpenHexagon/Core/main.cpp
index 64096430..fbcc6a86 100644
--- a/src/SSVOpenHexagon/Core/main.cpp
+++ b/src/SSVOpenHexagon/Core/main.cpp
@@ -297,6 +297,23 @@ getFirstCompressedReplayFilenameFromArgs(const std::vector<std::string>& args)
window->setFPSLimited(hg::Config::getLimitFPS());
window->setMaxFPS(hg::Config::getMaxFPS());
+ {
+ const auto resetIcon = [&window]
+ {
+ sf::Image icon;
+ if(!icon.loadFromFile("Assets/icon.png"))
+ {
+ ssvu::lo("::main") << "Failed to load icon image\n";
+ }
+
+ window->getRenderWindow().setIcon(
+ icon.getSize().x, icon.getSize().y, icon.getPixelsPtr());
+ };
+
+ window->onRecreation += resetIcon;
+ resetIcon();
+ }
+
// 240 ticks per second.
window->setTimer<ssvs::TimerStatic>(
hg::Config::TIME_STEP, hg::Config::TIME_SLICE);