Sun, 06 Feb 2022 16:52:20 +0100
Initial build and cmake setup
CMakeLists.txt | file | annotate | diff | comparison | revisions | |
src/config.in | file | annotate | diff | comparison | revisions | |
src/main.cpp | file | annotate | diff | comparison | revisions |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CMakeLists.txt Sun Feb 06 16:52:20 2022 +0100 @@ -0,0 +1,84 @@ +# CMakeLists.txt is part of bmsapp +# + +PROJECT(bmsapp) +CMAKE_MINIMUM_REQUIRED( VERSION 3.6 ) +SET(bmsapp_EXECUTABLE "bmsapp") +MESSAGE( STATUS "Building bmsapp" ) + +# 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_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======================================= + +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==================================== + +find_package(Qt5 REQUIRED COMPONENTS Core Widgets) + +# Network PrintSupport Sql 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============================== + +# 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 ) + +# ===== Process other CMakeList.txt's ===== + +set( SOURCE_FILES + ${SRCDIR}/main.cpp +) + +# ===== Build the application ===== + +add_executable(${bmsapp_EXECUTABLE} ${SOURCE_FILES}) +target_link_libraries(${bmsapp_EXECUTABLE} Qt5::Core Qt5::Widgets) +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/config.in Sun Feb 06 16:52:20 2022 +0100 @@ -0,0 +1,6 @@ +#ifndef CONFIG_IN +#define CONFIG_IN + +#define VERSIONSTRING "${bmsapp_VERSION_MAJOR}.${bmsapp_VERSION_MINOR}.${bmsapp_VERSION_PATCH}" + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main.cpp Sun Feb 06 16:52:20 2022 +0100 @@ -0,0 +1,38 @@ +/** + * main.cpp is part of bmsapp. + * + * bmsapp is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * bmsapp is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +#include <QApplication> +#include <QCommandLineParser> +//#include <QLocale> +//#include <QTranslator> + +#include "config.h" + + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + app.setApplicationName( +#ifdef QT_DEBUG + "bmsapp-debug" +#else + "bmsapp" +#endif + ); + app.setApplicationVersion(VERSIONSTRING); + + return app.exec(); +}