I'm using cmake 2.4.2 on windows, with Visual Studio 2005 Express Edition.

I have a Qt class in a subdirectory from my top-level project.  I don't want to 
build the class as a library, but rather include the source code in the 
top-level project.  But I can't get moc to run on the file in the subdirectory.

A snippet of my CMakeLists.txt looks like this:

SET(FIXED_ASPECT_IMAGE_DIR 
${my_project_SOURCE_DIR}/src/fixed_aspect_image_win32)

GET_FILENAME_COMPONENT(infile ${FIXED_ASPECT_IMAGE_DIR}/FixedAspectImage.h 
ABSOLUTE)
MESSAGE(STATUS "infile = ${infile}")

MESSAGE(STATUS "moc = ${QT_MOC_EXECUTABLE}")

IF (EXISTS ${infile})
    MESSAGE(STATUS "infile exists")
ENDIF (EXISTS ${infile})

ADD_CUSTOM_COMMAND(OUTPUT ${FIXED_ASPECT_IMAGE_DIR}/FixedAspectImage.moc
   COMMAND ${QT_MOC_EXECUTABLE}
   ARGS ${moc_includes} -o ${FIXED_ASPECT_IMAGE_DIR}/FixedAspectImage.moc 
${infile}
   DEPENDS ${infile})
ADD_FILE_DEPENDENCIES(${infile} ${FIXED_ASPECT_IMAGE_DIR}/FixedAspectImage.moc)




The project is "my_project", and the above CMakeLists.txt is in the src 
subdirectory.  The FixedAspectImage class is in the fixed_aspect_image_win32 
directory (below the src directory).  I've tried QT4_AUTOMOC, but this puts the 
moc file in the src subdirectory, not in fixed_aspect_image_win32 (this causes 
the #include "FixedAspectImage.moc" line to not find the .moc file).

I tried QT4_GENERATE_MOC, but no rule to generate the moc file was getting 
created.  So I copied the ADD_CUSTOM_COMMAND from QT4_GENERATE_MOC, and this 
still doesn't generate the rule.  I'm getting the "infile exists" status 
message, and the moc executable is pointing to the right place.  I can run the 
moc command from the command line just fine.

Other source files in the src directory are getting moc rules (using 
QT4_AUTOMOC for those), and moc is in fact run for them.

Why can't I get the moc to run on a file in a subdirectory?  Or how can I get 
the QT4_AUTOMOC to output the file in the same place as the header file?

Incidentally, I'm not able to build Qt applications out of the source tree, and 
it's the same sort of problem.  The moc files are generated in the build 
directory, causing the #include "foo.moc" lines to not find the .moc files.

In addition, I can get this to work on Linux just fine with the 
QT4_GENERATE_MOC command.

Regards,
Patrick
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to