CMakeLists.txt

Mon, 14 Feb 2022 20:58:07 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 14 Feb 2022 20:58:07 +0100
changeset 10
8aa2bd9ba9e8
parent 6
f8474f2c5db9
child 14
8a304c898a75
permissions
-rw-r--r--

Added the EditSupplier popup window. It is now ready to validate the form data.

# 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

# 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)

# 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}/MainWindow.cpp
    ${SRCDIR}/database/database.cpp
)

set( HDRS
    ${SRCDIR}/bmsapp.h
    ${SRCDIR}/AboutDialog.h
    ${SRCDIR}/InventorySuppliers.h
    ${SRCDIR}/EditSupplier.h
    ${SRCDIR}/MainWindow.h
    ${SRCDIR}/database/database.h
)

set( UIS
    ${UIDIR}/AboutDialog.ui
    ${UIDIR}/InventorySuppliers.ui
    ${UIDIR}/EditSupplier.ui
    ${UIDIR}/MainWindow.ui
)

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

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

add_executable(${bmsapp_EXECUTABLE} ${SOURCE_FILES})
target_link_libraries(${bmsapp_EXECUTABLE} Qt5::Core Qt5::Widgets Qt5::Network Qt5::Sql)

mercurial