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:
- 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 intolib/debug
andlib/release
subdirectories respectively. - Add
MyLib_LIBRARIES_DEBUG
andMyLib_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")
- 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()
- Run cmake configure and build for the libraries.
- Run cmake configure for the executable.
(Remove the
CMakeCache.txt
if was already exist) When cmake configure runs first time, then theCMakeCache.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.
- 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?