fix: fix linux build issue

This commit is contained in:
yyc12345 2024-08-27 20:48:27 +08:00
parent 85ff80cbf7
commit 8ef1c6e30a
8 changed files with 23 additions and 19 deletions

View File

@ -306,6 +306,8 @@ namespace BMap {
case LibCmo::CK2::CK_CLASSID::CKCID_TEXTURE:
m_ObjTextures.emplace_back(fileobj.CreatedObjectId);
break;
default:
break; // skip unknow objects
}
}

View File

@ -63,7 +63,7 @@ write_basic_package_version_file(
COMPATIBILITY SameMinorVersion
)
configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/LibCmoConfig.cmake.in
${CMAKE_CURRENT_LIST_DIR}/CMake/LibCmoConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/LibCmoConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LibCmo
)

View File

@ -230,7 +230,7 @@ namespace LibCmo::CK2 {
* @return True if it need to be notified, otherwise false.
* If the class id of checking is invalid, this function always return false.
*/
bool CKIsNeedNotify(CK_CLASSID listener, CK_CLASSID deletedObjCid); /**
bool CKIsNeedNotify(CK_CLASSID listener, CK_CLASSID deletedObjCid);
/**
* @brief Get all class ids need to be notified when objects whose class id included in \c delObjCids are deleting.
* @param[in] delObjCids The bit array representing class ids which need to be queried.

View File

@ -81,7 +81,7 @@ FILES
# X Container
XContainer/XTypes.hpp
)
# Setup include infomation
# Setup include and linked library infomation
target_include_directories(LibCmo
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>"
@ -90,16 +90,17 @@ PRIVATE
YYCC::YYCCommonplace
ZLIB::ZLIB
stb::stb-image
$<$<NOT:$<BOOL:${WIN32}>>:Iconv::Iconv>
)
# Setup linked library infomation
target_link_libraries(LibCmo
PRIVATE
YYCC::YYCCommonplace
ZLIB::ZLIB
stb::stb-image
$<$<NOT:$<BOOL:${WIN32}>>:Iconv::Iconv>
)
if (NOT WIN32)
target_include_directories(LibCmo PRIVATE Iconv::Iconv)
target_link_libraries(LibCmo PRIVATE Iconv::Iconv)
endif ()
# Setup C++ standard
set_target_properties(LibCmo
PROPERTIES

View File

@ -415,20 +415,21 @@ namespace LibCmo::EncodingHelper {
static const iconv_t c_InvalidIconvType = reinterpret_cast<iconv_t>(-1);
struct IconvEncodingToken {
IconvEncodingToken(const std::u8string_view& universal_code, const std::string_view& iconv_code) :
IconvEncodingToken(const std::u8string_view& universal_code, const std::string_view& _iconv_code) :
m_Name(universal_code),
m_FromUTF8(c_InvalidIconvType), m_ToUTF8(c_InvalidIconvType) {
// if iconv code is empty, do nothing
std::string iconv_code(_iconv_code);
if (iconv_code.empty()) return;
// setup iconv_t
this->m_FromUTF8 = iconv_open(code.c_str(), "UTF-8");
this->m_ToUTF8 = iconv_open("UTF-8", code.c_str());
this->m_FromUTF8 = iconv_open(iconv_code.c_str(), "UTF-8");
this->m_ToUTF8 = iconv_open("UTF-8", iconv_code.c_str());
}
~IconvEncodingToken() {
if (this->m_FromUTF8 != c_InvalidIconvType)
iconv_close(token_cast->m_FromUTF8);
iconv_close(this->m_FromUTF8);
if (this->m_ToUTF8 != c_InvalidIconvType)
iconv_close(token_cast->m_ToUTF8);
iconv_close(this->m_ToUTF8);
}
std::u8string m_Name;
@ -526,7 +527,7 @@ namespace LibCmo::EncodingHelper {
// check whether token has been initialized correctly
if (token->m_FromUTF8 == c_InvalidIconvType || token->m_ToUTF8 == c_InvalidIconvType) {
// failed. free resource and return
delete token_cast;
delete token;
return INVALID_ENCODING_TOKEN;
}
// okey, return
@ -588,7 +589,7 @@ namespace LibCmo::EncodingHelper {
return YYCC::EncodingHelper::UTF8ToChar(src, dst, token_cast->m_CodePage);
#else
IconvEncodingToken* token_cast = static_cast<IconvEncodingToken*>(token);
return DoIconv(token_cast->FromUTF8, YYCC::EncodingHelper::ToOrdinaryView(src), dst);
return DoIconv(token_cast->m_FromUTF8, YYCC::EncodingHelper::ToOrdinaryView(src), dst);
#endif
}
bool ToOrdinary(const char8_t* src, std::string& dst, EncodingToken token) {
@ -616,7 +617,7 @@ namespace LibCmo::EncodingHelper {
#else
IconvEncodingToken* token_cast = static_cast<IconvEncodingToken*>(token);
std::string dst_cache;
bool ret = DoIconv(token_cast->ToUTF8, src, dst_cache);
bool ret = DoIconv(token_cast->m_ToUTF8, src, dst_cache);
if (ret) dst = YYCC::EncodingHelper::ToUTF8(dst_cache);
return ret;
#endif

View File

@ -31,7 +31,7 @@ namespace LibCmo {
UnreachableException(const char* msg) : message(msg ? msg : "") {}
UnreachableException(const UnreachableException& rhs) : message(rhs.message) {}
virtual ~UnreachableException() {}
[[nodiscard]] virtual const char* what() const override { return message.c_str(); }
[[nodiscard]] virtual const char* what() const noexcept override { return message.c_str(); }
private:
std::string message;
};
@ -47,7 +47,7 @@ namespace LibCmo {
LogicException(const char* msg) : message(msg ? msg : "") {}
LogicException(const LogicException& rhs) : message(rhs.message) {}
virtual ~LogicException() {}
[[nodiscard]] virtual const char* what() const override { return message.c_str(); }
[[nodiscard]] virtual const char* what() const noexcept override { return message.c_str(); }
private:
std::string message;
};
@ -62,7 +62,7 @@ namespace LibCmo {
RuntimeException(const char* msg) : message(msg ? msg : "") {}
RuntimeException(const RuntimeException& rhs) : message(rhs.message) {}
virtual ~RuntimeException() {}
[[nodiscard]] virtual const char* what() const override { return message.c_str(); }
[[nodiscard]] virtual const char* what() const noexcept override { return message.c_str(); }
private:
std::string message;
};

View File

@ -389,7 +389,7 @@ namespace Unvirt::CmdHelper {
};
class RootNode : public AbstractNode {
friend class CommandParser;
friend class ::Unvirt::CmdHelper::CommandParser;
public:
RootNode();
virtual ~RootNode();

View File

@ -281,7 +281,7 @@ namespace Unvirt::Context {
YYCC::ConsoleHelper::EnableColorfulConsole();
// Show banner
YYCC::ConsoleHelper::WriteLine(YYCC_COLOR_LIGHT_YELLOW(u8"Unvirt 0.2.0") " build at " __DATE__ " " __TIME__);
YYCC::ConsoleHelper::WriteLine(YYCC_COLOR_LIGHT_YELLOW(u8"Unvirt 0.2.0") " built at " __DATE__ " " __TIME__);
YYCC::ConsoleHelper::WriteLine(u8"Type 'help' for more infomation. Type 'exit' to quit.");
// start process loop