Skip to content

Instantly share code, notes, and snippets.

@Trass3r
Created September 27, 2017 09:39
Show Gist options
  • Select an option

  • Save Trass3r/a4bf695e1eba4978b113d4652ebc5e2a to your computer and use it in GitHub Desktop.

Select an option

Save Trass3r/a4bf695e1eba4978b113d4652ebc5e2a to your computer and use it in GitHub Desktop.
# put generated files into a separate VS folder
source_group("Generated Files" "(qrc_.+\\.cpp)|(.+_automoc\\.cpp)|(ui_.+\\.h)")
# for finding generated headers in CMAKE_CURRENT_BINARY_DIR
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# run moc automatically when needed
set(CMAKE_AUTOMOC ON)
# imported targets are created for each Qt module
find_package(Qt5Widgets)
##### create target #####
set(SRCs main.cpp mainwindow.cpp)
set(HDRs mainwindow.h)
set(UIs mainwindow.ui)
set(RSCs projectname.qrc)
# run uic and rcc
qt5_wrap_ui(uiheaders ${UIs})
qt5_add_resources(rccfiles ${RSCs})
add_executable(ProjectName ${SRCs} ${HDRs} ${uiheaders} ${rccfiles})
target_link_libraries(ProjectName Qt5::Widgets)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment