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.

# Switch between static and dynamic library build.
if (TRUE)
# Add shared library target and also sets the dynamic library version.
Sf_AddSharedLibrary("${PROJECT_NAME}")
# Sets the extension of the generated binary.
Sf_SetTargetSuffix("${PROJECT_NAME}")
# Add version resource to the target.
Sf_AddVersionResource("${PROJECT_NAME}")
# Add target compile definitions.
target_compile_definitions(${PROJECT_NAME} PRIVATE
# Tell the compiled code a dynamic library (DL) is being build.
TARGET_DYNAMIC_LIB
# 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
)
else ()
add_library("${PROJECT_NAME}" STATIC)
# Add target compile definitions.
target_compile_definitions(${PROJECT_NAME} PRIVATE
# Tell the compiled code a static library is being build.
TARGET_STATIC_LIB
## 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
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.

# Required first entry checking the cmake version.
cmake_minimum_required(VERSION 3.18)
# Set the project name.
project("hello-world"
DESCRIPTION "Hello world application"
LANGUAGES CXX
)
# Set the actual executable target.
Sf_AddExecutable("${PROJECT_NAME}")
# Import the library static or dynamic.
target_link_libraries(${PROJECT_NAME} PRIVATE Sf::Hello)
# Add custom target to report resource stored versions.
Sf_AddExifTarget("${PROJECT_NAME}")
# RC-files only seem to be compiled when building using MingW.
target_sources(${PROJECT_NAME} PRIVATE main.cpp template.h)
# Sets the extension of the generated binary.
Sf_SetTargetSuffix("${PROJECT_NAME}")
# Add version resource to the target.
Sf_AddVersionResource("${PROJECT_NAME}")

Application GUI

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

# Required first entry checking the cmake version.
cmake_minimum_required(VERSION 3.18)
# 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 3 CMAKE_xxxxx_OUTPUT_DIRECTORY variables.
Sf_SetOutputDirs("bin")
# Set the actual executable target.
Sf_AddExecutable("${PROJECT_NAME}")
# Add custom target to report resource stored versions.
Sf_AddExifTarget("${PROJECT_NAME}")
# 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)
# Sets the extension of the generated binary.
Sf_SetTargetSuffix("${PROJECT_NAME}")
# Add version resource to the target.
Sf_AddVersionResource("${PROJECT_NAME}")

Help on Template

src/gen/template.h