Skip to content

Commit

Permalink
Merge branch 'feature/cmake' into 'main'
Browse files Browse the repository at this point in the history
Feature/cmake

See merge request asxa86/aspire!10
  • Loading branch information
ASxa86 committed Nov 8, 2024
2 parents 5c1b480 + 7d4e798 commit 67e80af
Show file tree
Hide file tree
Showing 54 changed files with 634 additions and 879 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"remoteEnv": {
"NUGET_NAME": "gitlab",
"NUGET_SOURCE": "https://gitlab.com/api/v4/projects/51467465/packages/nuget/index.json",
"VCPKG_VERSION": "2024.07.12",
"VCPKG_VERSION": "2024.10.21",
"VCPKG_ROOT": "${containerWorkspaceFolder}/vcpkg",
"VCPKG_BINARY_SOURCES": "clear;nuget,gitlab,readwrite",
"GITLAB_USER": "${localEnv:GITLAB_USER}",
"GITLAB_USER_TOKEN": "${localEnv:GITLAB_USER_TOKEN}",
"WORKSPACE_DIR": "${containerWorkspaceFolder}",
"PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/vcpkg:${containerWorkspaceFolder}/vcpkg/downloads/tools/cmake-3.29.2-linux/cmake-3.29.2-linux-x86_64/bin:${containerEnv:ANDROID_HOME}/cmdline-tools/latest/bin:${containerEnv:ANDROID_HOME}/platform-tools:${containerEnv:ANDROID_HOME}/emulator"
"PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/vcpkg:${containerWorkspaceFolder}/vcpkg/downloads/tools/cmake-3.30.1-linux/cmake-3.30.1-linux-x86_64/bin:${containerWorkspaceFolder}/vcpkg/downloads/tools/ninja-1.11.1-linux:${containerEnv:ANDROID_HOME}/cmdline-tools/latest/bin:${containerEnv:ANDROID_HOME}/platform-tools:${containerEnv:ANDROID_HOME}/emulator"
},
"runArgs": [
"--gpus",
Expand All @@ -29,5 +29,5 @@
}
},
"overrideCommand": true,
"postCreateCommand": "bash .devcontainer/postcreate.sh"
"postCreateCommand": "bash .devcontainer/android/postcreate.sh"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ fi
./vcpkg/bootstrap-vcpkg.sh
./vcpkg/vcpkg fetch nuget
./vcpkg/vcpkg fetch cmake
./vcpkg/vcpkg fetch ninja

echo "mono ./vcpkg/downloads/tools/nuget-6.10.0-linux/nuget.exe sources add -source $NUGET_SOURCE -name $NUGET_NAME -username $GITLAB_USER -password $GITLAB_USER_TOKEN"
mono ./vcpkg/downloads/tools/nuget-6.10.0-linux/nuget.exe sources add -source $NUGET_SOURCE -name $NUGET_NAME -username $GITLAB_USER -password $GITLAB_USER_TOKEN

sdkmanager "emulator"
sdkmanager "system-images;android-34;google_apis;x86_64"
sdkmanager "system-images;android-34;google_apis;x86_64;arm64-v8a"
apt install -y libpulse-dev

if [ ! -d "$WORKSPACE_DIR/avd" ]; then
Expand Down
33 changes: 33 additions & 0 deletions .devcontainer/linux/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"image": "registry.gitlab.com/asxa86/images/ubuntu-dev:latest",
"remoteEnv": {
"NUGET_NAME": "gitlab",
"NUGET_SOURCE": "https://gitlab.com/api/v4/projects/51467465/packages/nuget/index.json",
"VCPKG_VERSION": "2024.10.21",
"VCPKG_ROOT": "${containerWorkspaceFolder}/vcpkg",
"VCPKG_BINARY_SOURCES": "clear;nuget,gitlab,readwrite",
"GITLAB_USER": "${localEnv:GITLAB_USER}",
"GITLAB_USER_TOKEN": "${localEnv:GITLAB_USER_TOKEN}",
"WORKSPACE_DIR": "${containerWorkspaceFolder}",
"PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/vcpkg:${containerWorkspaceFolder}/vcpkg/downloads/tools/cmake-3.30.1-linux/cmake-3.30.1-linux-x86_64/bin:${containerWorkspaceFolder}/vcpkg/downloads/tools/ninja-1.11.1-linux"
},
"runArgs": [
"--gpus",
"all",
"--device",
"/dev/kvm"
],
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cmake-tools",
"twxs.cmake",
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack",
"bbenoist.QML"
]
}
},
"overrideCommand": true,
"postCreateCommand": "bash .devcontainer/linux/postcreate.sh"
}
15 changes: 15 additions & 0 deletions .devcontainer/linux/postcreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /bin/bash

if [ -d "$VCPKG_ROOT" ]; then
echo "$VCPKG_ROOT already exists. Skipping clone."
else
git clone https://github.com/microsoft/vcpkg.git $VCPKG_ROOT --depth 1 --branch $VCPKG_VERSION
fi

./vcpkg/bootstrap-vcpkg.sh
./vcpkg/vcpkg fetch nuget
./vcpkg/vcpkg fetch cmake
./vcpkg/vcpkg fetch ninja

echo "mono ./vcpkg/downloads/tools/nuget-6.10.0-linux/nuget.exe sources add -source $NUGET_SOURCE -name $NUGET_NAME -username $GITLAB_USER -password $GITLAB_USER_TOKEN"
mono ./vcpkg/downloads/tools/nuget-6.10.0-linux/nuget.exe sources add -source $NUGET_SOURCE -name $NUGET_NAME -username $GITLAB_USER -password $GITLAB_USER_TOKEN
57 changes: 23 additions & 34 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ default:
variables:
NUGET_SOURCE: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/nuget/index.json"
NUGET_NAME: gitlab
VCPKG_VERSION: 2024.07.12
VCPKG_VERSION: 2024.10.21
VCPKG_BINARY_SOURCES: "clear;nuget,${NUGET_NAME},readwrite"
CMAKE_COMMAND: ${CI_PROJECT_DIR}/vcpkg/downloads/tools/cmake-3.29.2-linux/cmake-3.29.2-linux-x86_64/bin/cmake
CMAKE_COMMAND: ${CI_PROJECT_DIR}/vcpkg/downloads/tools/cmake-3.30.1-linux/cmake-3.30.1-linux-x86_64/bin/cmake
NUGET_COMMAND: ${CI_PROJECT_DIR}/vcpkg/downloads/tools/nuget-6.10.0-linux/nuget.exe

.get-vcpkg: &get-vcpkg
Expand All @@ -20,6 +20,8 @@ variables:
- ./vcpkg/bootstrap-vcpkg.sh
- ./vcpkg/vcpkg fetch nuget --x-wait-for-lock
- ./vcpkg/vcpkg fetch cmake --x-wait-for-lock
- ./vcpkg/vcpkg fetch ninja --x-wait-for-lock
- export PATH=$PATH:${CI_PROJECT_DIR}/vcpkg/downloads/tools/ninja-1.11.1-linux

# Configure NuGet
- mono ${NUGET_COMMAND} sources add -source ${NUGET_SOURCE} -name ${NUGET_NAME} -username gitlab-ci-token -password $CI_JOB_TOKEN
Expand All @@ -37,13 +39,13 @@ lint-clang-tidy:
- *get-vcpkg

# Configure Aspire
- ${CMAKE_COMMAND} --preset clang-debug
- ${CMAKE_COMMAND} --preset x64-linux-gcc-debug

# Build to force generate moc files.
- ${CMAKE_COMMAND} --build --preset clang-debug
- ${CMAKE_COMMAND} --build --preset x64-linux-gcc-debug

# Run Clang Tidy
- find module/ app/ -type f -name "*.cpp" -print0 | xargs -0 -P $(nproc --all) clang-tidy-18 -p build-debug
- find app/ -type f -name "*.cpp" -print0 | xargs -0 -P $(nproc --all) clang-tidy-18 -p build

.build-base:
image: $CI_REGISTRY/asxa86/images/ubuntu-dev:latest
Expand All @@ -65,48 +67,35 @@ lint-clang-tidy:
# paths:
# - vcpkg/buildtrees/**/*.txt
# - vcpkg/buildtrees/**/*.log

build-clang-debug:
extends: .build-base
variables:
CMAKE_PRESET: clang-debug
artifacts:
expire_in: 1 day
paths:
- build-debug
- build
exclude:
- build/vcpkg_installed/**/*

build-gcc-debug:
extends: .build-base
variables:
CMAKE_PRESET: x64-linux-gcc-debug

build-gcc-release:
extends: .build-base
variables:
CMAKE_PRESET: gcc-release
artifacts:
expire_in: 1 day
paths:
- build-release
CMAKE_PRESET: x64-linux-gcc-release

build-android-x64-debug:
image: $CI_REGISTRY/asxa86/images/android-build:latest
extends: .build-base
variables:
CMAKE_PRESET: android-x64-debug
artifacts:
expire_in: 1 day
paths:
- build-debug
exclude:
- build-debug/vcpkg_installed/**/*
CMAKE_PRESET: x64-android-debug


build-android-armg64-debug:
image: $CI_REGISTRY/asxa86/images/android-build:latest
extends: .build-base
variables:
CMAKE_PRESET: android-arm64-debug
artifacts:
expire_in: 1 day
paths:
- build-debug
exclude:
- build-debug/vcpkg_installed/**/*
CMAKE_PRESET: arm64-android-debug

build-gcc-debug-sonar:
image: $CI_REGISTRY/asxa86/images/ubuntu-dev:latest
Expand All @@ -118,7 +107,7 @@ build-gcc-debug-sonar:
- docker
- large
variables:
CMAKE_PRESET: gcc-debug
CMAKE_PRESET: x64-linux-gcc-debug
script:
# Download sonar-scanner
- curl -sSLo ./sonar-scanner.zip 'https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.1.0.4477-linux-x64.zip'
Expand All @@ -134,16 +123,16 @@ build-gcc-debug-sonar:
# Run the sonar-scanner in the same stage as the build
- sonar-scanner/bin/sonar-scanner -Dsonar.host.url="${SONAR_HOST_URL}" -Dsonar.token="${SONAR_TOKEN}" -Dsonar.cfamily.compile-commands=bw-output/compile_commands.json

test-clang-debug:
test-gcc-debug:
image: $CI_REGISTRY/asxa86/images/ubuntu-dev:latest
stage: test
needs:
- build-clang-debug
- build-gcc-debug
tags:
# - saas-linux-medium-amd64
- shelley
- docker
- large
script:
- *get-vcpkg
- ${CMAKE_COMMAND} --build --preset clang-debug --target test
- ${CMAKE_COMMAND} --build --preset x64-linux-gcc-debug --target test
28 changes: 0 additions & 28 deletions .vscode/tasks.json

This file was deleted.

31 changes: 9 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
cmake_minimum_required(VERSION 3.27)
enable_language(CXX)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

include(GenerateExportHeader)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
include(cmake/project_compile_options.cmake)
include(cmake/project_add_library.cmake)
include(cmake/project_add_executable.cmake)
include(cmake/project_add_module.cmake)
include(cmake/project_gen_export.cmake)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/installed)

set(PROJECT_ROOT_NAME aspire)
project(${PROJECT_ROOT_NAME})
project(aspire)

enable_language(CXX)

include(GenerateExportHeader)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
include(CTest)
include(GoogleTest)

Expand All @@ -33,18 +27,11 @@ include_directories(SYSTEM ${CMAKE_CURRENT_BINARY_DIR})
# Qt fails to find this path for android when it invokes Qt6AndroidMacros.cmake.
set(QT_ANDROID_PATH_CMAKE_DIR_${ANDROID_ABI} ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share)

find_package(Qt6 CONFIG REQUIRED COMPONENTS Quick)
find_package(Qt6 6.7 CONFIG REQUIRED COMPONENTS Quick)

qt_standard_project_setup()
qt_standard_project_setup(REQUIRES 6.7)

set(CMAKE_AUTOMOC ON)

add_subdirectory(app)
add_subdirectory(module)

# set(PROJECT_CONFIG_VERSION ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_ROOT_NAME}-config-version.cmake)
# write_basic_package_version_file(${PROJECT_CONFIG_VERSION} VERSION 0.0.0 COMPATIBILITY SameMajorVersion)

# install(EXPORT ${PROJECT_ROOT_NAME}-config DESTINATION ${CMAKE_INSTALL_DATAROOTDIR})
# install(DIRECTORY include/${PROJECT_ROOT_NAME} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# install(FILES ${PROJECT_CONFIG_VERSION} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR})
# add_subdirectory(module)
Loading

0 comments on commit 67e80af

Please sign in to comment.