Cmake guide and tricks
You’ll never become a better C++ programmer if you can’t work well with cmake. ~Me
General Tips:
- First of all, be careful about the case sensitivity of cmake. All arguments-the things coming between paranthesis- are case sensitive.
- For being able to see the console output (
std::cout
) in your QtCreator environment, you need to addWIN_EXECTUABLE
toFalse
inside theset_target_properties
. - I like this github.io page on the cmake tutorial.
Qt Basic code steps:
project(NAME LANGUAGES CXX)
: you need to specify a name for the project and the language of the source files it includes. cxx is an older name for cpp.find_package(Qt REQUIRED COMPONENTS ...)
: the packages you require the running machine to have installed.qt_add_executable(TARGETNAME .cpp .h)
create target name. Targets are a bundle of resources, libraries that the project requires you to have.set_target_properties(TARGETNAME PROPERTIES WIN32_EXECUTABLE TRUE )
I don’t exactly know what this should do!target_link_libraries(<target>...<item>)
install(<target>... BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
**
This post is licensed under CC BY 4.0 by the author.