From 69916354e6fabd2a249825fb5a992f324cd692d8 Mon Sep 17 00:00:00 2001 From: dev Date: Thu, 21 Sep 2023 19:37:21 -0400 Subject: [PATCH 1/2] Allow for 0 SO_VERSION --- cmake/Packing.cmake | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmake/Packing.cmake b/cmake/Packing.cmake index 2c5d839..af40785 100644 --- a/cmake/Packing.cmake +++ b/cmake/Packing.cmake @@ -15,13 +15,17 @@ endif() get_target_property(target_type ${PROJECT_NAME} TYPE) if (target_type STREQUAL "SHARED_LIBRARY") get_target_property(so_version ${PROJECT_NAME} SOVERSION) - if (NOT so_version) - message( FATAL_ERROR "Target property SOVERSION must be defined for shared library packages." ) - endif() + # so_version evaluates to false when set to zero despite having a value + # see (https://cmake.org/cmake/help/v3.0/command/if.html). It evaluates to + # so_version-NOTFOUND when no value is present. It is always defined whether + # the property exists or not (see https://cmake.org/cmake/help/latest/command/get_target_property.html) + if((NOT so_version EQUAL 0 ) AND (NOT so_version)) + message( FATAL_ERROR "Target property SOVERSION must be defined for shared library packages." ) + endif() set (PACKAGE_VERSION ${so_version}) endif() -if (NOT PACKAGE_VERSION) +if (NOT DEFINED PACKAGE_VERSION) message( FATAL_ERROR "PACKAGE_VERSION must be defined for packages." ) endif() From 72a7345ec0197cfadd1586e381c5a4614495c703 Mon Sep 17 00:00:00 2001 From: dev Date: Fri, 22 Sep 2023 12:33:42 -0400 Subject: [PATCH 2/2] Update if statement --- cmake/Packing.cmake | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cmake/Packing.cmake b/cmake/Packing.cmake index af40785..d339fa7 100644 --- a/cmake/Packing.cmake +++ b/cmake/Packing.cmake @@ -15,12 +15,10 @@ endif() get_target_property(target_type ${PROJECT_NAME} TYPE) if (target_type STREQUAL "SHARED_LIBRARY") get_target_property(so_version ${PROJECT_NAME} SOVERSION) - # so_version evaluates to false when set to zero despite having a value - # see (https://cmake.org/cmake/help/v3.0/command/if.html). It evaluates to - # so_version-NOTFOUND when no value is present. It is always defined whether - # the property exists or not (see https://cmake.org/cmake/help/latest/command/get_target_property.html) - if((NOT so_version EQUAL 0 ) AND (NOT so_version)) - message( FATAL_ERROR "Target property SOVERSION must be defined for shared library packages." ) + # Check if so_version is empty or not found to allow for version 0 + # which is normally treated the same as so_version-NOTFOUND in a condition. + if ("${so_version}" STREQUAL "" OR "${so_version}" STREQUAL "so_version-NOTFOUND") + message( FATAL_ERROR "Target property SOVERSION must be defined for shared library packages." ) endif() set (PACKAGE_VERSION ${so_version}) endif()