CMakeLists.txt

Sat, 11 Feb 2023 15:48:02 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 11 Feb 2023 15:48:02 +0100
changeset 493
520306773450
parent 480
94b3def5d778
child 495
6aa29aaa3f4d
permissions
-rw-r--r--

Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.

# CMakeLists.txt is part of bmsapp
#

PROJECT(bmsapp)
CMAKE_MINIMUM_REQUIRED( VERSION 3.6 )
SET(bmsapp_EXECUTABLE "bmsapp")

# ===== Set application version =====

SET( bmsapp_VERSION_MAJOR 0 )
SET( bmsapp_VERSION_MINOR 4 )
SET( bmsapp_VERSION_PATCH 0 )

# Compile flags

option(BUILD_DESIGNER_PLUGINS "If on, you will only build and install the designer plugins." OFF)

IF( ${BUILD_DESIGNER_PLUGINS} )
  message(STATUS "Building designer plugins" )
ELSE()
  message(STATUS "Building bmsapp" )
ENDIF()

# Automatically run moc on source files when necessary
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

SET(CMAKE_INCLUDE_CURRENT_DIR ON)

SET( CMAKE_CXX_FLAGS_RELEASE "-Wall -ansi -pedantic -Wno-long-long -O2 -pipe" )
SET( CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -pipe" )

# ===== Directories =====

IF( NOT EXEC_PREFIX )
   SET( EXEC_PREFIX ${CMAKE_INSTALL_PREFIX} )
ENDIF()

SET( DATAROOTDIR "${EXEC_PREFIX}/share" )
SET( BINDIR "${EXEC_PREFIX}/bin" )
IF( NOT DOCDIR )
   SET( DOCDIR "${DATAROOTDIR}/doc/${CMAKE_PROJECT_NAME}" )
ENDIF()

SET( DATAPATH "${DATAROOTDIR}/${CMAKE_PROJECT_NAME}" )
SET( TARGETPATH ${BINDIR} )
SET( DOCPATH ${DOCDIR} )

SET( LIBPATH "$ENV{QT5DIR}" )

SET(ROOTDIR "${CMAKE_CURRENT_SOURCE_DIR}")
SET(SRCDIR "${ROOTDIR}/src")
SET(UIDIR "${ROOTDIR}/ui")
SET(DESIGNERDIR "${ROOTDIR}/designer")
SET(DATADIR "${ROOTDIR}/data")
SET(TRANSLATIONSDIR "${ROOTDIR}/translations")

INCLUDE_DIRECTORIES(${SRCDIR})
INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/src") # In case of out-of-source build.
INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/designer")

# ===== Find Qt5 =====

# Minimum versio 5.13 for debug messages.
find_package(Qt5 5.13 REQUIRED COMPONENTS Core Widgets Network Sql LinguistTools PrintSupport WebSockets Charts WebEngineWidgets)
INCLUDE_DIRECTORIES(${Qt5Core_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${Qt5Network_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${Qt5Sql_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${Qt5LinguistTools_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${Qt5PrintSupport_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${Qt5WebSockets_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${Qt5Charts_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${Qt5WebEngineWidgets_INCLUDE_DIRS})

# Xml

# Some extra files for the "make clean" target.
SET_PROPERTY(
   DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
   PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
   cmake_install.cmake
   compile_commands.json
   CMakeCache.txt
)

# ===== Setup the config.h =====

SET( CONFIGDATADIR "${DATAPATH}/" )
SET( CONFIGDOCDIR "${DOCPATH}/" )

# Tell cmake where the configure file is and where
# to put the output. All variables in config.in written as "${VAR}$
# will be replaced by VAR as determined by cmake in config.h.
# Outputs only in the build directory.
CONFIGURE_FILE( src/config.in src/config.h )

# ===== All sources =====

IF( ${BUILD_DESIGNER_PLUGINS} )

  ADD_DEFINITIONS(${QT_DEFINITIONS})
  ADD_DEFINITIONS(-DQT_PLUGIN)
  ADD_DEFINITIONS(-DQT_NO_DEBUG)
  ADD_DEFINITIONS(-DQT_SHARED)

  INCLUDE_DIRECTORIES(
    ${QT_INCLUDE_DIR}
    ${SRCDIR}
  )

  LINK_DIRECTORIES(
    ${QT_LIBRARY_DIR}
  )

  # By default only QtCore and QtGui are enabled
  SET( QT_USE_QTDESIGNER TRUE )

  QT_WRAP_CPP( GEN_MOC_FILES1 ${SRCDIR}/RangedSlider.h designer/RangedSliderPlugin.h)
  add_library(bmsapp_rangeslider SHARED
    ${SRCDIR}/RangedSlider.cpp
    designer/RangedSliderPlugin.cpp
    ${GEN_MOC_FILES1}
  )

  QT_WRAP_CPP( GEN_MOC_FILES2 ${SRCDIR}/NullDateEdit.h designer/NullDateEditPlugin.h)
  add_library(bmsapp_nulldate SHARED
    ${SRCDIR}/NullDateEdit.cpp
    designer/NullDateEditPlugin.cpp
    ${GEN_MOC_FILES2}
  )

  QT_WRAP_CPP(GEN_MOC_FILES4
    ${SRCDIR}/analog/thermometer.h
    ${SRCDIR}/analog/abstractmeter.h
    ${SRCDIR}/analog/widgetwithbackground.h
    designer/thermometer_plugin.h
  )
  add_library(bmsapp_thermometer SHARED
    ${SRCDIR}/analog/thermometer.cpp
    ${SRCDIR}/analog/abstractmeter.cpp
    ${SRCDIR}/analog/widgetwithbackground.cpp
    designer/thermometer_plugin.cpp
    ${GEN_MOC_FILES4}
  )

  QT_WRAP_CPP(GEN_MOC_FILES5
    ${SRCDIR}/analog/manometer.h
    ${SRCDIR}/analog/abstractmeter.h
    ${SRCDIR}/analog/widgetwithbackground.h
    designer/manometer_plugin.h
  )
  add_library(bmsapp_manometer SHARED
    ${SRCDIR}/analog/manometer.cpp
    ${SRCDIR}/analog/abstractmeter.cpp
    ${SRCDIR}/analog/widgetwithbackground.cpp
    designer/manometer_plugin.cpp
    ${GEN_MOC_FILES5}
  )

  QT_WRAP_CPP(GEN_MOC_FILES6
    ${SRCDIR}/analog/wallclock.h
    ${SRCDIR}/analog/widgetwithbackground.h
    designer/wallclock_plugin.h
  )
  add_library(bmsapp_wallclock SHARED
    ${SRCDIR}/analog/wallclock.cpp
    ${SRCDIR}/analog/widgetwithbackground.cpp
    designer/wallclock_plugin.cpp
    ${GEN_MOC_FILES6}
  )

  QT_WRAP_CPP(GEN_MOC_FILES7
    ${SRCDIR}/analog/led.h
    ${SRCDIR}/analog/widgetwithbackground.h
    designer/led_plugin.h
  )
  add_library(bmsapp_led SHARED
    ${SRCDIR}/analog/led.cpp
    ${SRCDIR}/analog/widgetwithbackground.cpp
    designer/led_plugin.cpp
    ${GEN_MOC_FILES7}
  )

ELSE()

  set( SRCS
    ${SRCDIR}/main.cpp
    ${SRCDIR}/RecipesTree.cpp
    ${SRCDIR}/AboutDialog.cpp
    ${SRCDIR}/InventorySuppliers.cpp
    ${SRCDIR}/EditSupplier.cpp
    ${SRCDIR}/InventoryFermentables.cpp
    ${SRCDIR}/EditFermentable.cpp
    ${SRCDIR}/InventoryHops.cpp
    ${SRCDIR}/EditHop.cpp
    ${SRCDIR}/InventoryYeasts.cpp
    ${SRCDIR}/EditYeast.cpp
    ${SRCDIR}/InventoryYeastPacks.cpp
    ${SRCDIR}/EditYeastPack.cpp
    ${SRCDIR}/InventoryMiscs.cpp
    ${SRCDIR}/EditMisc.cpp
    ${SRCDIR}/InventoryWaters.cpp
    ${SRCDIR}/EditWater.cpp
    ${SRCDIR}/InventoryEquipments.cpp
    ${SRCDIR}/EditEquipment.cpp
    ${SRCDIR}/ProfileWaters.cpp
    ${SRCDIR}/EditProfileWater.cpp
    ${SRCDIR}/ProfileMashs.cpp
    ${SRCDIR}/EditProfileMash.cpp
    ${SRCDIR}/ProfileStyles.cpp
    ${SRCDIR}/EditProfileStyle.cpp
    ${SRCDIR}/ProfileFerments.cpp
    ${SRCDIR}/EditProfileFerment.cpp
    ${SRCDIR}/EditRecipe.cpp
    ${SRCDIR}/ProdInprod.cpp
    ${SRCDIR}/ProdOnName.cpp
    ${SRCDIR}/ProdOnCode.cpp
    ${SRCDIR}/ProdOnDate.cpp
    ${SRCDIR}/ProdOnTree.cpp
    ${SRCDIR}/MonNodes.cpp
    ${SRCDIR}/MonFermenters.cpp
    ${SRCDIR}/MonCO2meters.cpp
    ${SRCDIR}/MoniSpindels.cpp
    ${SRCDIR}/DetailNode.cpp
    ${SRCDIR}/DetailFermenter.cpp
    ${SRCDIR}/DetailCO2meter.cpp
    ${SRCDIR}/DetailiSpindel.cpp
    ${SRCDIR}/ChartCarbonate.cpp
    ${SRCDIR}/ChartFermenter.cpp
    ${SRCDIR}/ChartiSpindel.cpp
    ${SRCDIR}/Webcam.cpp
    ${SRCDIR}/EditProduct.cpp
    ${SRCDIR}/ImportXML.cpp
    ${SRCDIR}/ImportBrew.cpp
    ${SRCDIR}/Setup.cpp
    ${SRCDIR}/Utils.cpp
    ${SRCDIR}/PrinterDialog.cpp
    ${SRCDIR}/MainWindow.cpp
    ${SRCDIR}/database/database.cpp
    ${SRCDIR}/database/db_product.cpp
    ${SRCDIR}/database/db_recipe.cpp
    ${SRCDIR}/RangedSlider.cpp
    ${SRCDIR}/NullDateEdit.cpp
    ${SRCDIR}/callout.cpp
    ${SRCDIR}/analog/abstractmeter.cpp
    ${SRCDIR}/analog/functions.cpp
    ${SRCDIR}/analog/widgetwithbackground.cpp
    ${SRCDIR}/analog/manometer.cpp
    ${SRCDIR}/analog/thermometer.cpp
    ${SRCDIR}/analog/led.cpp
    ${SRCDIR}/analog/wallclock.cpp
    ${SRCDIR}/global.cpp
  )

  set( HDRS
    ${SRCDIR}/RecipesTree.h
    ${SRCDIR}/AboutDialog.h
    ${SRCDIR}/InventorySuppliers.h
    ${SRCDIR}/EditSupplier.h
    ${SRCDIR}/InventoryFermentables.h
    ${SRCDIR}/EditFermentable.h
    ${SRCDIR}/InventoryHops.h
    ${SRCDIR}/EditHop.h
    ${SRCDIR}/InventoryYeasts.h
    ${SRCDIR}/EditYeast.h
    ${SRCDIR}/InventoryYeastPacks.h
    ${SRCDIR}/EditYeastPack.h
    ${SRCDIR}/InventoryMiscs.h
    ${SRCDIR}/EditMisc.h
    ${SRCDIR}/InventoryWaters.h
    ${SRCDIR}/EditWater.h
    ${SRCDIR}/InventoryEquipments.h
    ${SRCDIR}/EditEquipment.h
    ${SRCDIR}/ProfileWaters.h
    ${SRCDIR}/EditProfileWater.h
    ${SRCDIR}/ProfileMashs.h
    ${SRCDIR}/EditProfileMash.h
    ${SRCDIR}/ProfileStyles.h
    ${SRCDIR}/EditProfileStyle.h
    ${SRCDIR}/ProfileFerments.h
    ${SRCDIR}/EditProfileFerment.h
    ${SRCDIR}/EditRecipe.h
    ${SRCDIR}/ProdInprod.h
    ${SRCDIR}/ProdOnName.h
    ${SRCDIR}/ProdOnCode.h
    ${SRCDIR}/ProdOnDate.h
    ${SRCDIR}/ProdOnTree.h
    ${SRCDIR}/MonNodes.h
    ${SRCDIR}/MonFermenters.h
    ${SRCDIR}/MonCO2meters.h
    ${SRCDIR}/MoniSpindels.h
    ${SRCDIR}/DetailNode.h
    ${SRCDIR}/DetailFermenter.h
    ${SRCDIR}/DetailCO2meter.h
    ${SRCDIR}/DetailiSpindel.h
    ${SRCDIR}/ChartCarbonate.h
    ${SRCDIR}/ChartFermenter.h
    ${SRCDIR}/ChartiSpindel.h
    ${SRCDIR}/Webcam.h
    ${SRCDIR}/EditProduct.h
    ${SRCDIR}/ImportXML.h
    ${SRCDIR}/ImportBrew.h
    ${SRCDIR}/Setup.h
    ${SRCDIR}/Utils.h
    ${SRCDIR}/PrinterDialog.h
    ${SRCDIR}/MainWindow.h
    ${SRCDIR}/database/database.h
    ${SRCDIR}/database/db_product.h
    ${SRCDIR}/database/db_recipe.h
    ${SRCDIR}/RangedSlider.h
    ${SRCDIR}/NullDateEdit.h
    ${SRCDIR}/callout.h
    ${SRCDIR}/analog/abstractmeter.h
    ${SRCDIR}/analog/functions.h
    ${SRCDIR}/analog/widgetwithbackground.h
    ${SRCDIR}/analog/manometer.h
    ${SRCDIR}/analog/thermometer.h
    ${SRCDIR}/analog/led.h
    ${SRCDIR}/analog/wallclock.h
    ${SRCDIR}/global.h
  )

  set( UIS
    ${UIDIR}/AboutDialog.ui
    ${UIDIR}/EditSupplier.ui
    ${UIDIR}/EditFermentable.ui
    ${UIDIR}/EditHop.ui
    ${UIDIR}/EditYeast.ui
    ${UIDIR}/EditYeastPack.ui
    ${UIDIR}/EditMisc.ui
    ${UIDIR}/EditWater.ui
    ${UIDIR}/EditEquipment.ui
    ${UIDIR}/EditProfileWater.ui
    ${UIDIR}/EditProfileMash.ui
    ${UIDIR}/EditProfileStyle.ui
    ${UIDIR}/EditProfileFerment.ui
    ${UIDIR}/EditRecipe.ui
    ${UIDIR}/EditProduct.ui
    ${UIDIR}/DetailNode.ui
    ${UIDIR}/DetailFermenter.ui
    ${UIDIR}/DetailCO2meter.ui
    ${UIDIR}/DetailiSpindel.ui
    ${UIDIR}/ImportXML.ui
    ${UIDIR}/ImportBrew.ui
    ${UIDIR}/MainWindow.ui
  )

  set( TS_FILES
    ${TRANSLATIONSDIR}/bmsapp_en.ts # English
    ${TRANSLATIONSDIR}/bmsapp_nl.ts # Dutch
  )

  set( SOURCE_FILES
    ${SRCS}
    ${HDRS}
    ${UIS}
    resources/icons.qrc
    resources/qdarkstyle/theme/style.qrc
  )

ENDIF()

# ===== Build the application =====

IF( ${BUILD_DESIGNER_PLUGINS} )

ELSE()

  message("** parse sources for new translations")
  qt5_create_translation(QM_FILES ${SOURCE_FILES} ${TS_FILES})

  SET( bmsapp_DESKTOP
     ${ROOTDIR}/bmsapp.desktop
  )

  add_executable(${bmsapp_EXECUTABLE} ${SOURCE_FILES} ${QM_FILES})
  target_link_libraries(${bmsapp_EXECUTABLE} Qt5::Core Qt5::Widgets Qt5::Network Qt5::Sql Qt5::PrintSupport Qt5::WebSockets Qt5::Charts Qt5::WebEngineWidgets)

  # `make translations'
  add_custom_target(translations DEPENDS ${QM_FILES})
ENDIF()

# ===== Install the application =====

IF( ${BUILD_DESIGNER_PLUGINS} )

  INSTALL(TARGETS
    bmsapp_rangeslider
    bmsapp_nulldate
    bmsapp_thermometer
    bmsapp_manometer
    bmsapp_led
    bmsapp_wallclock
    DESTINATION "${LIBPATH}/plugins/designer"
  )

ELSE()

  install(TARGETS ${bmsapp_EXECUTABLE}
        RUNTIME DESTINATION bin
  )

  INSTALL( FILES ${bmsapp_DESKTOP}
	 DESTINATION "${DATAROOTDIR}/applications"
  )

  INSTALL( FILES ${QM_FILES}
	DESTINATION "${DATAROOTDIR}/bmsapp/translations"
  )

ENDIF()

mercurial