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)
if(WIN32)
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)
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${name})
list(GET "${ARGN}" 0 id)
if(id STREQUAL NOTFOUND)
if(${ARGC} GREATER 1)
set(id ${ARGV1})
else()
string(REPLACE ${resource_root} "" id ${source})
endif()
list(GET "${ARGN}" 1 type)
if(type STREQUAL NOTFOUND)
if(${ARGC} GREATER 2)
set(type ${ARGV2})
else()
set(type RCDATA)
endif()
file(SHA512 "${source}" hash)
@ -105,8 +107,8 @@ endfunction()
# Second, register all resources.
if(WIN32)
add_resource(win32/icon.ico RT_ICON_GROUP APP_ICON)
add_resource(win32/manifest.xml RT_MANIFEST APP_MANIFEST)
add_resource(win32/icon.ico APP_ICON ICON)
add_resource(win32/manifest.xml APP_MANIFEST RT_MANIFEST)
elseif(APPLE)
add_iconset (cocoa/AppIcon.iconset)
add_xib (cocoa/MainMenu.xib)