Skip to content

Commit

Permalink
修复远程编译时版本号传递到cmake宏的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
cngege committed Dec 5, 2024
1 parent 1f7d7db commit 34cf304
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ endif()
#不要放在 if(MSVC) 中
add_compile_options(/utf-8)

if(DEFINED FILE_VERSION)
add_definitions(-DFILEVERSION="${FILE_VERSION}")
#add_definitions(-DFILEVERSION="v1.0.2")
else()
add_definitions(-DFILEVERSION="0.0.0-Dev.0")
endif()

project ("GitHubDesktop2Chinese")

include(FetchContent)
Expand Down
13 changes: 5 additions & 8 deletions GitHubDesktop2Chinese.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
#define NO_REPLACE 0
#endif // _DEBUG

#ifndef FILE_VERSION
#define FILE_VERSION "v0.0.0-Dev.0"
#endif // !FILE_VERSION



std::Version FileVer{0,0,0};


Expand Down Expand Up @@ -148,15 +142,15 @@ int main(int argc, char* argv[])

CLI11_PARSE(app, argc, argv);
}
FileVer = std::Version(FILE_VERSION);
FileVer = std::Version(FILEVERSION);

// 开发者声明
spdlog::info("开发者:CNGEGE > 2024/04/13");
if(FileVer) {
spdlog::info("版本: {}", FileVer.toString(true));
}
else {
spdlog::warn("程序版本解析失败... at {}", FILE_VERSION);
spdlog::warn("程序版本解析失败... at {}", FILEVERSION);
}

if (GetKeyState(VK_SHIFT) & 0x8000 || _debug_goto_devoptions) {
Expand Down Expand Up @@ -208,6 +202,9 @@ int main(int argc, char* argv[])
std::string downlink = infojson["assets"][0]["browser_download_url"].get<std::string>();
spdlog::info("点击链接下载: {}", downlink);
}
else {
spdlog::info("当前版本已经是最新版..");
}
}
PAUSE;
}
Expand Down

0 comments on commit 34cf304

Please sign in to comment.