Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,818
    • Issues 3,818
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 8
    • Merge requests 8
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMake
  • CMakeCMake
  • Issues
  • #20681
Closed
Open
Created May 06, 2020 by Andrey@andry81

CMakeCache.txt does not retain list value from a generator expression as a list value

Platfrom: Windows 7 x64

Cmake: 3.17.2

Cmake generator: MSVC 2017 15.9.19/Win32

Steps to reproduce:

  1. Create an executable multiconfig project with external dependency libraries in not multiconfig projects. Because libraries does not support multiconfig, then they should be configured with an explicit setup of the CMAKE_BUILD_TYPE variable. Output of the libraries has to be placed into lib/debug and lib/release subdirectories respectively.
  2. Add MyLib_LIBRARIES_DEBUG and MyLib_LIBRARIES_RELEASE to the executable project cmake list as a list with more than one value (this is important):
set(MyLib_LIBRARIES_RELEASE "lib/release/a.lib;lib/release/b.lib")
set(MyLib_LIBRARIES_DEBUG "lib/debug/a.lib;lib/debug/b.lib")
  1. Add target_link_libraries to the executable project cmake list like that:
foreach(config_type_upper RELEASE DEBUG)
  if (MyLib_LIBRARIES_${config_type_upper})
    target_link_libraries(<executable_target>
      PUBLIC
        "$<$<CONFIG:${config_type_upper}>:${MyLib_LIBRARIES_${config_type_upper}}>"
    )
  endif()
endforeach()
  1. Run cmake configure and build for the libraries.
  2. Run cmake configure for the executable. (Remove the CMakeCache.txt if was already exist) When cmake configure runs first time, then the CMakeCache.txt will contain that:
MyLib_LIBRARIES_RELEASE:FILEPATH="lib/release/a.lib"
MyLib_LIBRARIES_DEBUG:FILEPATH="lib/debug/a.lib"

The rest of list values will be truncated. But neverless the generated Visual Studio project still contains all dependencies for the executable.

  1. Run cmake configure for the executable again.

Result:

The executable library dependecies has truncated in the Visual Studio project. So, the second configure step changes the Visual Studio project and loses the rest of libraries as linkage dependencies.

I don't know is this a bug in the generated Visual Studio project or a bug in the CMakeCache.txt file?

Edited May 06, 2020 by Andrey
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking