I currently have a visual studio solution which contains two projects: A game project responsible for building my game application and a gameTester project which runs unit tests on my game code. In the game project I have a post-build script responsible for also building a .lib out of the same source so that my gameTester project can link to it and run my tests. The post-build script is as follows:
lib /NOLOGO /OUT:"$(ProjectDir)Binaries\$(ProjectName).lib" "$(ProjectDir)Intermediate\$(PlatformName)\*.obj"
I would like to have a similar setup with CMake but not quite sure how best to set things up. It was suggested that I could just add these to lines in a CMakeLists.txt file and have my two binaries (.exe and .lib) built from the same source:
add_executable(Game "${CMAKE_SOURCE_DIR}/SourCe/Main.cpp")
add_library(GameLib STATIC "${CMAKE_SOURCE_DIR}/SourCe/Main.cpp")
Except, with this method CMake will generate an extra project 'GameLib' in visual studio. It would be cleaner if I could just generate the .lib as before without having another whole project dedicated to the task.
So is there a way, utilizing CMake, to have a post-build script run to generate a .lib from my Game project's source? If so, what CMake script commands would I use to accomplish this?