Skip to content

Commit

Permalink
Merge branch 'feature/remove_cpp_lib'
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquetc committed Sep 30, 2024
2 parents 99d0c57 + 4f84920 commit be987d6
Show file tree
Hide file tree
Showing 549 changed files with 25,611 additions and 10,024 deletions.
26 changes: 26 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM fedora:latest


RUN dnf install -y ninja-build gcc cmake extra-cmake-modules gdb clang clang-tools-extra
RUN dnf install -y qt6-qtbase-devel qt6-qtdeclarative-devel qt6-qtsvg-devel qcoro-qt6-devel
RUN dnf install -y kf6-kirigami-devel kf6-kcoreaddons-devel kf6-kconfig-devel kf6-ki18n-devel
RUN dnf install -y python3-poetry
RUN dnf install -y git
RUN mkdir .venv

# ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.22.2"

# Optionally install the cmake for vcpkg
# COPY ./reinstall-cmake.sh /tmp/

# RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
# chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
# fi \
# && rm -f /tmp/reinstall-cmake.sh

# [Optional] Uncomment this section to install additional vcpkg ports.
# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install <your-port-name-here>"

# [Optional] Uncomment this section to install additional packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
23 changes: 23 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
{
"name": "C++",
"build": {
"dockerfile": "Dockerfile"
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "gcc -v",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
59 changes: 59 additions & 0 deletions .devcontainer/reinstall-cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
#
set -e

CMAKE_VERSION=${1:-"none"}

if [ "${CMAKE_VERSION}" = "none" ]; then
echo "No CMake version specified, skipping CMake reinstallation"
exit 0
fi

# Cleanup temporary directory and associated files when exiting the script.
cleanup() {
EXIT_CODE=$?
set +e
if [[ -n "${TMP_DIR}" ]]; then
echo "Executing cleanup of tmp files"
rm -Rf "${TMP_DIR}"
fi
exit $EXIT_CODE
}
trap cleanup EXIT


echo "Installing CMake..."
apt-get -y purge --auto-remove cmake
mkdir -p /opt/cmake

architecture=$(dpkg --print-architecture)
case "${architecture}" in
arm64)
ARCH=aarch64 ;;
amd64)
ARCH=x86_64 ;;
*)
echo "Unsupported architecture ${architecture}."
exit 1
;;
esac

CMAKE_BINARY_NAME="cmake-${CMAKE_VERSION}-linux-${ARCH}.sh"
CMAKE_CHECKSUM_NAME="cmake-${CMAKE_VERSION}-SHA-256.txt"
TMP_DIR=$(mktemp -d -t cmake-XXXXXXXXXX)

echo "${TMP_DIR}"
cd "${TMP_DIR}"

curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_BINARY_NAME}" -O
curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_CHECKSUM_NAME}" -O

sha256sum -c --ignore-missing "${CMAKE_CHECKSUM_NAME}"
sh "${TMP_DIR}/${CMAKE_BINARY_NAME}" --prefix=/opt/cmake --skip-license

ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
ln -s /opt/cmake/bin/ctest /usr/local/bin/ctest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ qleany_preview
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
.venv

# C extensions
*.so
Expand Down
115 changes: 2 additions & 113 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ project(
Qleany
VERSION ${QLEANY_VERSION}
LANGUAGES CXX
DESCRIPTION "Qleany is a light framework for Clean Architecture with Qt6")
DESCRIPTION "Qleany is a generator for Clean Architecture with Qt6")
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)

# Compiler settings
Expand Down Expand Up @@ -54,7 +54,6 @@ endif()
option(QLEANY_BUILD_EXAMPLES "Build examples" ON)
option(QLEANY_BUILD_TESTS "Build tests" ON)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(QLEANY_BUILD_WITH_QT_GUI "Build with Qt GUI" ON)

if(QLEANY_BUILD_WITH_QT_GUI)
add_compile_definitions(QLEANY_BUILD_WITH_QT_GUI=true)
Expand All @@ -69,130 +68,20 @@ endif()
# Add Qt components
find_package(
Qt6
COMPONENTS Core Sql Concurrent
COMPONENTS Core Sql Gui Widgets Concurrent
REQUIRED)
qt_standard_project_setup()

if(QLEANY_BUILD_WITH_QT_GUI)
find_package(
Qt6
COMPONENTS Gui
REQUIRED)
endif()

if(QLEANY_BUILD_EXAMPLES)
find_package(
Qt6
COMPONENTS Widgets
REQUIRED)
endif()

find_package(QCoro6 REQUIRED COMPONENTS Core)

# Set necessary compiler flags to enable coroutine support
qcoro_enable_coroutines()

# configure the library
file(GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
file(GLOB_RECURSE PUBLIC_HEADERS
"${CMAKE_CURRENT_SOURCE_DIR}/include/qleany/*.h")

message(STATUS "PUBLIC_HEADERS: ${PUBLIC_HEADERS}")

# Create the library target
add_library(qleany ${LIB_TYPE} ${SOURCES} ${PUBLIC_HEADERS})

# Generate export header
message(STATUS "Generating export header")

include(GenerateExportHeader)
generate_export_header(
qleany EXPORT_FILE_NAME
${CMAKE_CURRENT_BINARY_DIR}/include/qleany/qleany_export.h)

target_include_directories(qleany PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include)

target_include_directories(
qleany
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/qleany>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)

set_target_properties(qleany PROPERTIES CXX_STANDARD 20)

set_target_properties(qleany PROPERTIES OUTPUT_NAME qleany)
set_target_properties(
qleany
PROPERTIES
PUBLIC_HEADER
"${PUBLIC_HEADERS};${CMAKE_CURRENT_BINARY_DIR}/include/qleany/qleany_export.h"
)

target_link_libraries(qleany PUBLIC Qt6::Core Qt6::Concurrent Qt6::Sql)

if(QLEANY_BUILD_WITH_QT_GUI)
target_link_libraries(qleany PRIVATE Qt::Gui)
endif()

# state that Qleany need PIC when the default is shared libraries
set_target_properties(qleany PROPERTIES POSITION_INDEPENDENT_CODE
${BUILD_SHARED_LIBS})

# configure the install location
message(STATUS "Configuring install location")
include(GNUInstallDirs)

# Install library
install(
TARGETS qleany
EXPORT qleanyTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include/qleany)

# Install public headers
install(DIRECTORY include/qleany DESTINATION include)

# install license
install(FILES LICENSE DESTINATION share/qleany)

# Install the export set for use with the install-tree
install(
EXPORT qleanyTargets
FILE qleanyTargets.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/qleany)

# Create and install qleanyConfig.cmake
message(STATUS "Creating and installing qleanyConfig.cmake")
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
qleanyConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)

configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/qleanyConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/qleanyConfig.cmake
INSTALL_DESTINATION lib/cmake/qleany)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qleanyConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/qleanyConfigVersion.cmake
DESTINATION lib/cmake/qleany)

# Export the targets to a script message(STATUS "Exporting targets to a script")
# export(EXPORT ${PROJECT_NAME}Targets FILE
# ${CMAKE_CURRENT_BINARY_DIR}/qleanyTargets.cmake)

# Subdirectories that contain CMakeLists.txt for the framework tests and example
if(QLEANY_BUILD_TESTS)
add_subdirectory(tests)
endif()

if(QLEANY_BUILD_EXAMPLES)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_BINARY_DIR}/include)
set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR} ${CMAKE_PREFIX_PATH})
set(CMAKE_LIBRARY_PATH ${CMAKE_BINARY_DIR} ${CMAKE_LIBRARY_PATH})

add_subdirectory(examples)
endif()
17 changes: 17 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": 8,
"configurePresets": [
{
"name": "Configure preset using toolchain file",
"displayName": "Configure preset using toolchain file",
"description": "Sets Ninja generator, build and install directory",
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_TOOLCHAIN_FILE": "",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
}
}
]
}
Loading

0 comments on commit be987d6

Please sign in to comment.