Make Windows icon optional
This commit is contained in:
parent
9c97d8722d
commit
ade4565e0c
|
@ -4,7 +4,10 @@
|
||||||
|
|
||||||
# before including this module, LibraryConfig/ApplicationConfig must be included
|
# before including this module, LibraryConfig/ApplicationConfig must be included
|
||||||
|
|
||||||
if(MINGW)
|
option(WINDOWS_RESOURCES_ENABLED "controls Windows resources are enabled" ON)
|
||||||
|
option(WINDOWS_ICON_ENABLED "controls Windows icon is enabled" ON)
|
||||||
|
|
||||||
|
if(MINGW AND WINDOWS_RESOURCES_ENABLED)
|
||||||
# find rc template
|
# find rc template
|
||||||
include(TemplateFinder)
|
include(TemplateFinder)
|
||||||
find_template_file("windows.rc" CPP_UTILITIES RC_TEMPLATE_FILE)
|
find_template_file("windows.rc" CPP_UTILITIES RC_TEMPLATE_FILE)
|
||||||
|
@ -12,31 +15,33 @@ if(MINGW)
|
||||||
# create Windows icon from png with ffmpeg if available
|
# create Windows icon from png with ffmpeg if available
|
||||||
unset(WINDOWS_ICON_PATH)
|
unset(WINDOWS_ICON_PATH)
|
||||||
unset(WINDOWS_ICON_RC_ENTRY)
|
unset(WINDOWS_ICON_RC_ENTRY)
|
||||||
|
if(WINDOWS_ICON_ENABLED)
|
||||||
find_program(FFMPEG_BIN ffmpeg avconv)
|
find_program(FFMPEG_BIN ffmpeg avconv)
|
||||||
if(FFMPEG_BIN)
|
if(FFMPEG_BIN)
|
||||||
if(NOT PNG_ICON_PATH)
|
if(NOT PNG_ICON_PATH)
|
||||||
set(PNG_ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/resources/icons/hicolor/128x128/apps/${META_PROJECT_NAME}.png")
|
set(PNG_ICON_PATH "${CMAKE_CURRENT_SOURCE_DIR}/resources/icons/hicolor/128x128/apps/${META_PROJECT_NAME}.png")
|
||||||
set(USING_DEFAULT_PNG_ICON_PATH true)
|
set(USING_DEFAULT_PNG_ICON_PATH true)
|
||||||
endif()
|
endif()
|
||||||
if(PNG_ICON_NO_CROP)
|
if(PNG_ICON_NO_CROP)
|
||||||
unset(PNG_ICON_CROP)
|
unset(PNG_ICON_CROP)
|
||||||
elseif(NOT PNG_ICON_CROP)
|
elseif(NOT PNG_ICON_CROP)
|
||||||
# default cropping
|
# default cropping
|
||||||
set(PNG_ICON_CROP "iw-20:ih-20:10:10")
|
set(PNG_ICON_CROP "iw-20:ih-20:10:10")
|
||||||
endif()
|
endif()
|
||||||
if(EXISTS "${PNG_ICON_PATH}")
|
if(EXISTS "${PNG_ICON_PATH}")
|
||||||
set(WINDOWS_ICON_PATH "${CMAKE_CURRENT_BINARY_DIR}/resources/${META_PROJECT_NAME}.ico")
|
set(WINDOWS_ICON_PATH "${CMAKE_CURRENT_BINARY_DIR}/resources/${META_PROJECT_NAME}.ico")
|
||||||
set(WINDOWS_ICON_RC_ENTRY "IDI_ICON1 ICON DISCARDABLE \"${WINDOWS_ICON_PATH}\"")
|
set(WINDOWS_ICON_RC_ENTRY "IDI_ICON1 ICON DISCARDABLE \"${WINDOWS_ICON_PATH}\"")
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${WINDOWS_ICON_PATH}"
|
OUTPUT "${WINDOWS_ICON_PATH}"
|
||||||
COMMAND ${FFMPEG_BIN} -y -i "${PNG_ICON_PATH}" -vf crop=${PNG_ICON_CROP},scale=64:64 "${WINDOWS_ICON_PATH}"
|
COMMAND ${FFMPEG_BIN} -y -i "${PNG_ICON_PATH}" -vf crop=${PNG_ICON_CROP},scale=64:64 "${WINDOWS_ICON_PATH}"
|
||||||
)
|
)
|
||||||
message(STATUS "Generating Windows icon from \"${PNG_ICON_PATH}\" via ${FFMPEG_BIN}.")
|
message(STATUS "Generating Windows icon from \"${PNG_ICON_PATH}\" via ${FFMPEG_BIN}.")
|
||||||
elseif(NOT USING_DEFAULT_PNG_ICON_PATH)
|
elseif(NOT USING_DEFAULT_PNG_ICON_PATH)
|
||||||
message(FATAL_ERROR "The specified PNG_ICON_PATH \"${PNG_ICON_PATH}\" is invalid.")
|
message(FATAL_ERROR "The specified PNG_ICON_PATH \"${PNG_ICON_PATH}\" is invalid.")
|
||||||
endif()
|
endif()
|
||||||
unset(USING_DEFAULT_PNG_ICON_PATH)
|
unset(USING_DEFAULT_PNG_ICON_PATH)
|
||||||
endif(FFMPEG_BIN)
|
endif(FFMPEG_BIN)
|
||||||
|
endif()
|
||||||
|
|
||||||
# create Windows rc file from template
|
# create Windows rc file from template
|
||||||
configure_file(
|
configure_file(
|
||||||
|
@ -48,4 +53,4 @@ if(MINGW)
|
||||||
set(CMAKE_RC_COMPILER_INIT windres)
|
set(CMAKE_RC_COMPILER_INIT windres)
|
||||||
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
|
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
|
||||||
enable_language(RC)
|
enable_language(RC)
|
||||||
endif(MINGW)
|
endif()
|
||||||
|
|
Loading…
Reference in New Issue