Generator expression evaluate to NOCONFIG in Xcode
I am on CMake 3.22.1. Please see below minimal example,
cmake_minimum_required(VERSION 3.20)
project(example)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/$<CONFIGURATION>/mymain.cpp
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/mymain.cpp.in
${CMAKE_BINARY_DIR}/$<CONFIGURATION>/mymain.cpp)
add_executable(${PROJECT_NAME} ${CMAKE_BINARY_DIR}/$<CONFIGURATION>/mymain.cpp
This minimal example works for make
, and it also works for visual studio
where $<CONFIGURATION>
is evaluated correctly to either Debug or Release. However, if I run cmake -G Xcode ..
on a Mac machine, I see the below CMake config error:
Cannot find source file:
/Users/jasjuang/example/build/NOCONFIG/mymain.cpp
Based on the error message, it looks like CMake incorrectly evaluates $<CONFIGURATION>
to NOCONFIG for Xcode
. I think this is a bug because $<CONFIGURATION>
should be evaluated to either Debug or Release for Xcode
just like visual studio
.