Sun, 06 Feb 2022 16:52:20 +0100
Initial build and cmake setup
# 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)