From d9978f10a0ef60563fdff8f8eadcb5a678b9a5b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pasi=20Pet=C3=A4j=C3=A4j=C3=A4rvi?= Date: Fri, 20 Aug 2021 14:48:26 +0300 Subject: Add cmake support Task-number: QTBUG-86119 Change-Id: I858cdcc75e8b26007c244f9ef4efebb5da9cd66a Reviewed-by: Samuli Piippo --- .cmake.conf | 1 + CMakeLists.txt | 26 ++++++++++++++++++++++++++ appcontroller.pro | 40 ---------------------------------------- main.cpp | 2 +- 4 files changed, 28 insertions(+), 41 deletions(-) create mode 100644 .cmake.conf create mode 100644 CMakeLists.txt delete mode 100644 appcontroller.pro diff --git a/.cmake.conf b/.cmake.conf new file mode 100644 index 0000000..16ecb3d --- /dev/null +++ b/.cmake.conf @@ -0,0 +1 @@ +add_compile_definitions(APPCONTROLLER_VERSION="1.0.0") diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7c96b7c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.16) +include(.cmake.conf) + +project(appcontroller LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(CMAKE_AUTOMOC ON) + +find_package(Qt6 COMPONENTS Network) + +qt6_add_executable(appcontroller + main.cpp + process.cpp + portlist.cpp + perfprocesshandler.cpp +) + +target_link_libraries(appcontroller PUBLIC + Qt::Network +) + +install(TARGETS appcontroller + RUNTIME DESTINATION bin +) diff --git a/appcontroller.pro b/appcontroller.pro deleted file mode 100644 index 97b208e..0000000 --- a/appcontroller.pro +++ /dev/null @@ -1,40 +0,0 @@ -QT-=gui -QT+=network -HEADERS=\ - process.h \ - portlist.h \ - perfprocesshandler.h - -SOURCES=\ - main.cpp \ - process.cpp \ - portlist.cpp \ - perfprocesshandler.cpp - -android { - target.path = $$[INSTALL_ROOT]/system/bin -} else { - target.path = $$[INSTALL_ROOT]/usr/bin -} -INSTALLS+=target - -# Find out git hash -exists(.git) { - unix:system(which git):HAS_GIT=TRUE - win32:system(where git.exe):HAS_GIT=TRUE - contains(HAS_GIT, TRUE) { - GIT_HASH=$$system(git log -1 --format=%H) - !system(git diff-index --quiet HEAD): GIT_HASH="$$GIT_HASH-dirty" - GIT_VERSION=$$system(git describe --tags --exact-match) - isEmpty(GIT_VERSION) : GIT_VERSION="unknown" - } -} else { - GIT_HASH="unknown" - GIT_VERSION="unknown" -} - -isEmpty(GIT_VERSION) : error("No suitable tag found") -isEmpty(GIT_HASH) : error("No hash available") - -DEFINES+="GIT_HASH=\\\"$$GIT_HASH\\\"" -DEFINES+="GIT_VERSION=\\\"$$GIT_VERSION\\\"" diff --git a/main.cpp b/main.cpp index 8f6d214..213339a 100644 --- a/main.cpp +++ b/main.cpp @@ -452,7 +452,7 @@ int main(int argc, char **argv) else return 1; } else if (arg == "--version") { - printf("Appcontroller version: " GIT_VERSION "\nGit revision: " GIT_HASH "\nFeatures: " FEATURES "\n"); + printf("Appcontroller version: " APPCONTROLLER_VERSION "\nFeatures: " FEATURES "\n"); return 0; } else if (arg == "--detach") { detach = true; -- cgit v1.2.3