CMakeLists.txt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. cmake_minimum_required(VERSION 2.8)
  2. project(QtAutomoc)
  3. find_package(Qt4 REQUIRED)
  4. include(UseQt4)
  5. include_directories(${CMAKE_CURRENT_BINARY_DIR})
  6. add_definitions(-DFOO -DSomeDefine="Barx")
  7. # enable relaxed mode so automoc can handle all the special cases:
  8. set(CMAKE_AUTOMOC_RELAXED_MODE TRUE)
  9. # create an executable and two library targets, each requiring automoc:
  10. add_library(codeeditorLib STATIC codeeditor.cpp)
  11. add_library(privateSlot OBJECT private_slot.cpp)
  12. add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp
  13. xyz.cpp yaf.cpp $<TARGET_OBJECTS:privateSlot>)
  14. set_target_properties(foo codeeditorLib privateSlot PROPERTIES AUTOMOC TRUE)
  15. include(GenerateExportHeader)
  16. # The order is relevant here. B depends on A, and B headers depend on A
  17. # headers both subdirectories use CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE and we
  18. # test that CMAKE_AUTOMOC successfully reads the include directories
  19. # for the build interface from those targets. There has previously been
  20. # a bug where caching of the include directories happened before
  21. # extracting the includes to pass to moc.
  22. add_subdirectory(Bdir)
  23. add_subdirectory(Adir)
  24. add_library(libC SHARED libC.cpp)
  25. set_target_properties(libC PROPERTIES AUTOMOC TRUE)
  26. generate_export_header(libC)
  27. target_link_libraries(libC LINK_PUBLIC libB)
  28. target_link_libraries(foo codeeditorLib ${QT_LIBRARIES} libC)
  29. add_library(empty STATIC empty.cpp)
  30. set_target_properties(empty PROPERTIES AUTOMOC TRUE)
  31. target_link_libraries(empty no_link_language)
  32. add_library(no_link_language STATIC empty.h)
  33. set_target_properties(no_link_language PROPERTIES AUTOMOC TRUE)