0

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?

Jason
  • 2,198
  • 3
  • 23
  • 59
  • I guess your [previous question](http://stackoverflow.com/questions/43430906/how-to-build-two-separate-binaries-exe-and-lib-from-source-in-cmake) is about the same problem. If so, please, either edit prevous question to the **actual problem** and delete given one, or delete previous question. – Tsyvarev Apr 16 '17 at 18:03
  • Previous has been deleted – Jason Apr 16 '17 at 20:09

0 Answers0