I'm trying to link a compiled .res file with cmake but I can't seem to find out much info on how to do it.
The closest I have got is
SET(RESOURCE_FILE resource.res)
file(GLOB src_files
"src/*.h"
"src/*.cpp"
"${RESOURCE_FILE}"
)
add_executable(exename ${src_files})
and then manually linking the .res file thru the IDE (i.e. in visual studio dropping the .res file in the Linker additional dependencies). This means I have to reset the additional dependency every time I change the cmake file. Surely there is a better way than this
Forgive my inexperience with cmake, any help would be appreciated.
Default lib extension is a bit sticky one, but you can do as follows:
# ...
ADD_EXECUTABLE( FOO ${FOO_SRCS} )
TARGET_LINK_LIBRARIES( FOO ${FOO_LIBS} )
SET( FOO_LINKFLAGS ${CMAKE_CURRENT_SOURCE_DIR}/foo.res )
SET_TARGET_PROPERTIES( FOO PROPERTIES LINK_FLAGS ${FOO_LINKFLAGS} )
which would show up in MSVC as additional [linker] options (instead of dependencies). Hope that helps.
If there are other LINK_FLAGS
defined, you may need to first store them in the FOO_LINKFLAGS
and then append new ones.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With