summaryrefslogtreecommitdiffstats
path: root/Tests/Qt4Targets/CMakeLists.txt
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-02-26 22:27:22 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-06-03 08:07:02 (GMT)
commit9ce60ff509c4ff27fe861fc5b2080f50897a68c4 (patch)
tree36d4973eef51233452e1ebd822f395647868f25a /Tests/Qt4Targets/CMakeLists.txt
parenta4d8c64d10105fd4448ffde6a5d2fb74c1bb4f57 (diff)
downloadCMake-9ce60ff509c4ff27fe861fc5b2080f50897a68c4.zip
CMake-9ce60ff509c4ff27fe861fc5b2080f50897a68c4.tar.gz
CMake-9ce60ff509c4ff27fe861fc5b2080f50897a68c4.tar.bz2
Qt4Macros: Allow specifying a TARGET in invokations of macros.
That will allow things like this: find_package(Qt4) qt4_generate_moc(myfile.h moc_myfile.cpp TARGET foo) # Note, foo target doesn't # exist until below. add_library(foo ...) The qt4_generate_moc call would use the INCLUDE_DIRECTORIES from the foo target using generator expressions. Currently it reads the INCLUDE_DIRECTORIES directory property, meaning that include_directories() is required. Support for the TARGET is also added to qt4_wrap_cpp, but not qt4_automoc, as that is deprecated in favor of the AUTOMOC target property. The moc tool reports failure if the Q_INTERFACES macro is used with an argument which has not appeared with Q_DECLARE_INTERFACE, so that is the basis of the unit test. The command line arguments are now always written to a file, which is passed to moc as the @atfile. This was already the case on Windows, but now it is used everywhere. The reason for that is that it is not currently possible to expand the list of includes from a target directly in a add_custom_command invokation (though that may become possible in the future). There is not a big disadvantage to using the file anyway on unix, so having one code path instead of two is also a motivation.
Diffstat (limited to 'Tests/Qt4Targets/CMakeLists.txt')
-rw-r--r--Tests/Qt4Targets/CMakeLists.txt17
1 files changed, 17 insertions, 0 deletions
diff --git a/Tests/Qt4Targets/CMakeLists.txt b/Tests/Qt4Targets/CMakeLists.txt
index d0c9c66..af9fc3f 100644
--- a/Tests/Qt4Targets/CMakeLists.txt
+++ b/Tests/Qt4Targets/CMakeLists.txt
@@ -19,3 +19,20 @@ if (WIN32)
target_link_libraries(activeqtexe Qt4::QAxServer Qt4::QtGui)
endif()
endif()
+
+qt4_generate_moc(main_gen_test.cpp
+ "${CMAKE_CURRENT_BINARY_DIR}/main_gen_test.moc"
+ TARGET Qt4GenerateMacroTest
+)
+add_executable(Qt4GenerateMacroTest WIN32 main_gen_test.cpp "${CMAKE_CURRENT_BINARY_DIR}/main_gen_test.moc")
+set_property(TARGET Qt4GenerateMacroTest PROPERTY AUTOMOC OFF)
+target_include_directories(Qt4GenerateMacroTest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface")
+target_link_libraries(Qt4GenerateMacroTest Qt4::QtGui)
+
+qt4_wrap_cpp(moc_file mywrapobject.h
+ TARGET Qt4WrapMacroTest
+)
+add_executable(Qt4WrapMacroTest WIN32 main_wrap_test.cpp ${moc_file})
+set_property(TARGET Qt4WrapMacroTest PROPERTY AUTOMOC OFF)
+target_include_directories(Qt4WrapMacroTest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface")
+target_link_libraries(Qt4WrapMacroTest Qt4::QtGui)