status-desktop/libs/Helpers/CMakeLists.txt

80 lines
1.9 KiB
CMake

# Light helpers library expected to be used by all other libraries
#
cmake_minimum_required(VERSION 3.21)
project(Helpers
VERSION 0.1.0
LANGUAGES CXX)
find_package(nlohmann_json 3.10.5 REQUIRED)
set(QT_NO_CREATE_VERSIONLESS_FUNCTIONS true)
find_package(Qt6 ${STATUS_QT_VERSION} COMPONENTS Quick Qml REQUIRED)
qt6_standard_project_setup()
add_library(Helpers SHARED)
add_library(Status::Helpers ALIAS Helpers)
# Setup configuration type (Debug/Release)
# Inspired by https://programmingrecluse.wordpress.com/2020/02/04/detect-debug-build-with-cmake/
if(CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES Debug Release)
elseif(NOT CMAKE_BUILD_TYPE)
message("Missing Build Type! Run cmake with:\n-DCMAKE_BUILD_TYPE=Debug|Release")
endif()
# Use by linker only
set_property(GLOBAL PROPERTY DEBUG_CONFIGURATIONS Debug)
# Setup BUILD_DEBUG and BUILD_REALEASE if single configuration builds
if(CMAKE_BUILD_TYPE)
string(TOUPPER "${CMAKE_BUILD_TYPE}" _upper_build_type)
set(BUILD_${_upper_build_type} true)
endif()
set(BUILD_GENERATED_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/generated)
configure_file("template/BuildConfiguration.h.in"
"${BUILD_GENERATED_DIRECTORY}/Helpers/BuildConfiguration.h"
@ONLY)
target_include_directories(Helpers
PUBLIC
src
${BUILD_GENERATED_DIRECTORY}
PRIVATE
src/Helpers
${BUILD_GENERATED_DIRECTORY}/Helpers
)
target_link_libraries(Helpers
PUBLIC
nlohmann_json::nlohmann_json
PRIVATE
Qt6::Quick
Qt6::Qml
)
install(
TARGETS
Helpers
RUNTIME
)
target_sources(Helpers
PRIVATE
src/Helpers/conversions.h
src/Helpers/conversions.cpp
src/Helpers/helpers.h
src/Helpers/logs.h
src/Helpers/logs.cpp
src/Helpers/NamedType.h
src/Helpers/QObjectVectorModel.h
src/Helpers/Singleton.h
src/Helpers/Macros.h
src/Helpers/JsonMacros.h
)