cmake_minimum_required(VERSION 2.8.8) project(cmake_example) # Show message on Linux platform if (${CMAKE_SYSTEM_NAME} MATCHES Linux) message("Good choice, bro!") endif() # Tell CMake to run moc when necessary: set(CMAKE_AUTOMOC ON) # As moc files are generated in the binary dir, # tell CMake to always look for includes there: set(CMAKE_INCLUDE_CURRENT_DIR ON) # Widgets finds its own dependencies. find_package(Qt5Widgets REQUIRED) add_executable(myproject main.cpp mainwindow.cpp) qt5_use_modules(myproject Widgets)