cmake_minimum_required(VERSION 2.8.12.2) project(cpackbug) file(WRITE a.txt "A") file(WRITE b.txt "B") file(WRITE c.txt "C") install(FILES a.txt DESTINATION foo COMPONENT a) install(FILES b.txt DESTINATION foo COMPONENT b) install(FILES c.txt DESTINATION foo COMPONENT c) set(CPACK_GENERATOR RPM) set(CPACK_RPM_COMPONENT_INSTALL ON) set(CPACK_RPM_a_PACKAGE_REQUIRES "foo") set(CPACK_RPM_b_PACKAGE_REQUIRES "bar") # If requirements for 'c' are unset, it gets 'bar'. # This is not a big problem, because we can set it to # an empty string to override. #set(CPACK_RPM_c_PACKAGE_REQUIRES "") # Both B and C will use this user specfile template. Setting # the template for C to an empty string *does not* override. set(CPACK_RPM_b_USER_BINARY_SPECFILE ${CMAKE_CURRENT_SOURCE_DIR}/cpackbug.spec.in) set(CPACK_RPM_c_USER_BINARY_SPECFILE "") include(CPack)