[CMake] VS2010 tries to compile a file with *.res extension when its copied

David Cole david.cole at kitware.com
Thu Jan 20 22:57:27 EST 2011


Is tha with 2.8.3 or 2.8.4-rc1?

On Thursday, January 20, 2011,  <Aaron_Wright at selinc.com> wrote:
> I know I've asked this before, but now I've narrowed it down a bit and I
> have an example. This copies a *.res file to the binary directory where
> presumably the executable can find it. The executable has that file as a
> source file to hook up the dependency, and the copied file has the
> HEADER_FILE_ONLY property set. Yet, somehow VS2010 is still trying to
> compile en.res. I even tried setting the source and destination en.res
> files to HEADER_FILE_ONLY, but that didn't fix it. Removing the
> ADD_CUSTOM_COMMAND that does the copy fixes the problem. Why is this
> broken? FYI, it worked fine in VS2008.
>
> CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
>
> PROJECT(cmake_res_bug)
>
> SET(RESOURCE_FILE "${PROJECT_SOURCE_DIR}/resources/en.res")
>
> GET_FILENAME_COMPONENT(RESOURCE_FILE_BASENAME "${RESOURCE_FILE}" NAME)
> SET(LOCAL_RESOURCE_FILE
> "${PROJECT_BINARY_DIR}/resources/${RESOURCE_FILE_BASENAME}")
>
> ADD_CUSTOM_COMMAND(
>    OUTPUT "${PROJECT_BINARY_DIR}/resources/${RESOURCE_FILE_BASENAME}"
>    COMMAND ${CMAKE_COMMAND} -E make_directory
> "${PROJECT_BINARY_DIR}/resources"
>    COMMAND ${CMAKE_COMMAND} -E copy "${RESOURCE_FILE}"
> "${PROJECT_BINARY_DIR}/resources"
>    DEPENDS "${RESOURCE_FILE}"
>    COMMENT "Localizing ${RESOURCE_FILE_BASENAME}")
>
> SET_SOURCE_FILES_PROPERTIES(
>    "${LOCAL_RESOURCE_FILE}"
>    PROPERTIES HEADER_FILE_ONLY TRUE)
>
> INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
>
> ADD_EXECUTABLE(
>    ${PROJECT_NAME}
>    "${PROJECT_SOURCE_DIR}/src/main.cpp"
>    "${LOCAL_RESOURCE_FILE}")
>
> ---
> Aaron Wright
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>


More information about the CMake mailing list