Skip to content

CPack: Allow negative fallback

Russell Greene requested to merge russelltg/cmake:cpack_negative_fallback into master

It was surprising to me that when building my debug packages, when I set CPACK_DEBIAN_DEBUGINFO_PACAKGE to ON, but CPACK_DEBIAN_<COMPONENT>_DEBUGINFO_PACKAGE to OFF for a certain component, the ON was preferred to the OFF. This fixes this, and applies to the other spots that the fallback method is used.

This is not a backwards compatible change, and I'm not quite how those are handled, so guidance would be appreciated.

The specific testcase that I tested with is:

cmake_minimum_required(VERSION 3.13)
  
project(TestCPackDDEB VERSION 0.1 LANGUAGES CXX)

file(WRITE test.cpp "int main(){}")

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_executable(test test.cpp)
add_executable(test2 test.cpp)

install(TARGETS test DESTINATION bin COMPONENT test)
install(TARGETS test2 DESTINATION bin COMPONENT test2)

set(CPACK_PACKAGE_NAME "testcpackddeb")
set(CPACK_PACKAGE_CONTACT "L User <luser@gmail.com>")
set(CPACK_PACKAGE_DESCRIPTION "Not just another generator")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64)
set(CPACK_DEBIAN_PACKAGE_LICENSE MIT)
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "test")
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_DEBIAN_DEBUGINFO_PACKAGE ON)         #####
set(CPACK_DEBIAN_TEST_DEBUGINFO_PACKAGE OFF)   #####
set(CPACK_GENERATOR "DEB")

include(CPack)

Currently, CMake produces two .ddeb packages, but after this change it only produces one.

Merge request reports