forked from linuxdeepin/dtkwidget
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(cmake): improve cmake and add new feature
* remove redundant "dtkwidget" in include directory; * improve cmake, modify some variable names, use file() to collect source files for scalability; * add full target_link_libraries support. Log: add full target_link_libraries support Influence: all projects who include headers directly by path
- Loading branch information
Showing
637 changed files
with
559 additions
and
726 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,156 @@ | ||
cmake_minimum_required (VERSION 3.10) | ||
|
||
set (DVERSION "5.6.2" CACHE STRING "define project version") | ||
project (DtkWidget | ||
VERSION ${DVERSION} | ||
DESCRIPTION "DTK Widget module" | ||
HOMEPAGE_URL "https://github.com/linuxdeepin/dtkwidget" | ||
LANGUAGES CXX C | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
set(VERSION | ||
"5.6.4" | ||
CACHE STRING "define project version" | ||
) | ||
|
||
project(DtkWidget | ||
VERSION ${VERSION} | ||
DESCRIPTION "DTK Widget module" | ||
HOMEPAGE_URL "https://github.com/linuxdeepin/dtkwidget" | ||
LANGUAGES CXX C | ||
) | ||
#set(BREAKVERSION "5") | ||
|
||
set(LIB_NAME dtkwidget) | ||
|
||
include(GNUInstallDirs) | ||
include(CMakePackageConfigHelpers) | ||
|
||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
set(CMAKE_AUTOMOC ON) | ||
set(CMAKE_AUTORCC ON) | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
if(UNIX AND NOT APPLE) | ||
set(LINUX TRUE) | ||
endif() | ||
|
||
# Set build option | ||
set (BUILD_PLUGINS ON CACHE BOOL "BUILD PLUGIN EXAMPLES") | ||
set(BUILD_PLUGINS | ||
ON | ||
CACHE BOOL "Build plugin and plugin example" | ||
) | ||
|
||
# Set install path | ||
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | ||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | ||
set(CMAKE_INSTALL_PREFIX /usr) | ||
endif () | ||
set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}/libdtk-${CMAKE_PROJECT_VERSION}/DWidget") | ||
set (TOOL_INSTALL_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/libdtk-${CMAKE_PROJECT_VERSION}/DWidget/bin") | ||
set (LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_FULL_LIBDIR}") | ||
set (MKSPECS_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/qt5/mkspecs/modules" CACHE STRING "INSTALL DIR FOR qt pri files") | ||
endif() | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE Release) | ||
endif() | ||
|
||
set(INCLUDE_INSTALL_DIR | ||
"${CMAKE_INSTALL_INCLUDEDIR}/dtk${PROJECT_VERSION_MAJOR}/DWidget" | ||
) | ||
set(TOOL_INSTALL_DIR | ||
"${CMAKE_INSTALL_LIBDIR}/dtk${PROJECT_VERSION_MAJOR}/DWidget/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 files" | ||
) | ||
set(CONFIG_INSTALL_DIR | ||
"${CMAKE_INSTALL_LIBDIR}/cmake/DtkWidget" | ||
CACHE STRING "Install directory for cmake files" | ||
) | ||
set(PKGCONFIG_INSTALL_DIR | ||
"${CMAKE_INSTALL_LIBDIR}/pkgconfig" | ||
CACHE STRING "Install directory for pkgconfig files" | ||
) | ||
|
||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wextra") | ||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed") | ||
if (CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
set(BUILD_TESTING ON) | ||
else () | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast") | ||
endif () | ||
if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
set(BUILD_TESTING ON) | ||
else() | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast") | ||
endif() | ||
# find_package | ||
find_package(Dtk REQUIRED COMPONENTS Core Gui) | ||
find_package(QT NAMES Qt5 REQUIRED COMPONENTS Core) | ||
find_package(Qt5 REQUIRED COMPONENTS | ||
Core | ||
Network | ||
Concurrent | ||
Widgets | ||
PrintSupport | ||
LinguistTools | ||
X11Extras | ||
DBus | ||
) | ||
find_package(PkgConfig REQUIRED) | ||
|
||
file(GLOB D_HEADERS "${PROJECT_SOURCE_DIR}/include/DWidget/*") | ||
|
||
add_subdirectory(src) | ||
set(AUTOCONFIG ${CMAKE_CURRENT_BINARY_DIR}/dtkwidget_config.h) | ||
get_filename_component(CONFIG_INCLUDE ${AUTOCONFIG} DIRECTORY) | ||
set(CONFIG_CONTENT) | ||
string(APPEND CONFIG_CONTENT "// This is an auto-generated config\n") | ||
|
||
foreach(header ${D_HEADERS}) | ||
get_filename_component(thename ${header} NAME) | ||
string(APPEND CONFIG_CONTENT "#define DTKWIDGET_CLASS_${thename}\n") | ||
endforeach() | ||
|
||
file(WRITE ${AUTOCONFIG} ${CONFIG_CONTENT}) | ||
|
||
file(GLOB_RECURSE PUBLIC_HEADERS "${PROJECT_SOURCE_DIR}/include/*.h") | ||
list(APPEND PUBLIC_HEADERS ${D_HEADERS} ${AUTOCONFIG}) | ||
|
||
add_subdirectory(src) | ||
add_subdirectory(examples) | ||
add_subdirectory(tools) | ||
|
||
if(BUILD_TESTING) | ||
message("==================================") | ||
message(" Now Testing is enabled ") | ||
message("==================================") | ||
enable_testing() | ||
add_subdirectory(tests) | ||
message("==================================") | ||
message(" Now Testing is enabled ") | ||
message("==================================") | ||
enable_testing() | ||
add_subdirectory(tests) | ||
endif() | ||
|
||
if(BUILD_PLUGINS) | ||
message("===================================") | ||
message(" You can build and run plugins now ") | ||
message("===================================") | ||
add_subdirectory(plugin) | ||
message("===================================") | ||
message(" You can build and run plugins now ") | ||
message("===================================") | ||
add_subdirectory(plugin) | ||
endif() | ||
find_package (Qt5 CONFIG REQUIRED COMPONENTS DBus Xml) | ||
|
||
set (BUILD_DOCS ON CACHE BOOL "Generate doxygen-based documentation") | ||
set(BUILD_DOCS | ||
ON | ||
CACHE BOOL "Generate doxygen-based documentation" | ||
) | ||
|
||
if (BUILD_DOCS) | ||
add_subdirectory(docs) | ||
endif () | ||
if(BUILD_DOCS) | ||
add_subdirectory(docs) | ||
endif() | ||
|
||
configure_package_config_file(misc/DtkWidgetConfig.cmake.in | ||
configure_package_config_file( | ||
misc/DtkWidgetConfig.cmake.in | ||
${CMAKE_CURRENT_BINARY_DIR}/DtkWidgetConfig.cmake | ||
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/DtkWidget" | ||
PATH_VARS INCLUDE_INSTALL_DIR LIBRARY_INSTALL_DIR TOOL_INSTALL_DIR | ||
INSTALL_DESTINATION ${CONFIG_INSTALL_DIR} | ||
PATH_VARS TOOL_INSTALL_DIR | ||
) | ||
|
||
write_basic_package_version_file( | ||
"${CMAKE_CURRENT_BINARY_DIR}/DtkWidgetConfigVersion.cmake" | ||
VERSION ${DVERSION} | ||
${CMAKE_CURRENT_BINARY_DIR}/DtkWidgetConfigVersion.cmake | ||
VERSION ${VERSION} | ||
COMPATIBILITY SameMajorVersion | ||
) | ||
install(FILES | ||
${CMAKE_CURRENT_BINARY_DIR}/DtkWidgetConfig.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/DtkWidgetConfigVersion.cmake | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/DtkWidget" | ||
DESTINATION ${CONFIG_INSTALL_DIR} | ||
) | ||
|
||
configure_file(misc/dtkwidget.pc.in dtkwidget.pc @ONLY) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dtkwidget.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dtkwidget.pc DESTINATION ${PKGCONFIG_INSTALL_DIR}) | ||
|
||
configure_file(misc/qt_lib_dtkwidget.pri.in qt_lib_dtkwidget.pri @ONLY) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qt_lib_dtkwidget.pri DESTINATION "${MKSPECS_INSTALL_DIR}") | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qt_lib_dtkwidget.pri DESTINATION ${MKSPECS_INSTALL_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ Source: dtkwidget | |
Section: libdevel | ||
Priority: optional | ||
Maintainer: Deepin Packages Builder <[email protected]> | ||
Build-Depends: debhelper (>= 9), pkg-config, libudev-dev, | ||
Build-Depends: debhelper-compat (= 12), pkg-config, libudev-dev, | ||
libqt5x11extras5-dev, libxext-dev, qttools5-dev-tools, qttools5-dev, | ||
x11proto-xext-dev, libxcb-util0-dev, libstartup-notification0-dev, | ||
libmtdev-dev, qtbase5-private-dev, libegl1-mesa-dev, libudev-dev, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
usr/lib/*/*/*/examples/* | ||
usr/share/dsg/configs/overrides/dtk-example/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
usr/lib/*/lib*.so.* | ||
usr/share/*/*/translations/* | ||
usr/share/dsg/configs/org.deepin.dtkwidget.feature-display.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
usr/lib/*/lib*.so.* | ||
#usr/lib/*/libmsc.so | ||
usr/share/*/*/translations/* | ||
usr/share/dsg/configs/org.deepin.dtkwidget.feature-display.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
usr/lib/*/lib*.so.* | ||
#usr/lib/*/libmsc.so | ||
usr/share/*/*/translations/* | ||
usr/share/dsg/configs/org.deepin.dtkwidget.feature-display.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
add_subdirectory(dwidget-examples/collections) | ||
add_subdirectory(dwidget-examples/PrintPreviewSettingsPlugin) | ||
add_subdirectory(collections) | ||
add_subdirectory(PrintPreviewSettingsPlugin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
set(PLUGIN_NAME PrintPreviewSettingsPlugin) | ||
|
||
find_package(Qt5 REQUIRED COMPONENTS Core) | ||
|
||
add_library(${PLUGIN_NAME} SHARED | ||
settingsplugin.h | ||
settingsplugin.cpp | ||
) | ||
|
||
target_link_libraries(${PLUGIN_NAME} PRIVATE | ||
${LIB_NAME} | ||
) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
set(BIN_NAME collections) | ||
set(CMAKE_AUTOUIC ON) | ||
|
||
find_package(Qt5 REQUIRED COMPONENTS Gui Widgets) | ||
|
||
add_executable(${BIN_NAME} | ||
images.qrc | ||
resources.qrc | ||
icons/theme-icons.qrc | ||
cameraform.ui | ||
mainwindow.h | ||
buttonexample.h | ||
examplewindowinterface.h | ||
pagewindowinterface.h | ||
editexample.h | ||
sliderexample.h | ||
listviewexample.h | ||
windowexample.h | ||
tooltipexample.h | ||
spinnerexample.h | ||
dialogexample.h | ||
progressbarexample.h | ||
layoutexample.h | ||
scrollbarexample.h | ||
rubberbandexample.h | ||
widgetexample.h | ||
lcdnumberexample.h | ||
menuexample.h | ||
imageviewerexample.h | ||
main.cpp | ||
mainwindow.cpp | ||
buttonexample.cpp | ||
examplewindowinterface.cpp | ||
pagewindowinterface.cpp | ||
editexample.cpp | ||
sliderexample.cpp | ||
listviewexample.cpp | ||
windowexample.cpp | ||
tooltipexample.cpp | ||
spinnerexample.cpp | ||
dialogexample.cpp | ||
progressbarexample.cpp | ||
layoutexample.cpp | ||
scrollbarexample.cpp | ||
rubberbandexample.cpp | ||
widgetexample.cpp | ||
lcdnumberexample.cpp | ||
menuexample.cpp | ||
imageviewerexample.cpp | ||
) | ||
|
||
target_link_libraries(${BIN_NAME} PRIVATE | ||
Qt5::Widgets | ||
Qt5::GuiPrivate | ||
${LIB_NAME} | ||
) | ||
install( | ||
TARGETS ${BIN_NAME} | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/dtk${PROJECT_VERSION_MAJOR}/DWidget/examples/" | ||
) | ||
|
||
dconfig_override_files(APPID dtk-example META_NAME org.deepin.dtkwidget.feature-display FILES ${CMAKE_CURRENT_LIST_DIR}/org.deepin.dtkwiget.feature-display.json) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Oops, something went wrong.