[CMake] VS2010 tries to compile a file with *.res extension when its copied
Aaron_Wright at selinc.com
Aaron_Wright at selinc.com
Thu Jan 20 17:31:11 EST 2011
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
More information about the CMake
mailing list