CMake: correctly define and use the add_resource function.

pull/10/head
whitequark 2016-05-18 11:22:07 +00:00
parent fbc5bfc27f
commit 4b0dc5819b
1 changed files with 9 additions and 7 deletions

View File

@ -3,17 +3,19 @@ set(resource_root ${CMAKE_CURRENT_SOURCE_DIR}/)
set(resource_list) set(resource_list)
if(WIN32) if(WIN32)
set(rc_file ${CMAKE_CURRENT_BINARY_DIR}/resources.rc) set(rc_file ${CMAKE_CURRENT_BINARY_DIR}/resources.rc)
file(WRITE ${rc_file} "// Autogenerated; do not edit\n") file(WRITE ${rc_file} "// Autogenerated; do not edit\n#include<windows.h>\n")
function(add_resource name) function(add_resource name)
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${name}) set(source ${CMAKE_CURRENT_SOURCE_DIR}/${name})
list(GET "${ARGN}" 0 id) if(${ARGC} GREATER 1)
if(id STREQUAL NOTFOUND) set(id ${ARGV1})
else()
string(REPLACE ${resource_root} "" id ${source}) string(REPLACE ${resource_root} "" id ${source})
endif() endif()
list(GET "${ARGN}" 1 type) if(${ARGC} GREATER 2)
if(type STREQUAL NOTFOUND) set(type ${ARGV2})
else()
set(type RCDATA) set(type RCDATA)
endif() endif()
file(SHA512 "${source}" hash) file(SHA512 "${source}" hash)
@ -105,8 +107,8 @@ endfunction()
# Second, register all resources. # Second, register all resources.
if(WIN32) if(WIN32)
add_resource(win32/icon.ico RT_ICON_GROUP APP_ICON) add_resource(win32/icon.ico APP_ICON ICON)
add_resource(win32/manifest.xml RT_MANIFEST APP_MANIFEST) add_resource(win32/manifest.xml APP_MANIFEST RT_MANIFEST)
elseif(APPLE) elseif(APPLE)
add_iconset (cocoa/AppIcon.iconset) add_iconset (cocoa/AppIcon.iconset)
add_xib (cocoa/MainMenu.xib) add_xib (cocoa/MainMenu.xib)