From 58f3bb3ce8c80818dcd40aa951d8c678a0a68644 Mon Sep 17 00:00:00 2001 From: PikachuHy Date: Tue, 8 Jun 2021 09:52:04 +0800 Subject: [PATCH] build: MSVC Compat --- CMakeLists.txt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c46c8cd..aab3d1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,11 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(QT Core Gui Quick QuickControls2 LinguistTools) find_package(Qt5 REQUIRED ${QT}) - +if (MSVC) + # fix warning C4819: The file contains a character that cannot be represented in the current code page (936). + # Save the file in Unicode format to prevent data loss + add_compile_options("/utf-8") +endif () set(SRCS main.cpp calcengine.cpp @@ -33,11 +37,15 @@ target_link_libraries(${PROJECT_NAME} Qt5::Quick Qt5::QuickControls2 ) +if (MSVC) + # do nothing +else() + file(GLOB TS_FILES translations/*.ts) + qt5_create_translation(QM_FILES ${TS_FILES}) + add_custom_target(translations DEPENDS ${QM_FILES} SOURCES ${TS_FILES}) + add_dependencies(${PROJECT_NAME} translations) +endif () -file(GLOB TS_FILES translations/*.ts) -qt5_create_translation(QM_FILES ${TS_FILES}) -add_custom_target(translations DEPENDS ${QM_FILES} SOURCES ${TS_FILES}) -add_dependencies(${PROJECT_NAME} translations) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION /usr/bin)