Skip to content

Commit

Permalink
add rc file
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Feb 3, 2024
1 parent 706c4ac commit 5683ae7
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
cmake_minimum_required(VERSION 3.13)

project(mpv-menu-plugin C)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include(GetGitVersion)
get_git_version(GIT_VERSION SEM_VER)

project(mpv-menu-plugin LANGUAGES C VERSION "${SEM_VER}")
set(CMAKE_C_STANDARD 11)

include(FindPkgConfig)
pkg_search_module(MPV REQUIRED mpv>=0.37.0)

configure_file(${PROJECT_SOURCE_DIR}/menu.rc.in ${PROJECT_BINARY_DIR}/menu.rc @ONLY)

set(CMAKE_SHARED_LIBRARY_PREFIX "")
add_library(menu SHARED
mpv/misc/bstr.c
Expand All @@ -18,6 +25,8 @@ add_library(menu SHARED
src/dialog.c
src/menu.c
src/plugin.c

${PROJECT_BINARY_DIR}/menu.rc
)
set_property(TARGET menu PROPERTY POSITION_INDEPENDENT_CODE ON)

Expand Down
27 changes: 27 additions & 0 deletions cmake/GetGitVersion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
find_package(Git)

function(get_git_version var1 var2)
if(GIT_EXECUTABLE)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --match "[0-9]*.[0-9]*.[0-9]*" --abbrev=8
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE status
OUTPUT_VARIABLE GIT_VERSION
)
if (${status})
set(GIT_VERSION "0.0.0")
else()
string(STRIP ${GIT_VERSION} GIT_VERSION)
string(REGEX REPLACE "-[0-9]+-g" "-" GIT_VERSION ${GIT_VERSION})
endif()
else()
set(GIT_VERSION "0.0.0")
endif()

string(REGEX MATCH "^[0-9]+.[0-9]+.[0-9]+" SEM_VER "${GIT_VERSION}")

message("-- Git Tag: ${GIT_VERSION}, Sem Ver: ${SEM_VER}")

set(${var1} ${GIT_VERSION} PARENT_SCOPE)
set(${var2} ${SEM_VER} PARENT_SCOPE)
endfunction()
32 changes: 32 additions & 0 deletions menu.rc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <winver.h>

#define VERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,0
#define VERSION_STR "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@[email protected]\0"

VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION
PRODUCTVERSION VERSION
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "mpv-menu-plugin\0"
VALUE "ProductName", "mpv-menu-plugin\0"
VALUE "ProductVersion", VERSION_STR
VALUE "FileVersion", VERSION_STR
VALUE "InternalName", "menu\0"
VALUE "OriginalFilename", "menu.dll\0"
VALUE "LegalCopyright", "Copyright (C) 2023-2024 tsl0922\0"
VALUE "Comment", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

0 comments on commit 5683ae7

Please sign in to comment.