Skip to content

Commit

Permalink
chore: Adapt Qt6 && Dtk6 compilation
Browse files Browse the repository at this point in the history
Since xdgiconloader is not adapted to Qt6, libxdg is disabled by default when compiling Dtk6
Do not install dconfig file in dtkgui to avoid conficts with dtk6gui
C++ 17 by default
DVERSION ==> DTK_VERSION
cmake_minimum_required 3.13
tools install to CMAKE_INSTALL_LIBEXECDIR
  • Loading branch information
kegechen committed Jun 19, 2023
1 parent b683e97 commit dcede1f
Show file tree
Hide file tree
Showing 26 changed files with 270 additions and 1,167 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ CMakeLists.txt.user*
#clangformat
.clang-format

# build
compile_commands.json

bin
DtkGuis
dtkgui_config.h
Expand Down
137 changes: 11 additions & 126 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,135 +1,20 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.13)

set(DVERSION "5.6.8" CACHE STRING "define project version")
set(DTK_VERSION "5.6.11" CACHE STRING "define project version")
project(DtkGui
VERSION ${DVERSION}
VERSION ${DTK_VERSION}
DESCRIPTION "DTK Gui module"
HOMEPAGE_URL "https://github.com/linuxdeepin/dtkgui"
LANGUAGES CXX C
)
set(LIB_NAME dtkgui)

# Set install path
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr)
endif ()

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Set build option
option(DTK_DISABLE_LIBXDG "Disable libxdg" OFF)
option(DTK_DISABLE_LIBRSVG "Disable librsvg" OFF)
option(DTK_DISABLE_EX_IMAGE_FORMAT "Disable libraw and freeimage" OFF)
set(BUILD_DOCS ON CACHE BOOL "Generate doxygen-based documentation")

set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/dtk${PROJECT_VERSION_MAJOR}/DGui")
set(TOOL_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/dtk${PROJECT_VERSION_MAJOR}/DGui/bin")
set(LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
set(MKSPECS_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/qt5/mkspecs/modules" CACHE STRING "Install dir for qt pri module files")
set(CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/DtkGui")
set(PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wextra -fopenmp")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(BUILD_TESTING ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -fno-omit-frame-pointer")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast")
endif ()

set(CONFIGNAME include/global/dtkgui_config.h)
file(WRITE ${CONFIGNAME}
"// This is an auto-generated header, please don't modify it.\n"
)
file(GLOB CONFIGSOURCE include/DtkGui/*)

foreach(FILENAME ${CONFIGSOURCE})
get_filename_component(thefile ${FILENAME} NAME)
file(APPEND ${CONFIGNAME} "#define DTKGUI_CLASS_${thefile}\n")
endforeach()

# Generate cmake config file
configure_package_config_file(misc/DtkGuiConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/DtkGuiConfig.cmake
INSTALL_DESTINATION "${CONFIG_INSTALL_DIR}"
PATH_VARS TOOL_INSTALL_DIR
)
# Generate cmake version file
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/DtkGuiConfigVersion.cmake"
VERSION ${DVERSION}
COMPATIBILITY SameMajorVersion
)
# Install cmake config file and version file to CONFIG_INSTALL_DIR
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/DtkGuiConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/DtkGuiConfigVersion.cmake
DESTINATION "${CONFIG_INSTALL_DIR}"
)
# Install pkgconfig file
configure_file(misc/dtkgui.pc.in dtkgui.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dtkgui.pc DESTINATION "${PKGCONFIG_INSTALL_DIR}")
# Install pri module
configure_file(misc/qt_lib_dtkgui.pri.in qt_lib_dtkgui.pri @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qt_lib_dtkgui.pri DESTINATION "${MKSPECS_INSTALL_DIR}")

set(GUISGNAME DtkGuis)

file(WRITE ${GUISGNAME}
"// This is an auto-generated header, please don't modify it.\n"
"#ifndef DTK_GUI_MODULE_H\n"
"#define DTK_GUI_MODULE_H\n"
)
file(GLOB FILEGRAGTOWRITSOURCE include/filedrag/*)

foreach(FILENAME ${FILEGRAGTOWRITSOURCE})
get_filename_component(thefile ${FILENAME} NAME)
file(APPEND ${GUISGNAME} "#include \"${thefile}\"\n")
endforeach()
file(GLOB KERNELTOWRITESOURCE include/kernel/*)
foreach(FILENAME ${KERNELTOWRITESOURCE})
get_filename_component(thefile ${FILENAME} NAME)
file(APPEND ${GUISGNAME} "#include \"${thefile}\"\n")
endforeach()
file(GLOB UTILTOWRITESOURCE include/util/*)
foreach(FILENAME ${UTILTOWRITESOURCE})
get_filename_component(thefile ${FILENAME} NAME)
file(APPEND ${GUISGNAME} "#include \"${thefile}\"\n")
endforeach()
file(APPEND ${GUISGNAME} "#endif")
install(FILES DtkGuis DESTINATION "${INCLUDE_INSTALL_DIR}")

# Find common dependencies
find_package(Qt5 REQUIRED COMPONENTS Gui DBus Network)
find_package(PkgConfig REQUIRED)
find_package(Dtk REQUIRED COMPONENTS Core)
pkg_check_modules(librsvg REQUIRED IMPORTED_TARGET librsvg-2.0)

# Check optional image handler dependencies.
find_package(FreeImage)
pkg_check_modules(libraw IMPORTED_TARGET libraw)
if(FreeImage_FOUND AND libraw_FOUND)
set(EX_IMAGE_FORMAT_LIBS_FOUND ON)
if("${PROJECT_VERSION_MAJOR}" STREQUAL "5")
set(QT_VERSION_MAJOR "5")
elseif("${PROJECT_VERSION_MAJOR}" STREQUAL "6")
set(QT_VERSION_MAJOR "6")
set(DTK_VERSION_MAJOR "6")
else()
message(SEND_ERROR "not support Prject Version ${PROJECT_VERSION}.")
endif()

add_subdirectory(src)
if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()
add_subdirectory(tools)
add_subdirectory(examples)

if (BUILD_DOCS)
add_subdirectory(docs)
endif ()

include(dtkgui.cmake)
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Standards-Version: 3.9.8

Package: libdtkgui5
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, libdtkcommon,
Depends: ${shlibs:Depends}, ${misc:Depends}, libdtkdata,
qt5-image-formats-plugins
Multi-Arch: same
Description: Deepin Tool Kit Gui library
Expand Down
2 changes: 1 addition & 1 deletion debian/libdtkgui5-bin.install
Original file line number Diff line number Diff line change
@@ -1 +1 @@
usr/lib/*/*/DGui/bin/*
usr/*/*/DGui/bin/*
2 changes: 1 addition & 1 deletion debian/libdtkgui5.install
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
usr/lib/*/lib*.so.*
usr/share/dsg/*/*
#usr/share/dsg/*/*
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ endif
dh $@

override_dh_auto_configure:
dh_auto_configure -- -DBUILD_TESTING=OFF -DBUILD_DOCS=ON -DDVERSION=$(_PACK_VER)
dh_auto_configure -- -DBUILD_TESTING=OFF -DBUILD_DOCS=ON -DDTK_VERSION=$(_PACK_VER)
#override_dh_auto_test:
# echo "skip auto test"

Expand Down
Loading

0 comments on commit dcede1f

Please sign in to comment.