diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b33868..2547e44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,16 +1,18 @@ cmake_minimum_required(VERSION 3.20) -project(Testing LANGUAGES CXX) +project(TestingQt LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) -add_executable(test_app main.cpp) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) -if(MINGW) - target_link_options(test_app PRIVATE - -static - -static-libgcc - -static-libstdc++ - ) -endif() \ No newline at end of file +find_package(Qt6 REQUIRED COMPONENTS Widgets) + +add_executable(test_app + main.cpp +) + +target_link_libraries(test_app PRIVATE Qt6::Widgets) \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 4e3eea7..e6e3f85 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,24 +17,35 @@ pipeline { } } - stage('Build Windows') { - agent { label 'windows' } - steps { - cleanWs() - checkout scm +stage('Build Windows') { + agent { label 'windows' } + steps { + cleanWs() + checkout scm - bat ''' - call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat" + bat ''' + call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat" - cmake -S . -B build\\windows -G Ninja ^ - -DCMAKE_BUILD_TYPE=Release ^ - -DCMAKE_TOOLCHAIN_FILE=C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake + cmake -S . -B build\\windows -G Ninja ^ + -DCMAKE_BUILD_TYPE=Release ^ + -DCMAKE_TOOLCHAIN_FILE=C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake ^ + -DVCPKG_TARGET_TRIPLET=x64-windows - cmake --build build\\windows - ''' + cmake --build build\\windows - archiveArtifacts artifacts: 'build/windows/test_app.exe', fingerprint: true - } - } + if exist dist\\windows rmdir /s /q dist\\windows + mkdir dist\\windows + + copy build\\windows\\test_app.exe dist\\windows\\test_app.exe + + C:\\vcpkg\\installed\\x64-windows\\tools\\Qt6\\bin\\windeployqt.exe ^ + --release ^ + --no-translations ^ + dist\\windows\\test_app.exe + ''' + + archiveArtifacts artifacts: 'dist/windows/**', fingerprint: true + } +} } } \ No newline at end of file diff --git a/main.cpp b/main.cpp index f253cbe..a92f350 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,16 @@ -#include +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QMessageBox box; + box.setWindowTitle("Jenkins Qt Test"); + box.setText("Hello from Qt + Jenkins!"); + box.setInformativeText("This app was built on Windows agent."); + box.setStandardButtons(QMessageBox::Ok); + box.exec(); -int main() { - std::cout << "Hello, World!" << std::endl; return 0; } \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json index e55f310..740d8b1 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,5 +1,5 @@ - { "dependencies": [ + "qtbase" ] } \ No newline at end of file