Generate 2 images in CMake



I have a project with thousands of files, assume one of those files is version.cpp, defining variable with version. 
I want to generate 2 HEX images where the only difference will be version.cpp (.o) used at link time. Goal here is not to build 1k+ sources twice just to change version.  

I know how to do it in plain CMake project, add_library with 1k+ sources and add_executable with version.cpp and then target_link_library everyting. But since Zephyr's CMake is quite more complex I can't figure this out. 

Can anyone point me in the right direction please?