Thu, 17 Mar 2022 13:54:39 +0100
Updated translations and some messages.
# CMakeLists.txt is part of bmsapp # PROJECT(bmsapp) CMAKE_MINIMUM_REQUIRED( VERSION 3.6 ) SET(bmsapp_EXECUTABLE "bmsapp") MESSAGE( STATUS "Building bmsapp" ) # ===== Set application version ===== SET( bmsapp_VERSION_MAJOR 0 ) SET( bmsapp_VERSION_MINOR 1 ) SET( bmsapp_VERSION_PATCH 0 ) # Compile flags OPTION(DO_RELEASE_BUILD "If on, will do a release build. Otherwise, debug build." OFF) option(UPDATE_TRANSLATIONS "Enable rescanning sources to update .ts files" OFF) # Automatically run moc on source files when necessary set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) SET( CMAKE_CXX_FLAGS_RELEASE "-Wall -ansi -pedantic -Wno-long-long -O2 -pipe" ) SET( CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -pipe" ) #====================================================Set build type===================================================== # We might always to tell the compiler to include debugging information (eg via the -g option on gcc). It makes the # binaries slightly bigger on Linux, but helps greatly in analysing core dumps etc. (In closed-source projects people # sometimes turn it off for release builds to make it harder to reverse engineer the software, but obviously that's not # an issue for us.) # # However, setting CMAKE_BUILD_TYPE to "Debug", also changes other things, such as the default location for config # files, which we don't want on a release build, so we would probably need to set compiler flags directly. # # .:TBD:. Investigate whether setting CMAKE_BUILD_TYPE to "RelWithDebInfo" does what we want. # #IF( ${DO_RELEASE_BUILD} ) # SET(CMAKE_BUILD_TYPE "Release") #ELSE() # SET(CMAKE_BUILD_TYPE "Debug") #ENDIF() # ===== 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(ROOTDIR "${CMAKE_CURRENT_SOURCE_DIR}") SET(SRCDIR "${ROOTDIR}/src") SET(UIDIR "${ROOTDIR}/ui") SET(DATADIR "${ROOTDIR}/data") SET(TRANSLATIONSDIR "${ROOTDIR}/translations") INCLUDE_DIRECTORIES(${SRCDIR}) INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/src") # In case of out-of-source build. # ===== Find Qt5 ===== # Minimum versio 5.13 for debug messages. find_package(Qt5 5.13 REQUIRED COMPONENTS Core Widgets Network Sql LinguistTools PrintSupport) # PrintSupport Xml LinguistTools # 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 ===== set( SRCS ${SRCDIR}/main.cpp ${SRCDIR}/bmsapp.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}/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}/Setup.cpp ${SRCDIR}/Utils.cpp ${SRCDIR}/PrinterDialog.cpp ${SRCDIR}/MainWindow.cpp ${SRCDIR}/database/database.cpp ${SRCDIR}/nulldateedit.cpp ) set( HDRS ${SRCDIR}/bmsapp.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}/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}/Setup.h ${SRCDIR}/Utils.h ${SRCDIR}/PrinterDialog.h ${SRCDIR}/MainWindow.h ${SRCDIR}/database/database.h ${SRCDIR}/nulldateedit.h ) set( UIS ${UIDIR}/AboutDialog.ui ${UIDIR}/InventorySuppliers.ui ${UIDIR}/EditSupplier.ui ${UIDIR}/InventoryFermentables.ui ${UIDIR}/EditFermentable.ui ${UIDIR}/InventoryHops.ui ${UIDIR}/EditHop.ui ${UIDIR}/InventoryYeasts.ui ${UIDIR}/EditYeast.ui ${UIDIR}/InventoryMiscs.ui ${UIDIR}/EditMisc.ui ${UIDIR}/InventoryWaters.ui ${UIDIR}/EditWater.ui ${UIDIR}/InventoryEquipments.ui ${UIDIR}/EditEquipment.ui ${UIDIR}/ProfileWaters.ui ${UIDIR}/EditProfileWater.ui ${UIDIR}/ProfileMashs.ui ${UIDIR}/EditProfileMash.ui ${UIDIR}/ProfileStyles.ui ${UIDIR}/EditProfileStyle.ui ${UIDIR}/ProfileFerments.ui ${UIDIR}/EditProfileFerment.ui ${UIDIR}/Setup.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 ) # ===== Build the application ===== # Run with cmake -DUPDATE_TRANSLATIONS=ON .. # or cmake -DUPDATE_TRANSLATIONS=OFF .. if(UPDATE_TRANSLATIONS) message("** parse sources for new translations") qt5_create_translation(QM_FILES ${SOURCE_FILES} ${TS_FILES}) else() message("** update qm files") qt5_add_translation(QM_FILES ${TS_FILES}) endif() add_executable(${bmsapp_EXECUTABLE} ${SOURCE_FILES} ${QM_FILES}) target_link_libraries(${bmsapp_EXECUTABLE} Qt5::Core Qt5::Widgets Qt5::Network Qt5::Sql Qt5::PrintSupport) # `make translations' add_custom_target(translations DEPENDS ${QM_FILES}) # ===== Install the application =====