Scanframe DevOps Trial App 0.1.0
Loading...
Searching...
No Matches
Projects

Hello World

Library

The Hello World project can build for the commandline interface (CLI) of for the graphic user interface (GUI) using Qt. The projects can be built with a static or dynamic library containing the hello-world code.

# Get the Git versions from the repository of this files directory.
Sf_GetGitTagVersion(_Versions "${CMAKE_CURRENT_LIST_DIR}")
# Report the found Git tag found version.
Sf_ReportGitTagVersion("${_Versions}")
# Split the list into separate values.
list(GET _Versions 0 SF_GIT_TAG_VERSION)
list(GET _Versions 1 SF_GIT_TAG_RC)
list(GET _Versions 2 SF_GIT_TAG_COMMITS)
# Convert the versions list to a string.
Sf_VersionToString(SF_VERSION "${_Versions}")
# Switch between static and dynamic library build.
if (TRUE)
# Add shared library target and also sets the dynamic library version.
Sf_AddTarget("${PROJECT_NAME}" SHARED FLAGS pack doc VERSION EXIF SUFFIX COVERAGE)
# Add target compile definitions.
target_compile_definitions(${PROJECT_NAME} PRIVATE
# Tell the code the 'hello-lib' library is used as dynamic library. (So imports needed)
_HWL_PKG
## The 'DEBUG_LEVEL' controls the debug output macro's.
_DEBUG_LEVEL=1
# When enabled the 'target.h' file enables reporting of the current target being build using 'pragma message'.
#REPORT_TARGET
# Set version from Git.
SF_VERSION=${SF_VERSION}
)
else ()
Sf_AddTarget("${PROJECT_NAME}" STATIC FLAGS doc COVERAGE)
# Add target compile definitions.
target_compile_definitions(${PROJECT_NAME} PRIVATE
## The 'DEBUG_LEVEL' controls the debug output macro's.
_DEBUG_LEVEL=1
# When enabled the 'target.h' file enables reporting of the current target being build using 'pragma message'.
#REPORT_TARGET
# Set version from Git.
SF_VERSION=${SF_GIT_TAG_VERSION}-rc${SF_GIT_TAG_RC}~${SF_GIT_TAG_COMMITS}
PUBLIC
# Tell the code the 'hello-lib' library is used as an archive. (So no imports or exports)
_HWL_ARC
)
endif ()

Application CLI

This is the CMake project for the Hello World console application.

# Set the project name.
project("hello-world"
DESCRIPTION "Hello world application"
LANGUAGES CXX
)
# Set the actual executable target.
Sf_AddTarget("${PROJECT_NAME}" FLAGS doc cli pack VERSION EXIF SUFFIX)
# Import the library static or dynamic.
target_link_libraries(${PROJECT_NAME} PRIVATE Sf::Hello)
# RC-files only seem to be compiled when building using MingW.
target_sources(${PROJECT_NAME} PRIVATE main.cpp template.h)

Application GUI

This is the CMake project for the Hello World graphic application.

# Set the project name.
project("hello-world-qt" LANGUAGES CXX)
# Enable automatic compiling of Qt related source and resource files.
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
# Set the actual executable target.
Sf_AddTarget("${PROJECT_NAME}" FLAGS gui pack qt VERSION EXIF SUFFIX)
# Explicitly tell the compiled code the QT libraries are included.
target_compile_definitions(${PROJECT_NAME} PRIVATE TARGET_QT)
# Import static and or dynamic libraries.
target_link_libraries(${PROJECT_NAME} PRIVATE Sf::Hello Qt::Widgets)
# RC-files only seem to be compiled when building using MingW.
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
# Add this for the headers in the autogen directory made by the *.ui files.
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Add the message log context for debug builds so %{function}, %{file} and %{line} are available in the log.
# It can be specified by environment variable:
# QT_MESSAGE_PATTERN="%{if-category}%{category}: %{endif}%{function}: %{message}"
# And not to forget by categorized log entry and rules:
# QT_LOGGING_RULES=qt.tts.*=true
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(QT_MESSAGELOGCONTEXT)
endif()
# Fix for running in Wine11 since it is missing function 'WcsCreateIccProfile()' in 'mscms.dll'.
# Function used in Qt 6.12.0 and up.
Sf_Wine11DllFixForQt(${PROJECT_NAME} ${QT_VERSION})

Help on Template

src/cli/template.h