Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
CMake
CMake
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,291
    • Issues 3,291
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 11
    • Merge Requests 11
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • External Wiki
    • External Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMake
  • CMakeCMake
  • Issues
  • #19918

Closed
Open
Created Nov 04, 2019 by Craig Scott@craig.scottMaintainer

Building the "package" target fails if CPACK_INSTALL_CMAKE_CONFIGURATIONS contains more than one config

!3533 (merged) introduced the new CPACK_INSTALL_CMAKE_CONFIGURATIONS variable. If it is set to more than one configuration, then building the package target from a clean build directory will fail. Here's a minimal project used to reproduce the problem:

cmake_minimum_required(VERSION 3.15)
project(MultiConfigInstall)

add_executable(barry main.cpp)
install(TARGETS barry RUNTIME DESTINATION bin/$<CONFIG>)

set(CPACK_GENERATOR ZIP)
set(CPACK_INSTALL_CMAKE_CONFIGURATIONS Debug Release)
include(CPack)

Issue the following commands to reproduce the build error using Xcode (MSVC has the same behavior too):

# Assuming the build directory doesn't exist yet
mkdir build
cd build
cmake -G Xcode ..
cmake --build . --target package

Building the package target fails because it only tries to build one configuration (Debug), but then when it invokes cpack, the build for the other configuration is missing. If you manually build both targets first, then the package is built successfully and contains both configurations. The package target will need to learn to recognise that multiple configurations are needed and build all of the ones listed in CPACK_INSTALL_CMAKE_CONFIGURATIONS before it runs cpack.

There is also a similar situation for the clean target as well which will become more important once the above issue is addressed.

Ignore the rest of the description below, it is incorrect (kept here only so that the comment history makes sense)

Doing the same thing with the Visual Studio generator gives no error, but only the Debug configuration is included in the package, even if you manually build both the Debug and Release configurations first. Even if you invoke cpack -C "Debug;Release" directly, the package includes either just the Debug configuration or nothing at all (again, even if you manually build both configurations first). Which result I get seems to depend on things I may have done beforehand.

Continuing with Visual Studio, if you run cpack without the -C option, you get an empty package if you haven't built the Release configuration, or you get just the Release configuration if you've built that configuration. In either case, no errors are raised. The Debug configuration gets completely ignored, despite it being listed in CPACK_INSTALL_CMAKE_CONFIGURATIONS. It's possible that there might be different results depending on what steps you've done beforehand.

Edited Nov 05, 2019 by Craig Scott
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
3.16.0
Milestone
3.16.0 (Past due)
Assign milestone
Time tracking
None
Due date
None