Add "SOVERSION" as suffix to shared libraries for mingw-w64 targets

* Also enable the "lib" prefix which CMake would add by default again; it
  has only been removed to preserve compatibility with qmake when switching
  from qmake to CMake
* None of these changes are enabled by default to preserve compatibility
This commit is contained in:
Martchus 2020-07-04 14:43:26 +02:00
parent 6ed057b932
commit b03332f37a
3 changed files with 28 additions and 11 deletions

View File

@ -15,10 +15,10 @@ if (NOT "${META_PROJECT_TYPE}" STREQUAL "application")
)
endif ()
# set the windows extension to "exe", this is required by the Windows-specific WindowsResources module
if (WIN32)
set(WINDOWS_EXT "exe")
endif (WIN32)
# set the windows extension to "exe", this is required by the mingw-w64-specific WindowsResources module
if (MINGW)
set(WINDOWS_EXT ".exe")
endif ()
# define relevant files
set(ALL_FILES
@ -183,7 +183,7 @@ if (MINGW
add_custom_target(
${META_PROJECT_NAME}_run
COMMAND "${CPP_UTILITIES_SOURCE_DIR}/scripts/wine.sh"
"${CMAKE_CURRENT_BINARY_DIR}/${META_PROJECT_NAME}.${WINDOWS_EXT}" ${RUNTIME_LIBRARY_PATH})
"${CMAKE_CURRENT_BINARY_DIR}/${META_PROJECT_NAME}${WINDOWS_EXT}" ${RUNTIME_LIBRARY_PATH})
add_dependencies(${META_PROJECT_NAME}_run ${META_PROJECT_NAME})
endif ()
endif ()

View File

@ -20,6 +20,11 @@ if ((NOT "${META_PROJECT_TYPE}" STREQUAL "library")
)
endif ()
# add option for enabling versioned mingw-w64 libraries (disabled by default to preserve compatibility, will be the only
# naming scheme in v6)
option(VERSIONED_MINGW_LIBRARIES
"enables versioned libraries like 'libc++utilities-5.dll' instead of 'c++utilities.dll' for mingw-w64 targets" OFF)
# include packages for configure_package_config_file, write_basic_package_version_file and find_template_file
include(CMakePackageConfigHelpers)
include(TemplateFinder)
@ -35,14 +40,14 @@ set(CMAKE_MODULE_INSTALL_DESTINATION "${META_DATA_DIR_ABSOLUTE}/cmake/modules")
set(CMAKE_CONFIG_INSTALL_DESTINATION "${META_DATA_DIR_ABSOLUTE}/cmake")
# remove library prefix when building with mingw-w64 (just for consistency with qmake)
if (MINGW)
if (MINGW AND NOT VERSIONED_MINGW_LIBRARIES)
set(CMAKE_SHARED_LIBRARY_PREFIX "")
endif (MINGW)
endif ()
# set the windows extension to "dll", this is required by the mingw-w64 specific WindowsResources module
# set the Windows library suffix, this is also required by the mingw-w64 specific WindowsResources module as well
if (MINGW)
set(WINDOWS_EXT "dll")
endif (MINGW)
set(WINDOWS_EXT ".dll")
endif ()
# set compile definitions for static build
if (NOT BUILD_SHARED_LIBS)
@ -77,6 +82,13 @@ if (NOT META_SOVERSION AND NOT META_IS_PLUGIN)
endif ()
endif ()
# incorporate the SOVERSION into the library name for mingw-w64 targets
if (BUILD_SHARED_LIBS AND NOT META_IS_PLUGIN
AND MINGW
AND VERSIONED_MINGW_LIBRARIES)
set(WINDOWS_EXT "-${META_SOVERSION}${WINDOWS_EXT}")
endif ()
# define relevant files
set(ALL_FILES
${HEADER_FILES}
@ -161,6 +173,11 @@ else ()
if (META_PLUGIN_CATEGORY)
set_target_properties(${META_TARGET_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${META_PLUGIN_CATEGORY}")
endif ()
if (BUILD_SHARED_LIBS AND NOT META_IS_PLUGIN
AND MINGW
AND VERSIONED_MINGW_LIBRARIES)
set_target_properties(${META_TARGET_NAME} PROPERTIES SUFFIX "${WINDOWS_EXT}")
endif ()
endif ()
# populate META_PUBLIC_LIB_DEPENDS

View File

@ -27,7 +27,7 @@ VS_VERSION_INFO VERSIONINFO
VALUE "FileDescription", "@META_APP_DESCRIPTION@\0"
VALUE "FileVersion", "@META_APP_VERSION@\0"
VALUE "LegalCopyright", "by @META_APP_AUTHOR@\0"
VALUE "OriginalFilename", "@META_PROJECT_NAME@.@WINDOWS_EXT@\0"
VALUE "OriginalFilename", "@META_PROJECT_NAME@@WINDOWS_EXT@\0"
VALUE "ProductName", "@META_APP_NAME@\0"
VALUE "ProductVersion", "@META_APP_VERSION@\0"
END