修复c++标准设置不正确,新增utfcpp库
This commit is contained in:
parent
4d9ccc73c0
commit
d596ae4c09
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -7,3 +7,6 @@
|
||||
[submodule "src/mirage_widget/third_party/tomlplusplus"]
|
||||
path = src/mirage_widget/third_party/tomlplusplus
|
||||
url = https://github.com/marzer/tomlplusplus.git
|
||||
[submodule "src/mirage_core/third_party/utfcpp"]
|
||||
path = src/mirage_core/third_party/utfcpp
|
||||
url = https://github.com/nemtrif/utfcpp.git
|
||||
|
@ -4,13 +4,18 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
project(mirage)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 26)
|
||||
# 指定需要的 C++ 标准
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
# 强制要求此标准,如果编译器不支持则配置时报错
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
# 可选:禁用编译器特定的扩展,使用纯粹的标准
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
if (MSVC)
|
||||
# MSVC编译器设置C++标准
|
||||
add_compile_options(/std:c++latest)
|
||||
# 设置utf-8编码
|
||||
add_compile_options(/utf-8)
|
||||
# 强制 MSVC 正确设置 __cplusplus 宏
|
||||
add_compile_options(/Zc:__cplusplus)
|
||||
endif ()
|
||||
if (WIN32)
|
||||
# 定义Windows版本宏
|
||||
|
@ -3,17 +3,23 @@
|
||||
#include "mirage.h"
|
||||
#include "window/mwindow.h"
|
||||
#include "font/font_system.h"
|
||||
#include "style/mirage_style.h"
|
||||
#include "widget/widget_new.h"
|
||||
#include "widget/compound_widget/mbutton.h"
|
||||
#include "widget/leaf_widget/mtext_block.h"
|
||||
#include "widget/panel_widget/mbox.h"
|
||||
|
||||
#include "utf8.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
mirage_app::get().init();
|
||||
|
||||
auto c1 = linear_color::from_string("#FF0000");
|
||||
auto c2 = linear_color::from_string("rgb(255, 0, 0)");
|
||||
auto c3 = linear_color::from_string("rgba(255, 0, 0, 255)");
|
||||
auto name = mirage_style::get().name();
|
||||
auto version = mirage_style::get().version();
|
||||
auto author = mirage_style::get().author();
|
||||
auto description = mirage_style::get().description();
|
||||
auto license = mirage_style::get().license();
|
||||
|
||||
|
||||
auto& manager = font_manager::instance();
|
||||
manager.add_font(L"C:/Users/46944/AppData/Local/Microsoft/Windows/Fonts/MapleMono-NF-CN-Regular.ttf");
|
||||
@ -22,7 +28,18 @@ int main(int argc, char* argv[]) {
|
||||
manager.add_font(L"C:/Windows/Fonts/seguiemj.ttf");
|
||||
|
||||
const auto& text_block = std::make_shared<mtext_block>();
|
||||
text_block->set_text(U"Hello, World! 你好,世界!\n换行测试1111,测试测试测试测试,测试测试😀🐵🙏 😃🐵🙏");
|
||||
std::stringstream ss;
|
||||
ss << "name: " << name << "\n";
|
||||
ss << "version: " << version << "\n";
|
||||
ss << "author: " << author << "\n";
|
||||
ss << "description: " << description << "\n";
|
||||
ss << "license: " << license << "\n";
|
||||
// text_block->set_text(U"Hello, World! 你好,世界!\n换行测试1111,测试测试测试测试,测试测试😀🐵🙏 😃🐵🙏");
|
||||
|
||||
const auto& utf32 = utf8::utf8to32(ss.str());
|
||||
|
||||
// const char*转换为std::u32string
|
||||
text_block->set_text(utf32);
|
||||
|
||||
const auto& text_block2 = std::make_shared<mtext_block>();
|
||||
text_block2->set_text(U"Hello, World!");
|
||||
|
@ -4,11 +4,13 @@ project(mirage_core LANGUAGES C CXX)
|
||||
|
||||
find_package(Eigen3 REQUIRED)
|
||||
|
||||
add_subdirectory(third_party/utfcpp)
|
||||
|
||||
set(SRC_FILES)
|
||||
retrieve_files(${CMAKE_CURRENT_SOURCE_DIR} SRC_FILES)
|
||||
retrieve_files(${CMAKE_CURRENT_SOURCE_DIR}/src SRC_FILES)
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC ${SRC_FILES})
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen mirage_image)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen mirage_image utf8cpp)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
add_os_definitions(${PROJECT_NAME})
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC -DNOMINMAX)
|
||||
|
1
src/mirage_core/third_party/utfcpp
vendored
Submodule
1
src/mirage_core/third_party/utfcpp
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 65701fe00700577f9f4e9b96d682bd7cfcc0b76e
|
Loading…
x
Reference in New Issue
Block a user