Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version info on Windows for DLLs/Exe #3054

Merged
merged 1 commit into from
May 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion cmake/pcl_targets.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
include(${PROJECT_SOURCE_DIR}/cmake/pcl_utils.cmake)

# Store location of current dir, because value of CMAKE_CURRENT_LIST_DIR is
# set to the directory where a function is used, not where a function is defined
set(_PCL_TARGET_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR})

###############################################################################
# Add an option to build a subsystem or not.
# _var The name of the variable to store the option in.
Expand Down Expand Up @@ -174,6 +178,25 @@ macro(PCL_SUBSUBSYS_DEPEND _var _parent _name)
endif()
endmacro()

###############################################################################
# Adds version information to executable/library in form of a version.rc. This works only with MSVC.
#
# _name The library name.
##
function(PCL_ADD_VERSION_INFO _name)
if(MSVC)
string(REPLACE "." "," VERSION_INFO_VERSION_WITH_COMMA ${PCL_VERSION})
if (SUBSUBSYS_DESC)
set(VERSION_INFO_DISPLAY_NAME ${SUBSUBSYS_DESC})
else()
set(VERSION_INFO_DISPLAY_NAME ${SUBSYS_DESC})
endif()
set(VERSION_INFO_ICON_PATH "${_PCL_TARGET_CMAKE_DIR}/images/pcl.ico")
configure_file(${_PCL_TARGET_CMAKE_DIR}/version.rc.in ${PROJECT_BINARY_DIR}/${_name}_version.rc @ONLY)
target_sources(${_name} PRIVATE ${PROJECT_BINARY_DIR}/${_name}_version.rc)
endif()
endfunction()

###############################################################################
# Add a set of include files to install.
# _component The part of PCL that the install files belong to.
Expand All @@ -197,6 +220,7 @@ function(PCL_ADD_LIBRARY _name)
cmake_parse_arguments(ADD_LIBRARY_OPTION "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

add_library(${_name} ${PCL_LIB_TYPE} ${ADD_LIBRARY_OPTION_SOURCES})
PCL_ADD_VERSION_INFO(${_name})
target_compile_features(${_name} PUBLIC ${PCL_CXX_COMPILE_FEATURES})
# must link explicitly against boost.
target_link_libraries(${_name} ${Boost_LIBRARIES})
Expand Down Expand Up @@ -242,6 +266,7 @@ function(PCL_CUDA_ADD_LIBRARY _name)
else()
cuda_add_library(${_name} ${PCL_LIB_TYPE} ${ADD_LIBRARY_OPTION_SOURCES})
endif()
PCL_ADD_VERSION_INFO(${_name})

# must link explicitly against boost.
target_link_libraries(${_name} ${Boost_LIBRARIES})
Expand Down Expand Up @@ -275,7 +300,7 @@ function(PCL_ADD_EXECUTABLE _name)
else()
add_executable(${_name} ${ADD_LIBRARY_OPTION_SOURCES})
endif()

PCL_ADD_VERSION_INFO(${_name})
# must link explicitly against boost.
if(UNIX AND NOT ANDROID)
target_link_libraries(${_name} ${Boost_LIBRARIES} pthread m ${CLANG_LIBRARIES})
Expand Down Expand Up @@ -321,6 +346,8 @@ function(PCL_CUDA_ADD_EXECUTABLE _name)

REMOVE_VTK_DEFINITIONS()
cuda_add_executable(${_name} ${ADD_LIBRARY_OPTION_SOURCES})
PCL_ADD_VERSION_INFO(${_name})

# must link explicitly against boost.
target_link_libraries(${_name} ${Boost_LIBRARIES})

Expand Down
44 changes: 44 additions & 0 deletions cmake/version.rc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <winres.h>

#ifndef _DEBUG
#define VER_DEBUG 0
#else
#define VER_DEBUG VS_FF_DEBUG
#endif

IDI_ICON1 ICON "@VERSION_INFO_ICON_PATH@"

VS_VERSION_INFO VERSIONINFO
FILEVERSION @VERSION_INFO_VERSION_WITH_COMMA@
PRODUCTVERSION @VERSION_INFO_VERSION_WITH_COMMA@
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS VER_DEBUG
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "Open Perception Foundation"
VALUE "FileDescription", "@VERSION_INFO_DISPLAY_NAME@"
VALUE "FileVersion", "@PCL_VERSION_PRETTY@"
VALUE "LegalCopyright", "�Open Perception Foundation. All rights reserved."
taketwo marked this conversation as resolved.
Show resolved Hide resolved
VALUE "ProductName", "Point Cloud Library"
VALUE "ProductVersion", "@PCL_VERSION_PRETTY@"
END
END

BLOCK "VarFileInfo"
BEGIN
/* The following line should only be modified for localized versions. */
/* It consists of any number of WORD,WORD pairs, with each pair */
/* describing a language,codepage combination supported by the file. */
/* */
/* For example, a file might have values "0x409,1252" indicating that it */
/* supports English language (0x409) in the Windows ANSI codepage (1252). */

VALUE "Translation", 0x409, 1252
END
END