From 85cca1eed1cdcb425b877deefc10b74bdc26dff9 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sat, 27 Jul 2024 09:59:28 -0400 Subject: [PATCH 1/5] Use PUBLIC_HEADERS --- CMakeLists.txt | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb4f158..8d432f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,14 +10,18 @@ set(CMAKE_AUTORCC ON) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -add_library(QtAwesome +set(QtAwesome_HEADERS QtAwesome/QtAwesome.h - QtAwesome/QtAwesome.cpp QtAwesome/QtAwesomeAnim.h - QtAwesome/QtAwesomeAnim.cpp QtAwesome/QtAwesomeEnumGenerated.h QtAwesome/QtAwesomeStringGenerated.h +) + +add_library(QtAwesome + QtAwesome/QtAwesome.cpp + QtAwesome/QtAwesomeAnim.cpp QtAwesome/QtAwesomeFree.qrc + ${QtAwesome_HEADERS} ) include(GNUInstallDirs) @@ -32,23 +36,20 @@ target_link_libraries(QtAwesome PUBLIC Qt${QT_VERSION_MAJOR}::Widgets ) +set_target_properties(QtAwesome PROPERTIES + PUBLIC_HEADER "${QtAwesome_HEADERS}" +) + install(TARGETS QtAwesome EXPORT QtAwesomeConfig RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/QtAwesome ) install(EXPORT QtAwesomeConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/QtAwesome/ NAMESPACE QtAwesome:: ) -export(EXPORT QtAwesomeConfig NAMESPACE QtAwesome::) - -install(FILES - QtAwesome/QtAwesome.h - QtAwesome/QtAwesomeAnim.h - QtAwesome/QtAwesomeEnumGenerated.h - QtAwesome/QtAwesomeStringGenerated.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/QtAwesome - ) +export(EXPORT QtAwesomeConfig NAMESPACE QtAwesome::) From 5a60b87d3ff4f854515c47591b07f58ee9a1e7cb Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sat, 27 Jul 2024 11:26:13 -0400 Subject: [PATCH 2/5] feat: Install license --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d432f9..b87f25c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,8 @@ install(TARGETS QtAwesome EXPORT QtAwesomeConfig PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/QtAwesome ) +install (FILES "${PROJECT_SOURCE_DIR}/LICENSE.md" DESTINATION ${CMAKE_INSTALL_DATADIR}/licenses/${PROJECT_NAME} RENAME LICENSE) + install(EXPORT QtAwesomeConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/QtAwesome/ NAMESPACE QtAwesome:: From 9e4e2a908730211a05ec8281049a40c8c15ced1e Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sat, 27 Jul 2024 10:51:51 -0400 Subject: [PATCH 3/5] build: Get version from git --- .github/workflows/cmake.yml | 3 +++ CMakeLists.txt | 40 ++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 4275c48..21bbf00 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -33,6 +33,9 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@v4 + with: + fetch-depth: 0 + - run: git fetch --tags --force - name: Install Qt uses: jurplel/install-qt-action@v4 diff --git a/CMakeLists.txt b/CMakeLists.txt index b87f25c..752aa1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,43 @@ cmake_minimum_required(VERSION 3.16) -project(QtAwesome) + +#Set The Current Version Number to use as fallback if GIT Fails. +set(QTAWESOME_VERSION_MAJOR 6) +set(QTAWESOME_VERSION_MINOR 5) +set(QTAWESOME_VERSION_PATCH 1) +set(QTAWESOME_VERSION_TWEAK 0) +# Get the version from git if it's a git repository +if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) + find_package(Git) + if(GIT_FOUND) + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --tags --long --match "font-awesome-*" --always + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + OUTPUT_VARIABLE GITREV + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(FIND ${GITREV} "font-awesome-" isRev) + if(NOT ifRev EQUAL -1) + string(REGEX MATCH [0-9]+ MAJOR ${GITREV}) + string(REGEX MATCH \\.[0-9]+ MINOR ${GITREV}) + string(REPLACE "." "" MINOR "${MINOR}") + string(REGEX MATCH [0-9]+\- PATCH ${GITREV}) + string(REPLACE "-" "" PATCH "${PATCH}") + string(REGEX MATCH \-[0-9]+\- TWEAK ${GITREV}) + string(REPLACE "-" "" TWEAK "${TWEAK}") + set(QTAWESOME_VERSION_MAJOR ${MAJOR}) + set(QTAWESOME_VERSION_MINOR ${MINOR}) + set(QTAWESOME_VERSION_PATCH ${PATCH}) + set(QTAWESOME_VERSION_TWEAK ${TWEAK}) + elseif(NOT ${GITREV} STREQUAL "") + set(QTAWESOME_VERSION_TWEAK ${GITREV}) + endif() + endif() +endif() + +set(QTAWESOME_VERSION "${QTAWESOME_VERSION_MAJOR}.${QTAWESOME_VERSION_MINOR}.${QTAWESOME_VERSION_PATCH}.${QTAWESOME_VERSION_TWEAK}") +message(STATUS "Building QTAWESOME: ${QTAWESOME_VERSION}") + +project(QtAwesome VERSION ${QTAWESOME_VERSION}) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets) From f38515793765daac25002c0ab931fecd9fde2e23 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sat, 27 Jul 2024 11:10:43 -0400 Subject: [PATCH 4/5] build: Simple CPack Package --- CMakeLists.txt | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 752aa1c..8c7cc86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ endif() set(QTAWESOME_VERSION "${QTAWESOME_VERSION_MAJOR}.${QTAWESOME_VERSION_MINOR}.${QTAWESOME_VERSION_PATCH}.${QTAWESOME_VERSION_TWEAK}") message(STATUS "Building QTAWESOME: ${QTAWESOME_VERSION}") -project(QtAwesome VERSION ${QTAWESOME_VERSION}) +project(QtAwesome VERSION ${QTAWESOME_VERSION} DESCRIPTION "Add Font Awesome icons to your Qt application") find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets) @@ -93,3 +93,51 @@ install(EXPORT QtAwesomeConfig ) export(EXPORT QtAwesomeConfig NAMESPACE QtAwesome::) + +## PACKAGES +#Generic Info +set(CPACK_PACKAGE_CONTACT "rick@blommersit.nl") +set(CPACK_STRIP_FILES TRUE) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.md") +set(CPACK_PACKAGE_NAME "QtAwesome") +set(CPACK_PACKAGE_VENDOR "gamecreature") +set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/gamecreature/QtAwesome") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${CMAKE_PROJECT_DESCRIPTION}) + +## SET OS NAME +if(CMAKE_SYSTEM_NAME MATCHES "Darwin") + set(OS_STRING "macos") +elseif(CMAKE_SYSTEM_NAME MATCHES "Windows") + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(OS_STRING "win64") + elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + set(OS_STRING "win32") + endif() +elseif(CMAKE_SYSTEM_NAME MATCHES "Linux") + set(OS_STRING "linux_${CMAKE_SYSTEM_PROCESSOR}") +else() + set(OS_STRING ${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}) +endif() + +if (NOT CPACK_PACKAGE_VERSION) + set(CPACK_PACKAGE_VERSION ${CMAKE_PROJECT_VERSION}) +endif() + +if(NOT BUILD_SHARED_LIBS) + set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${OS_STRING}") +else() + set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-static-${OS_STRING}") +endif() +set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}) +set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF) + +#Set base Name And Generator Based on the system +if(CMAKE_SYSTEM_NAME MATCHES "Darwin") + set(CPACK_GENERATOR "ZIP") +elseif(CMAKE_SYSTEM_NAME MATCHES "Windows") + set(CPACK_GENERATOR "7Z") +elseif(CMAKE_SYSTEM_NAME MATCHES "Linux") + set(CPACK_GENERATOR "TGZ") +endif() + +include(CPack) From bb2aa3d998d94a29727f0ae7e3c6cbacdbd3d085 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sat, 27 Jul 2024 11:30:00 -0400 Subject: [PATCH 5/5] ci: build package target --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 21bbf00..a00ce83 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -49,4 +49,4 @@ jobs: run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DBUILD_SHARED_LIBS=${{ matrix.shared }} -B "${{github.workspace}}/build" - name: Build with ${{ matrix.compiler }} - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target package