Eventually found this with some help from the CMake list. In your CMakeLists.txt do something like this:
install(PROGRAMS basic.sh DESTINATION "." COMPONENT basic)
install(PROGRAMS optional.sh DESTINATION "." COMPONENT optional)
set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/CPackOptions.cmake")
CPackOptions.cmake should handle the ifs. Notice that you must turn on CPACK_*_COMPONENT_INSTALL for any other generator you might want:
SET(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
SET(CPACK_DEB_COMPONENT_INSTALL ON)
SET(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
IF ("${CPACK_GENERATOR}" MATCHES "TGZ")
SET(CPACK_COMPONENTS_ALL basic optional)
ELSEIF ("${CPACK_GENERATOR}" MATCHES "TBZ2")
SET(CPACK_COMPONENTS_ALL basic optional)
ELSE()
SET(CPACK_COMPONENTS_ALL basic)
ENDIF()