From bdd63e89951880bf826a39e432f872c72d8b23a7 Mon Sep 17 00:00:00 2001 From: Peter M. Groen Date: Thu, 24 Feb 2022 23:20:44 +0100 Subject: [PATCH] Setting up build-system --- .gitignore | 3 +++ CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ src/controlcentre/CMakeLists.txt | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 0 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0a4ac40 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/.gitmodules +/cmake/ +/versioning/ diff --git a/CMakeLists.txt b/CMakeLists.txt index e69de29..5f019d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.12) +project(mqtt-tools) +# =========================================================================== +# == Check to see if we're a submodule or top-repo. +if( IS_DIRECTORY ${CMAKE_SOURCE_DIR}/cmake) + message( STATUS "Looks like we're a single module." ) + LIST( APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) +else() + message( FATAL_ERROR "No cmake directory founnd. Did you run the submodules script?" ) +endif() + +# ============================================================================ +# == Check to see if there is versioning information available +if( IS_DIRECTORY ${CMAKE_SOURCE_DIR}/versioning/cmake) + LIST( APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/versioning/cmake) +else() + message( FATAL_ERROR "No ${CMAKE_SOURCE_DIR}/osdev_versioning directory found." ) +endif() + +# ============================================================================ +# == Include build information +include(osdevversion) +include(projectheader) + +project_header(mqtt-tools) + +add_subdirectory(src/controlcentre) + +include(packaging) +package_component() diff --git a/src/controlcentre/CMakeLists.txt b/src/controlcentre/CMakeLists.txt index e69de29..855294b 100644 --- a/src/controlcentre/CMakeLists.txt +++ b/src/controlcentre/CMakeLists.txt @@ -0,0 +1,62 @@ +cmake_minimum_required(VERSION 3.12) +# ============================================================================ +# Check to see if we have cmake directory +if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/cmake) + message( STATUS "Looks like we're a single module" ) + LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) +else() + message( FATAL_ERROR "No cmake directory found. Did you run the submodules script?" ) +endif() + +# ============================================================================== +# Check to see if there is versioning information available +if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/versioning) + LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/versioning/cmake) +else() + message( FATAL_ERROR "No ${CMAKE_SOURCE_DIR}/osdev_versioning directory found." ) +endif() + +# ============================================================================== +include(projectheader) +project_header(mqttcc) + +find_package( Qt5Core REQUIRED ) +find_package( Qt5Gui REQUIRED ) +find_package( Qt5Widgets REQUIRED ) + +include(compiler) + +include_directories( + ${Qt5Core_INCLUDE_DIRS} + ${Qt5Gui_INCLUDE_DIRS} + ${Qt5Widget_INCLUDE_DIRS} +) + +set(SRC_LIST + ${CMAKE_CURRENT_SOURCE_DIR}/controlcentre.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp +) + +include(qtmoc) +create_mocs( SRC_LIST MOC_LIST + ${CMAKE_CURRENT_SOURCE_DIR}/controlcentre.h +) + +add_executable( ${PROJECT_NAME} + ${SRC_LIST} +) + +target_link_libraries( ${PROJECT_NAME} + ${Qt5Core_LIBRARIES} + ${Qt5Gui_LIBRARIES} + ${Qt5Widget_LIBRARIES} + mqtt-cpp +) + +set_target_properties( ${PROJECT_NAME} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib +) + +include(installation) +install_application() -- libgit2 0.21.4