Skip to content

Commit 5164d88

Browse files
committed
Use custom rules for RC files with x64-Clang configs in VS
1 parent 3f1efc7 commit 5164d88

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

src/CMakeLists.txt

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,17 @@ if(WIN32)
4848

4949
if(BUILD_SHARED_LIBS)
5050
function(add_version_rc target)
51-
add_library(${target}_version OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/../res/${target}_version.rc)
51+
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target}_version.rc.res
52+
COMMAND ${CMAKE_RC_COMPILER} ${CMAKE_RC_FLAGS} $<$<CONFIG:Debug>:${CMAKE_RC_FLAGS_DEBUG}>
53+
"/fo${CMAKE_CURRENT_BINARY_DIR}/${target}_version.rc.res"
54+
"${CMAKE_CURRENT_SOURCE_DIR}/../res/${target}_version.rc"
55+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../res/${target}_version.rc")
56+
add_custom_target(build_${target}_version_rc ALL
57+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${target}_version.rc.res)
58+
59+
add_library(${target}_version OBJECT ${CMAKE_CURRENT_BINARY_DIR}/${target}_version.rc.res)
60+
set_target_properties(${target}_version PROPERTIES LINKER_LANGUAGE CXX)
61+
add_dependencies(${target}_version build_${target}_version_rc)
5262
target_link_libraries(${target} PRIVATE ${target}_version)
5363
endfunction()
5464
endif()
@@ -193,7 +203,17 @@ if(GRAPHQL_BUILD_CLIENTGEN)
193203
endif()
194204

195205
if(WIN32)
196-
add_library(clientgen_version OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/../res/ClientGen.rc)
206+
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ClientGen.rc.res
207+
COMMAND ${CMAKE_RC_COMPILER} ${CMAKE_RC_FLAGS} $<$<CONFIG:Debug>:${CMAKE_RC_FLAGS_DEBUG}>
208+
"/fo${CMAKE_CURRENT_BINARY_DIR}/ClientGen.rc.res"
209+
"${CMAKE_CURRENT_SOURCE_DIR}/../res/ClientGen.rc"
210+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../res/ClientGen.rc")
211+
add_custom_target(build_clientgen_rc ALL
212+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ClientGen.rc.res)
213+
214+
add_library(clientgen_version OBJECT ${CMAKE_CURRENT_BINARY_DIR}/ClientGen.rc.res)
215+
set_target_properties(clientgen_version PROPERTIES LINKER_LANGUAGE CXX)
216+
add_dependencies(clientgen_version build_clientgen_rc)
197217
target_link_libraries(clientgen PRIVATE clientgen_version)
198218
endif()
199219

@@ -231,7 +251,17 @@ if(GRAPHQL_BUILD_SCHEMAGEN)
231251
endif()
232252

233253
if(WIN32)
234-
add_library(schemagen_version OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/../res/SchemaGen.rc)
254+
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SchemaGen.rc.res
255+
COMMAND ${CMAKE_RC_COMPILER} ${CMAKE_RC_FLAGS} $<$<CONFIG:Debug>:${CMAKE_RC_FLAGS_DEBUG}>
256+
"/fo${CMAKE_CURRENT_BINARY_DIR}/SchemaGen.rc.res"
257+
"${CMAKE_CURRENT_SOURCE_DIR}/../res/SchemaGen.rc"
258+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../res/SchemaGen.rc")
259+
add_custom_target(build_schemagen_rc ALL
260+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/SchemaGen.rc.res)
261+
262+
add_library(schemagen_version OBJECT ${CMAKE_CURRENT_BINARY_DIR}/SchemaGen.rc.res)
263+
set_target_properties(schemagen_version PROPERTIES LINKER_LANGUAGE CXX)
264+
add_dependencies(schemagen_version build_schemagen_rc)
235265
target_link_libraries(schemagen PRIVATE schemagen_version)
236266
endif()
237267

0 commit comments

Comments
 (0)