-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
553 additions
and
296 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,5 @@ installed-* | |
# Scripts | ||
*.bat | ||
|
||
# Json | ||
# Json | ||
*.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml | ||
default: true | ||
MD002: false | ||
MD033: false | ||
|
||
MD013: | ||
line_length: 120 | ||
MD034: false | ||
MD041: false |
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,36 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
ci: | ||
skip: [clang-format] | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.2.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
exclude: ^tests/.*/data/.*$ | ||
- id: end-of-file-fixer | ||
exclude: ^tests/.*/data/.*$ | ||
- id: check-yaml | ||
- id: check-added-large-files | ||
- repo: https://github.com/cheshirekow/cmake-format-precommit | ||
rev: v0.6.13 | ||
hooks: | ||
- id: cmake-format | ||
# - id: cmake-lint | ||
- repo: https://github.com/pocc/pre-commit-hooks | ||
rev: v1.3.5 | ||
hooks: | ||
- id: clang-format | ||
args: [--style=file, -i] | ||
# - id: clang-tidy | ||
# args: [-checks=clang-diagnostic-return-type] | ||
# - id: oclint | ||
# args: [-enable-clang-static-analyzer, -enable-global-analysis] | ||
# - id: uncrustify | ||
# - id: cppcheck | ||
# args: [--enable=all] | ||
- repo: https://github.com/igorshubovych/markdownlint-cli | ||
rev: v0.31.1 | ||
hooks: | ||
- id: markdownlint | ||
args: [-f] |
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,124 +1,109 @@ | ||
cmake_minimum_required(VERSION 3.12) | ||
cmake_policy(SET CMP0077 NEW) | ||
|
||
project(PowerSlider) | ||
|
||
option(BUILD_DESIGNER_PLUGIN "Build Qt Designer Plugin" ON) | ||
option(BUILD_EXAMPLE_APP "Build example app" ON) | ||
|
||
# | ||
# Qt5 and Qt6 can be retrieved using versionless targets introduced in Qt5.15: | ||
# https://doc.qt.io/qt-6/cmake-qt5-and-qt6-compatibility.html#versionless-targets | ||
macro(find_qt_package) | ||
set(options REQUIRED) | ||
set(oneValueArgs "") | ||
set(multiValueArgs COMPONENTS) | ||
|
||
cmake_parse_arguments(MY_OPTIONS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||
|
||
if(NOT MY_OPTIONS_COMPONENTS) # User didn't enter any component | ||
set(MY_OPTIONS_COMPONENTS "") | ||
endif() | ||
|
||
find_package(Qt6 COMPONENTS ${MY_OPTIONS_COMPONENTS} QUIET) | ||
if(NOT Qt6_FOUND) | ||
if(${MY_OPTIONS_REQUIRED}) | ||
find_package(Qt5 5.15 COMPONENTS ${MY_OPTIONS_COMPONENTS} REQUIRED) | ||
else() | ||
find_package(Qt5 5.15 COMPONENTS ${MY_OPTIONS_COMPONENTS}) | ||
endif() | ||
endif() | ||
endmacro() | ||
|
||
include(cmake/findQtPackage.cmake) | ||
find_qt_package(COMPONENTS Core Widgets REQUIRED) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
set(CMAKE_AUTOMOC ON) | ||
set(CMAKE_AUTOUIC ON) | ||
set(CMAKE_AUTORCC ON) | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE "Release") | ||
endif() | ||
|
||
set(BUNDLE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Bundle-${CMAKE_CXX_COMPILER_ID}-${CMAKE_BUILD_TYPE}") | ||
set(BUNDLE_DIRECTORY | ||
"${CMAKE_CURRENT_SOURCE_DIR}/Bundle-${CMAKE_CXX_COMPILER_ID}-${CMAKE_BUILD_TYPE}" | ||
) | ||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | ||
set(CMAKE_INSTALL_PREFIX | ||
"${BUNDLE_DIRECTORY}" | ||
CACHE PATH "Install path prefix, prepended onto install directories." FORCE | ||
) | ||
message("Set install prefix to ${CMAKE_INSTALL_PREFIX}") | ||
set(CMAKE_INSTALL_PREFIX | ||
"${BUNDLE_DIRECTORY}" | ||
CACHE PATH "Install path prefix, prepended onto install directories." | ||
FORCE) | ||
message("Set install prefix to ${CMAKE_INSTALL_PREFIX}") | ||
endif() | ||
|
||
set(lib_SOURCES | ||
./src/PowerSlider.cpp | ||
) | ||
add_library(PowerSlider SHARED ./src/PowerSlider.cpp) | ||
|
||
add_library(${PROJECT_NAME} SHARED ${lib_SOURCES} ) | ||
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) | ||
target_compile_definitions(PowerSlider PRIVATE POWERSLIDER_EXPORT) | ||
|
||
target_link_libraries(${PROJECT_NAME} Qt::Widgets ) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER src/PowerSlider.hpp) | ||
target_link_libraries(PowerSlider Qt::Widgets) | ||
set_target_properties(PowerSlider PROPERTIES PUBLIC_HEADER src/PowerSlider.hpp) | ||
target_include_directories( | ||
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src> | ||
$<INSTALL_INTERFACE:include/${PROJECT_NAME}> | ||
) | ||
PowerSlider PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src> | ||
$<INSTALL_INTERFACE:include/PowerSlider>) | ||
|
||
if(BUILD_DESIGNER_PLUGIN) | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE "POWERSLIDER_DESIGNER_PLUGIN") | ||
|
||
find_qt_package( COMPONENTS Core Widgets UiTools REQUIRED) | ||
set(plugin_SOURCES | ||
./src/PowerSlider.cpp | ||
./src/PowerSliderPlugin.cpp | ||
) | ||
|
||
add_library(${PROJECT_NAME}Plugin SHARED ${plugin_SOURCES}) | ||
target_link_libraries(${PROJECT_NAME}Plugin Qt::UiTools Qt::Widgets ) | ||
target_compile_definitions(PowerSlider PRIVATE "POWERSLIDER_DESIGNER_PLUGIN") | ||
|
||
find_qt_package(COMPONENTS Core Widgets UiTools REQUIRED) | ||
|
||
add_library(PowerSliderPlugin SHARED ./src/PowerSlider.cpp | ||
./src/PowerSliderPlugin.cpp) | ||
target_link_libraries(PowerSliderPlugin Qt::UiTools Qt::Widgets) | ||
target_compile_definitions(PowerSliderPlugin PRIVATE POWERSLIDER_EXPORT) | ||
endif(BUILD_DESIGNER_PLUGIN) | ||
|
||
# manage installation | ||
include(GNUInstallDirs) | ||
include(CMakePackageConfigHelpers) | ||
|
||
# configure the package config file | ||
configure_file( | ||
${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in | ||
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake @ONLY | ||
) | ||
add_library(PowerSlider::PowerSlider ALIAS PowerSlider) | ||
|
||
# export targets file in buildtree and install targets file and package config file | ||
export(TARGETS ${PROJECT_NAME} | ||
FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake | ||
) | ||
install(EXPORT ${PROJECT_NAME}Targets NAMESPACE ${PROJECT_NAME}:: | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} | ||
) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} | ||
) | ||
# configure the package config file | ||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in | ||
${CMAKE_CURRENT_BINARY_DIR}/PowerSliderConfig.cmake @ONLY) | ||
|
||
# export targets file in buildtree and install targets file and package config | ||
# file | ||
export(TARGETS PowerSlider | ||
FILE ${CMAKE_CURRENT_BINARY_DIR}/PowerSliderTargets.cmake) | ||
install( | ||
EXPORT PowerSliderTargets | ||
NAMESPACE PowerSlider:: | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PowerSlider) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PowerSliderConfig.cmake | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PowerSlider) | ||
|
||
# install target | ||
install(TARGETS ${PROJECT_NAME} | ||
EXPORT ${PROJECT_NAME}Targets | ||
CONFIGURATIONS ${CMAKE_BUILD_TYPE} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
PUBLIC_HEADER | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} | ||
) | ||
install( | ||
TARGETS PowerSlider | ||
EXPORT PowerSliderTargets | ||
CONFIGURATIONS ${CMAKE_BUILD_TYPE} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/PowerSlider) | ||
|
||
if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
if(MSVC OR MSVC_IDE) | ||
install(FILES $<TARGET_PDB_FILE:${PROJECT_NAME}> DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
endif() | ||
if(MSVC OR MSVC_IDE) | ||
install(FILES $<TARGET_PDB_FILE:PowerSlider> | ||
DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
endif() | ||
endif() | ||
|
||
if(BUILD_DESIGNER_PLUGIN) | ||
install(TARGETS ${PROJECT_NAME}Plugin DESTINATION plugins/designer) | ||
install(TARGETS PowerSliderPlugin DESTINATION plugins/designer) | ||
endif(BUILD_DESIGNER_PLUGIN) | ||
|
||
# find_package will find PowerSlider package config in the buildtree | ||
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
if(NOT CMAKE_PROJECT_NAME STREQUAL ${PROJECT_NAME}) | ||
set(CMAKE_PREFIX_PATH | ||
"${CMAKE_PREFIX_PATH};${CMAKE_CURRENT_BINARY_DIR}" | ||
PARENT_SCOPE) | ||
endif() | ||
|
||
# manage example | ||
if(BUILD_EXAMPLE_APP) | ||
# find_package will find PowerSlider package config in the buildtree | ||
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_BINARY_DIR}) | ||
add_subdirectory(example) | ||
add_subdirectory(example) | ||
endif(BUILD_EXAMPLE_APP) |
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
Oops, something went wrong.