cmake and Qt
curated list of awesome CMake resources
CppCon 2017: Mathieu Ropert “Using Modern CMake Patterns to Enforce a Good Modular Design - Youtube
cmake Visual Studio mapping - cmake-and-visual-studio
cmake-best-practice
DanielPfeifer1
CMake_FAQ
cmake-tutorial
Qt5 mini-cmake-qt project
qt-cmake-template
Building Qt 5 from Git
CMake Useful Variables
cmake-generator-expressions
PACKT cmake-cookbook
target_sources target_sources
CMake Generators
cmake generate
cd <build dir>
cmake -DCMAKE_INSTALL_PREFIX=<install dir> -G "Visual Studio 14 2015 Win64" ..
// VS 2019
cmake-DCMAKE_INSTALL_PREFIX=<install dir> -G "Visual Studio 16 2019" -A x64 ..
// or
cmake -DCMAKE_INSTALL_PREFIX=<install dir> -G "Unix Makefiles" ..
List available generators
cmake --help
cmake build
List all targets
cmake --build . --target help
build <dir> is an existing build directory
cmake --build "." --target <tgt> --config RelWithDebInfo
cmake install
cmake -DBUILD_TYPE=Release -P cmake_install.cmake
cpack (requires install command in CMakeLists.txt)
cpack -C Release --config ./CPackConfig.cmake
Use verbose mode to find errors in a filepath of a component. (Use . for components on root)
cpack --verbose -C Release --config ./CPackConfig.cmake
Transitive Compile Dependency
Private - Needed by me but not my dependers
Public - Needed by me and my dependers
Interface - Needed not by me but my dependers
MOC UIC RCC
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
Iterate over Qt GUI plugins and get the location
foreach(plugin ${Qt5Gui_PLUGINS})
get_target_property(_loc ${plugin} LOCATION)
message("Plugin ${plugin} is at location ${_loc}")
endforeach()
obsolete (add uic and qrc files to source)
qt5_wrap_ui(UIS_HDRS xxx.ui)
qt5_add_resources(QRC_HDRS xxx.qrc)