Skip to content

Commit

Permalink
chroe: update CMakeLists
Browse files Browse the repository at this point in the history
  • Loading branch information
XMuli committed Nov 2, 2023
1 parent 44c89c9 commit efbb6a5
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 112 deletions.
95 changes: 50 additions & 45 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set(project_name FLIPPED)
set(project_version_major 1)
set(project_version_minor 3)
set(project_version_minor 5)
set(project_version_path 0)
set(project_version ${project_version_major}.${project_version_minor}.${project_version_path})
project(${project_name} VERSION ${project_version} LANGUAGES CXX)
Expand All @@ -21,7 +21,7 @@ set(_VERSION ${VERSION})

# 作为宏传递给 C++ 代码
add_definitions(-DMY_PROJECT_NAME="${project_name}")
add_definitions(-DMY_BUILD_TIME="2023-08-08")
add_definitions(-DMY_BUILD_TIME="2023-11-02")
add_definitions(-DMY_VARIABLE="${project_version}")
add_compile_definitions(MY_DEBUG_DETAIL) # 屏蔽则关闭详细调试日志信息
#add_compile_definitions(MY_SHIELD_CONFIG_JSON) # 屏蔽配置文件读写 json
Expand Down Expand Up @@ -152,62 +152,72 @@ file(GLOB_RECURSE source_lists LIST_DIRECTORIES false
source_group(TREE ${src_root_path} FILES ${source_lists}) # will be organized according to the actual directory structure, .h.cpp is put together
include_directories(${PROJECT_SOURCE_DIR}/widgets) # 修复 Qt Design 使用提升自定义控件后, MinGW 找不到而编译失败

#***************************************************通用参数的定义 开始**********************************************
# get kit architecture bit
#********************************************** 判断且定义 x64/x86 变量 (get kit architecture bit) ****************************
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(architecture_bit "x86")
set(build_x64bit false)
set(arch_bit "86")
set(is_x64bit false)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(architecture_bit "x64")
set(build_x64bit true)
set(arch_bit "64")
set(is_x64bit true)
endif()

# 设置变量 qt/ssl/lupdate/lrelease 在不同编译器下的环境和版本下的 path
# env_qt_version_dir/env_qt_dir/lupdate_path/lrelease_path; [exe_dir] <-> EXECUTABLE_OUTPUT_PATH | CMAKE_BINARY_DIR
if(WIN32)
set(env_qt_version_dir "C:/Qt/${QT_VERSION}")
if(${build_x64bit})
set(env_os "Windows(kits 64bit)")
if(MSVC)
set(env_qt_dir "${env_qt_version_dir}/msvc2019_64")
elseif(MINGW)
set(env_qt_dir "${env_qt_version_dir}/mingw81_64")
endif()
# 定义一些 qt bin 的基础变量

set(qt_binray_dir "${Qt5_DIR}/../../../bin") # C:/Qt/5.15.2/msvc2019_64/lib/cmake/Qt5/../../../bin

if(UNIX) # using apt install qt5-devtools*
execute_process(COMMAND lsb_release -i OUTPUT_VARIABLE LSB_ID)
if (LSB_ID MATCHES "Deepin" OR LSB_ID MATCHES "UOS")
set(lupdate_path "/usr/lib/qt5/bin/lupdate")
set(lrelease_path "/usr/lib/qt5/bin/lrelease")
message("This is a Deepin or UOS system.")
else()
set(env_os "Windows(kits 86bit)")
if(MSVC)
set(env_qt_dir "${env_qt_version_dir}/msvc2019")
elseif(MINGW)
set(env_qt_dir "${env_qt_version_dir}/mingw81_32")
endif()
set(lupdate_path "lupdate")
set(lrelease_path "lrelease")
message("This is other linux system.")
endif()

execute_process(COMMAND cmd.exe "/C" "echo %USERPROFILE%" OUTPUT_VARIABLE HOME_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
set(lupdate_path "${qt_binray_dir}/lupdate")
set(lrelease_path "${qt_binray_dir}/lrelease")

if(APPLE)
set(env_os "MacOS")
set(env_qt_version_dir "${HOME_DIR}/Qt/${QT_VERSION}")
execute_process(COMMAND bash "-c" "echo $HOME" OUTPUT_VARIABLE HOME_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
set(env_qt_dir "${env_qt_version_dir}/clang_64")
if(WIN32)
set(windeployqt "${qt_binray_dir}/windeployqt.exe")
elseif(APPLE)
set(windeployqt "${qt_binray_dir}/macdeployqt")
elseif(UNIX)
set(env_os "Unix/Linux")

set(env_qt_version_dir "opt/Qt/${QT_VERSION}") # ununtu 22.04
execute_process(COMMAND bash "-c" "echo $HOME" OUTPUT_VARIABLE HOME_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
set(env_qt_dir "${env_qt_version_dir}/gcc_64")
# custom deployqt
endif()
endif()

message("Qt5_DIR:" ${Qt5_DIR})
message("qt_binray_dir:" ${qt_binray_dir})
message("windeployqt:" ${windeployqt})
message("lupdate_path:" ${lupdate_path})
message("lrelease_path:" ${lrelease_path})
message("EXECUTABLE_OUTPUT_PATH:" ${EXECUTABLE_OUTPUT_PATH})
message("CMAKE_BINARY_DIR:" ${CMAKE_BINARY_DIR})
message("CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
message("CMAKE_RUNTIME_OUTPUT_DIRECTORY: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
message("CMAKE_RUNTIME_OUTPUT_DIRECTORY: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") # exe 和 dll 运行的输出路径
message("CMAKE_LIBRARY_OUTPUT_DIRECTORY: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") # 动态链接库(DLL、SO 等)的输出目录(实际不生效)
message("CMAKE_ARCHIVE_OUTPUT_DIRECTORY: ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}") # 静态库的输出目录

#***************************************************通用参数的定义 开始**********************************************
# get kit architecture bit
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(architecture_bit "x86")
set(build_x64bit false)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(architecture_bit "x64")
set(build_x64bit true)
endif()

if(APPLE)
set(exe_dir ${EXECUTABLE_OUTPUT_PATH}/${project_name}.app/Contents/MacOS)
else()
set(exe_dir ${EXECUTABLE_OUTPUT_PATH})
endif()

set(lupdate_path "${env_qt_dir}/bin/lupdate")
set(lrelease_path "${env_qt_dir}/bin/lrelease")

message("--->architecture_bit:" ${architecture_bit} " build_x64bit:" ${build_x64bit} " ssl_dir:" ${ssl_dir} " HOME_DIR:" ${HOME_DIR} " env_os:" ${env_os})
message("lupdate_path:" ${lupdate_path})
message("lrelease_path:" ${lrelease_path})
Expand Down Expand Up @@ -345,7 +355,6 @@ target_compile_definitions(${PROJECT_NAME} PUBLIC _PROJECT_VERSION="${PROJECT_VE
target_compile_definitions(${PROJECT_NAME} PUBLIC _BIT_ARCH=${CMAKE_SIZEOF_VOID_P}) # 4/8
target_compile_definitions(${PROJECT_NAME} PUBLIC _COMPILER=${CMAKE_HOST_SYSTEM_PROCESSOR}) # i386/i686/x86_64/unknown Win: AMD64
target_compile_definitions(${PROJECT_NAME} PUBLIC _COMPILER_ID="${CMAKE_CXX_COMPILER_ID}") # Clang/GCC/MSVC
target_compile_definitions(${PROJECT_NAME} PUBLIC _VERSION_BUILD_TIME="2023.08.13")
# build time about version

message("------------BRGIN------------")
Expand Down Expand Up @@ -376,7 +385,6 @@ endif()


if(APPLE)
set(windeployqt "${env_qt_dir}/bin/macdeployqt")
add_custom_command(TARGET ${project_name} POST_BUILD
COMMAND "${windeployqt} ${EXECUTABLE_OUTPUT_PATH}/${project_name}.app" -verbose=1
)
Expand All @@ -388,14 +396,11 @@ if(APPLE)
elseif(UNIX)

elseif(WIN32)
set(windeployqt "${env_qt_dir}/bin/windeployqt.exe")
add_custom_command(TARGET ${project_name} POST_BUILD
COMMAND "${windeployqt}" "${EXECUTABLE_OUTPUT_PATH}/${project_name}.exe" --no-translations
)
endif()


message("copy depend COMPILER_ID[${CMAKE_CXX_COMPILER_ID}] ${env_os}: ssl/qt")
message("--->windeployqt(or mac/linux): ${windeployqt}")

# 添加一个自定义的目标,将编译和自定义打包命令关联起来
Expand Down
4 changes: 2 additions & 2 deletions src/preference/hotkeyswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ HotkeysWidget::HotkeysWidget(QWidget *parent) : QWidget(parent)
grid->setColumnStretch(1, 9);

QStringList list = { DATAMAID->paraValue(thScrnCapture).toString()
,DATAMAID->paraValue(thDelayCapture).toString()
,DATAMAID->paraValue(thFullScreen).toString()};
,DATAMAID->paraValue(thFullScreen).toString()
,DATAMAID->paraValue(thDelayCapture).toString()};
std::map<XKeySequenceEdit*, const QString> vHkEdit;
int idx = 0;
for (auto& it : Tray::instance().getVHotKeys()) {
Expand Down
4 changes: 2 additions & 2 deletions src/preference/prefmanage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void PrefManage::initUIAbout()
.arg(_PROJECT_VERSION)
.arg(_COMPILER_ID)
.arg(bit)
.arg(_VERSION_BUILD_TIME));
.arg(MY_BUILD_TIME));

}

Expand Down Expand Up @@ -425,7 +425,7 @@ void PrefManage::on_cbLanuage_currentTextChanged(const QString &language)
ui->labVersion->setText(QString("%1-Beta %2 (%3)")
.arg(_PROJECT_VERSION)
.arg(bit)
.arg(_VERSION_BUILD_TIME));
.arg(MY_BUILD_TIME));
}


Expand Down
16 changes: 3 additions & 13 deletions src/preference/prefmanage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>508</width>
<height>342</height>
<width>609</width>
<height>344</height>
</rect>
</property>
<property name="minimumSize">
Expand Down Expand Up @@ -1271,7 +1271,7 @@
<property name="title">
<string>About</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_13" stretch="1,1,1,1">
<layout class="QHBoxLayout" name="horizontalLayout_13" stretch="1,1,1">
<item>
<widget class="QLabel" name="labGitHub">
<property name="text">
Expand Down Expand Up @@ -1301,16 +1301,6 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_22">
<property name="text">
<string>UI: iCancely</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_20">
<property name="text">
Expand Down
4 changes: 2 additions & 2 deletions src/screen/tray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ void Tray::initGlobalHotKeys()
m_vHotKeys = {
std::make_tuple(nullptr, DATAMAID->paraValue(thScrnCapture).toString(), tr("Scrn Capture"), CaptureHelper::SST_ScrnCapture),
//std::make_tuple(nullptr, "", tr("Scrolling Window"), ScrnShotType::SST_ScrollingWindow),
std::make_tuple(nullptr, DATAMAID->paraValue(thDelayCapture).toString(), tr("Delay Capture"), CaptureHelper::SST_DelayCapture),
std::make_tuple(nullptr, DATAMAID->paraValue(thFullScreen).toString(), tr("Full Screen"), CaptureHelper::SST_FullScrnCapture),
std::make_tuple(nullptr, DATAMAID->paraValue(thDelayCapture).toString(), tr("Delay Capture"), CaptureHelper::SST_DelayCapture)
// std::make_tuple(nullptr, "", tr("Fixd-Size Region"), ScrnShotType::SST_FixdSizeRegion),
// std::make_tuple(nullptr, "", tr("Paste"), ScrnShotType::SST_Paste),
// std::make_tuple(nullptr, "", tr("Hide/Show all images"), ScrnShotType::SST_HideShowAllImages),
Expand Down Expand Up @@ -170,7 +170,7 @@ void Tray::onPreference(bool checked)
if (!m_prefManage) m_prefManage = new PrefManage();

m_prefManage->show();
m_prefManage->resize(680, 360);
m_prefManage->resize(800, 450);
}

void Tray::onKeySequenceChanged(const QKeySequence& keySequence)
Expand Down
27 changes: 11 additions & 16 deletions src/translations/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<context>
<name>ColorParaBar</name>
<message>
<location filename="../tool/base/colorparabar.cpp" line="162"/>
<location filename="../tool/base/colorparabar.cpp" line="164"/>
<source>select color</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -460,11 +460,6 @@
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Copyright © 2022-2023 &lt;a href=&quot;https://github.com/XMuli&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#008000;&quot;&gt;XMuli&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../preference/prefmanage.ui"/>
<source>UI: iCancely</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../preference/prefmanage.ui"/>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;QQ Group: &lt;a href=&quot;https://qm.qq.com/cgi-bin/qm/qr?k=jsD03QzMohGZm0TqYAFh3BvKOpCGlTcT&amp;amp;jump_from=webapi&amp;amp;authKey=DMUwiCQ6ta95PoH8JmtZ+Jz9y7Ozg3yinEsxmm92rNXZRVeMPD7NRgjU+dmUI8Xu&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#008000;&quot;&gt;418103279&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
Expand Down Expand Up @@ -607,52 +602,52 @@ Allowed to run only one instance of the application.</source>
<context>
<name>Tray</name>
<message>
<location filename="../screen/tray.cpp" line="90"/>
<location filename="../screen/tray.cpp" line="77"/>
<source>ScreenShot</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../screen/tray.cpp" line="91"/>
<location filename="../screen/tray.cpp" line="78"/>
<source>Preference</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../screen/tray.cpp" line="92"/>
<location filename="../screen/tray.cpp" line="79"/>
<source>Quit</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../screen/tray.cpp" line="121"/>
<location filename="../screen/tray.cpp" line="108"/>
<source>Scrn Capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../screen/tray.cpp" line="123"/>
<location filename="../screen/tray.cpp" line="110"/>
<source>Delay Capture</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../screen/tray.cpp" line="124"/>
<location filename="../screen/tray.cpp" line="111"/>
<source>Full Screen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../screen/tray.cpp" line="239"/>
<location filename="../screen/tray.cpp" line="219"/>
<source>Success</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../screen/tray.cpp" line="239"/>
<location filename="../screen/tray.cpp" line="219"/>
<source>Fail</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../screen/tray.cpp" line="240"/>
<location filename="../screen/tray.cpp" line="220"/>
<source>Image saved to %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../screen/tray.cpp" line="249"/>
<location filename="../screen/tray.cpp" line="229"/>
<source>Fail ShotKeys</source>
<translation type="unfinished"></translation>
</message>
Expand Down
Loading

0 comments on commit efbb6a5

Please sign in to comment.