Better_Software_Header_Mobile Better_Software_Header_Web

Find what you need - explore our website and developer resources

CMake and Qt

cmake_and_qt_front_page

Download PDF:

if(CPUS)
	math(EXPR CPUS "${CPUS} + 1")
	set(BLD_FLAGS "${BLD_FLAGS} -j${CPUS}")
endif()
find_package(somecoollib)
target_link_libraries(main somecoollib)

CMake includes a GUI for configuration; very handy for building debug and release candidates.

cmake_minimum_required(VERSION 3.16) ➀ 

project(helloworld VERSION 1.0.0) ➁

set(CMAKE_CXX_STANDARD 17) ➂
set(CMAKE_CXX_STANDARD_REQUIRED ON) 

set(CMAKE_AUTOMOC TRUE) ➃
set(CMAKE_AUTORCC TRUE) 
set(CMAKE_AUTOUIC TRUE) 

find_package(Qt6 CONFIG REQUIRED COMPONENTS Widgets) ➄

add_executable(helloworld  ➅
   mainwindow.ui 
   mainwindow.cpp 
   main.cpp 
   resources.qrc 
) 

target_link_libraries(helloworld Qt::Widgets) ➆

Tags:

qt