I'm using CMake for generating cross-platform build configuration. And for project to work I need to copy additional precompiled libraries to binaries directory. So, I use such script to build this project:
cmake_minimum_required(VERSION 3.17)
project(foo)
add_executable(bar foobar.cpp)
# Doing some logic to find library files...
list(APPEND DBG_LIBRARIES_LIST "lib1" "lib2")
list(APPEND REL_LIBRARIES_LIST "lib1" "lib2")
# Joining all libraries with " " character to be parsed as different program arguments
list(JOIN DBG_LIBRARIES_LIST " " DEBUG_LIBRARIES)
list(JOIN REL_LIBRARIES_LIST " " RELEASE_LIBRARIES)
add_custom_command(TARGET bar POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<IF:$<CONFIG:Debug>,${DEBUG_LIBRARIES},${RELEASE_LIBRARIES}>
$<TARGET_FILE_DIR:estareng>
)
After I generate such project on Windows using VS16 my post-build events contain such line:
cmake -E copy_if_different "lib1 lib2" some\proj\dir
If I try to join list using $<JOIN:$<IF:$<CONFIG:Debug>,${DEBUG_LIBRARIES_LIST},${RELEASE_LIBRARIES_LIST}>," "> I just get raw generator expression in post-build events.
NOTE: On GNU/Linux it works fine both using makefiles or Ninja