Skip to content

Commit

Permalink
fix: the checking version of dtkwidget does not work on other distrib…
Browse files Browse the repository at this point in the history
…ution

Log: The version of dtkwidget can be checked on other distributions
  • Loading branch information
hillwoodroc committed Nov 5, 2024
1 parent b7fe661 commit dff3bba
Showing 1 changed file with 44 additions and 7 deletions.
51 changes: 44 additions & 7 deletions libimageviewer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,54 @@
#定义需要的cmake版本
# Define the required cmake version
cmake_minimum_required(VERSION 3.10)

# 设置工程名字
# Set project name
project(libimageviewer VERSION 0.1.0)

# 检查dtkwidget版本
execute_process(COMMAND dpkg -s libdtkwidget-dev
COMMAND grep Version
TIMEOUT 5
OUTPUT_VARIABLE DWIDGET_VERSION_STR)
# Check distribution
find_program(LSB_RELEASE lsb_release)

if(EXISTS "/etc/os-release")
message(STATUS "The file /etc/os-release exists.")
else()
message(FATAL_ERROR "The file /etc/os-release does not exist.")
endif()

execute_process(
COMMAND lsb_release -i
OUTPUT_VARIABLE LSB_RELEASE_ID
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if (LSB_RELEASE_ID MATCHES "Deepin" OR
LSB_RELEASE_ID MATCHES "UOS" OR
LSB_RELEASE_ID MATCHES "Debian" OR
LSB_RELEASE_ID MATCHES "Ubuntu")
execute_process(COMMAND dpkg -s libdtkwidget-dev
COMMAND grep Version
TIMEOUT 5
OUTPUT_VARIABLE DWIDGET_VERSION_STR)
elseif (LSB_RELEASE_ID MATCHES "openSUSE" OR
LSB_RELEASE_ID MATCHES "SUSE" OR
LSB_RELEASE_ID MATCHES "Fedora" OR
LSB_RELEASE_ID MATCHES "Redhat" OR
LSB_RELEASE_ID MATCHES "Centos" OR
LSB_RELEASE_ID MATCHES "openEuler")
execute_process(COMMAND rpm -qi dtkwidget-devel
COMMAND grep Version
TIMEOUT 5
OUTPUT_VARIABLE DWIDGET_VERSION_STR)
elseif (LSB_RELEASE_ID MATCHES "Arch")
execute_process(COMMAND pacman -Qi dtkwidget
COMMAND grep Version
TIMEOUT 5
OUTPUT_VARIABLE DWIDGET_VERSION_STR)
else()
message(FATAL_ERROR "Unsupport your distribution. Please add your distribution. Exiting.")
endif()
string(REPLACE "Version: " "" DWIDGET_VERSION_STR ${DWIDGET_VERSION_STR})
message(STATUS "BUILD DTKWidget VERSION ${DWIDGET_VERSION_STR}")

# Check dtkwidget version
if (${DWIDGET_VERSION_STR} VERSION_LESS "5.6.9-1")
message(STATUS "Use specific dtk watermakr, Version < 5.6.9-1")
add_definitions(-DUSE_SPECIFIC_DTK_WATERMARK)
Expand Down

0 comments on commit dff3bba

Please sign in to comment.