Last active
August 29, 2015 14:07
-
-
Save ashwin/4ef99734df12e48e4fa4 to your computer and use it in GitHub Desktop.
Sample CMakeLists.txt to compile a program that uses Qt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check if Qt4 is present | |
find_package(Qt4 REQUIRED) | |
# Add Qt headers for compiling | |
include( | |
${QT_USE_FILE} | |
) | |
# Add Qt definitions for compilation | |
add_definitions( | |
${QT_DEFINITIONS} | |
) | |
# Your *.h files that need to be processed by MOC | |
qt4_wrap_cpp( | |
FOOBAR_HEADERS_MOC | |
FooForm.h | |
BarForm.h | |
) | |
# Your *.ui files | |
qt4_wrap_ui( | |
FOOBAR_HEADERS_UI | |
FooForm.ui | |
BarForm.ui | |
) | |
# Your *.qrc files | |
qt4_add_resources( | |
FOOBAR_HEADERS_QRC | |
Foo.qrc | |
Bar.qrc | |
) | |
# Add MOC, UI and QRC generated headers for compilation | |
add_executable( | |
foobar | |
main.cpp | |
star.cpp | |
${FOOBAR_HEADERS_MOC} | |
${FOOBAR_HEADERS_UI} | |
${FOOBAR_HEADERS_QRC} | |
) | |
# Add Qt libraries for linking | |
target_link_libraries( | |
foobar | |
${QT_LIBRARIES} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment