cmake_minimum_required(VERSION 3.13)

project(qt_wrap_sources)

# fake moc:
set(QT_MOC_EXECUTABLE /some/path/to/moc)

add_executable(qt_wrap_cpp main.cpp)

qt_wrap_cpp(IGNORED moc_sources moc1.h)
qt_wrap_cpp(IGNORED moc_sources moc2.h PREFIX foo_ EXTENSION bar)

# unfake moc: EXECUTABLE must now be passed for this to work!
unset(QT_MOC_EXECUTABLE)
qt_wrap_cpp(IGNORED moc_sources moc3.h EXECUTABLE /some/other/moc)

message("MOC sources: ${moc_sources}.")
set(binary_path "${CMAKE_CURRENT_BINARY_DIR}")
if (NOT "${binary_path}/moc_moc1.cxx" IN_LIST moc_sources)
  message(SEND_ERROR "qt_wrap_cpp: moc_moc1.cxx not found.")
endif()
if (NOT "${binary_path}/foo_moc2.bar" IN_LIST moc_sources)
  message(SEND_ERROR "qt_wrap_cpp: foo_moc2.bar not found.")
endif()
if (NOT "${binary_path}/moc_moc3.cxx" IN_LIST moc_sources)
  message(SEND_ERROR "qt_wrap_cpp: moc_moc3.cxx not found.")
endif()
