This fails with the error "Cannot find source file: WIN32. Tried extensions..."
add_executable(${PROJECT_NAME} $<$<CONFIG:Release>:WIN32> main.cpp)
I need this in order to launch the app in the console in Debug mode and being able to read information printed to the console.
And as far as I know it's wrong and is advised agains in the cmake docs to check CMAKE_BUILD_TYPE
being Release
directly.
CodePudding user response:
As you noticed you cannot use generator expressions for the WIN32 keyword in the add_executable
command.
Instead, try setting the corresponding property WIN32_EXECUTABLE
on the target:
set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE $<CONFIG:Release>)