How to run different add_custom_command for each specific target?

I work with Visual Studio and have different paths to work for different configurations (Debug, Release):

if(WIN32 )
    set(static_release ${my_lib}_release/SomeLibrary.lib)
    set(static_debug ${my_lib}_debug/SomeLibrary.lib)
endif(WIN32)

Then I want to run different commands <<add_custom_command(TARGET>> for those different configurations as follows:

A command which can be applied for Debug configuration:

add_custom_command(TARGET mylib
                   POST_BUILD
				   COMMAND lib /out:$<TARGET_FILE:mylib> $<TARGET_FILE:mylib> ${static_debug}
                   COMMENT "Concatenating static libs"
				   CONFIG Debug)

A command which can be applied for Release configuration:

add_custom_command(TARGET mylib
                   POST_BUILD
				   COMMAND lib /out:$<TARGET_FILE:mylib> $<TARGET_FILE:mylib> ${static_release}
                   COMMENT "Concatenating static libs"
				   CONFIG Release)

Unfortunately, Visual Studio runs both of those custom commands for each configuration.
Is it possible to run only needed custom command for each configuration?

I also tried to use

add_custom_command(TARGET myLib
                   POST_BUILD
				   COMMAND lib /out:$<TARGET_FILE:myLib> $<TARGET_FILE:myLib> "$<IF:$<CONFIG:Debug>,${static_debug},$<CONFIG:Release>,${static_release}>"
                   COMMENT "Concatenating static libs"
				   CONFIG "$<IF:$<CONFIG:Debug>,Debug,$<CONFIG:Release>,Release")

but it doesn’t work at all.

This issue may be of interest to you for the long-term.

You’re missing a > at the end of that CONFIG argument (for the $<IF>).