mirror of
https://github.com/opencv/opencv.git
synced 2024-11-27 12:40:05 +08:00
build: added VERSIONINFO resource
This commit is contained in:
parent
68d01972fe
commit
db35e13b46
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -31,6 +31,8 @@
|
||||
*.py text
|
||||
*.qrc text
|
||||
*.qss text
|
||||
*.rc text
|
||||
*.rc.in text
|
||||
*.S text
|
||||
*.sbt text
|
||||
*.scala text
|
||||
|
@ -800,11 +800,35 @@ macro(_ocv_create_module)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(WIN32 AND BUILD_SHARED_LIBS AND NOT OPENCV_VS_VERSIONINFO_SKIP)
|
||||
if(DEFINED OPENCV_VS_VERSIONINFO_FILE)
|
||||
set(_VS_VERSION_FILE "${OPENCV_VS_VERSIONINFO_FILE}")
|
||||
elseif(DEFINED OPENCV_VS_VERSIONINFO_${the_module}_FILE)
|
||||
set(_VS_VERSION_FILE "${OPENCV_VS_VERSIONINFO_${the_module}_FILE")
|
||||
elseif(NOT OPENCV_VS_VERSIONINFO_SKIP_GENERATION)
|
||||
set(_VS_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/vs_version.rc")
|
||||
ocv_generate_vs_version_file("${_VS_VERSION_FILE}"
|
||||
NAME "${the_module}"
|
||||
FILEDESCRIPTION "OpenCV module: ${OPENCV_MODULE_${the_module}_DESCRIPTION}"
|
||||
INTERNALNAME "${the_module}${OPENCV_DLLVERSION}"
|
||||
ORIGINALFILENAME "${the_module}${OPENCV_DLLVERSION}.dll"
|
||||
)
|
||||
endif()
|
||||
if(_VS_VERSION_FILE)
|
||||
if(NOT EXISTS "${_VS_VERSION_FILE}")
|
||||
message(STATUS "${the_module}: Required .rc file is missing: ${_VS_VERSION_FILE}")
|
||||
endif()
|
||||
source_group("Src" FILES "${_VS_VERSION_FILE}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
source_group("Include" FILES "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp")
|
||||
source_group("Src" FILES "${${the_module}_pch}")
|
||||
ocv_add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES}
|
||||
"${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp"
|
||||
${${the_module}_pch} ${sub_objs})
|
||||
${${the_module}_pch} ${sub_objs}
|
||||
${_VS_VERSION_FILE}
|
||||
)
|
||||
|
||||
if (cuda_objs)
|
||||
target_link_libraries(${the_module} ${cuda_objs})
|
||||
|
@ -1128,3 +1128,49 @@ macro(ocv_add_testdata basedir dest_subdir)
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(ocv_generate_vs_version_file DESTINATION)
|
||||
cmake_parse_arguments(VS_VER "" "NAME;FILEDESCRIPTION;FILEVERSION;INTERNALNAME;COPYRIGHT;ORIGINALFILENAME;PRODUCTNAME;PRODUCTVERSION;COMMENTS;FILEVERSION_QUAD;PRODUCTVERSION_QUAD" "" ${ARGN})
|
||||
|
||||
macro(__vs_ver_update_variable name)
|
||||
if(VS_VER_NAME AND DEFINED OPENCV_${VS_VER_NAME}_VS_VER_${name})
|
||||
set(OPENCV_VS_VER_${name} "${OPENCV_${VS_VER_NAME}_VS_VER_${name}}")
|
||||
elseif(VS_VER_${name})
|
||||
set(OPENCV_VS_VER_${name} "${VS_VER_${name}}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
__vs_ver_update_variable(FILEVERSION_QUAD)
|
||||
__vs_ver_update_variable(PRODUCTVERSION_QUAD)
|
||||
|
||||
macro(__vs_ver_update_str_variable name)
|
||||
if(VS_VER_NAME AND DEFINED OPENCV_${VS_VER_NAME}_VS_VER_${name})
|
||||
set(OPENCV_VS_VER_${name}_STR "${OPENCV_${VS_VER_NAME}_VS_VER_${name}}")
|
||||
elseif(VS_VER_${name})
|
||||
set(OPENCV_VS_VER_${name}_STR "${VS_VER_${name}}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
__vs_ver_update_str_variable(FILEDESCRIPTION)
|
||||
__vs_ver_update_str_variable(FILEVERSION)
|
||||
__vs_ver_update_str_variable(INTERNALNAME)
|
||||
__vs_ver_update_str_variable(COPYRIGHT)
|
||||
__vs_ver_update_str_variable(ORIGINALFILENAME)
|
||||
__vs_ver_update_str_variable(PRODUCTNAME)
|
||||
__vs_ver_update_str_variable(PRODUCTVERSION)
|
||||
__vs_ver_update_str_variable(COMMENTS)
|
||||
|
||||
if(OPENCV_VS_VER_COPYRIGHT_STR)
|
||||
set(OPENCV_VS_VER_HAVE_COPYRIGHT_STR 1)
|
||||
else()
|
||||
set(OPENCV_VS_VER_HAVE_COPYRIGHT_STR 0)
|
||||
endif()
|
||||
|
||||
if(OPENCV_VS_VER_COMMENTS_STR)
|
||||
set(OPENCV_VS_VER_HAVE_COMMENTS_STR 1)
|
||||
else()
|
||||
set(OPENCV_VS_VER_HAVE_COMMENTS_STR 0)
|
||||
endif()
|
||||
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/vs_version.rc.in" "${DESTINATION}" @ONLY)
|
||||
endmacro()
|
||||
|
@ -16,3 +16,10 @@ set(OPENCV_LIBVERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_
|
||||
# create a dependency on version file
|
||||
# we never use output of the following command but cmake will rerun automatically if the version file changes
|
||||
configure_file("${OPENCV_VERSION_FILE}" "${CMAKE_BINARY_DIR}/junk/version.junk" COPYONLY)
|
||||
|
||||
ocv_update(OPENCV_VS_VER_FILEVERSION_QUAD "${OPENCV_VERSION_MAJOR},${OPENCV_VERSION_MINOR},${OPENCV_VERSION_PATCH},0")
|
||||
ocv_update(OPENCV_VS_VER_PRODUCTVERSION_QUAD "${OPENCV_VERSION_MAJOR},${OPENCV_VERSION_MINOR},${OPENCV_VERSION_PATCH},0")
|
||||
ocv_update(OPENCV_VS_VER_FILEVERSION_STR "${OPENCV_VERSION}")
|
||||
ocv_update(OPENCV_VS_VER_PRODUCTVERSION_STR "${OPENCV_VERSION}")
|
||||
ocv_update(OPENCV_VS_VER_PRODUCTNAME_STR "OpenCV library")
|
||||
ocv_update(OPENCV_VS_VER_COMMENTS_STR "http://opencv.org/")
|
||||
|
38
cmake/templates/vs_version.rc.in
Normal file
38
cmake/templates/vs_version.rc.in
Normal file
@ -0,0 +1,38 @@
|
||||
#include <winver.h>
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION @OPENCV_VS_VER_FILEVERSION_QUAD@
|
||||
PRODUCTVERSION @OPENCV_VS_VER_PRODUCTVERSION_QUAD@
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 1
|
||||
#else
|
||||
FILEFLAGS 0
|
||||
#endif
|
||||
FILEOS VOS__WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE 0
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "@OPENCV_VS_VER_FILEDESCRIPTION_STR@\0"
|
||||
VALUE "FileVersion", "@OPENCV_VS_VER_FILEVERSION_STR@\0"
|
||||
VALUE "InternalName", "@OPENCV_VS_VER_INTERNALNAME_STR@\0"
|
||||
#if @OPENCV_VS_VER_HAVE_COPYRIGHT_STR@
|
||||
VALUE "LegalCopyright", "@OPENCV_VS_VER_COPYRIGHT_STR@\0"
|
||||
#endif
|
||||
VALUE "OriginalFilename", "@OPENCV_VS_VER_ORIGINALFILENAME_STR@\0"
|
||||
VALUE "ProductName", "@OPENCV_VS_VER_PRODUCTNAME_STR@\0"
|
||||
VALUE "ProductVersion", "@OPENCV_VS_VER_PRODUCTVERSION_STR@\0"
|
||||
#if @OPENCV_VS_VER_HAVE_COMMENTS_STR@
|
||||
VALUE "Comments", "@OPENCV_VS_VER_COMMENTS_STR@\0"
|
||||
#endif
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x0409, 1252
|
||||
END
|
||||
END
|
Loading…
Reference in New Issue
Block a user