Yes, making your framework a separate library. As of now, you specify framework_SRCS as sources for the project executable, and then specify the same sources for the test-runner executable. And CMake simply creates both executable files from the specified sources.
Worse, CMake cannot easily assume that the same source file will be used the same for both executable files. What if you have several different compilation flags between your test and your application?
The easiest way is to link you to framework_SRCS in the library, and then specify the link dependency:
ADD_LIBRARY( MyFramework STATIC ${framework_SRCS} ) ADD_EXECUTABLE(${CMAKE_PROJECT_NAME} ${game_SRC}) TARGET_LINK_LIBRARIES( ${CMAKE_PROJECT_NAME} MyFramework ) # --- Testing --- ENABLE_TESTING() AUX_SOURCE_DIRECTORY(${TEST_DIR} test_SRC) ADD_EXECUTABLE(${TEST_RUNNER_NAME} ${test_SRC} TARGET_LINK_LIBRARIES( ${TEST_RUNNER_NAME} MyFramework )
(Note that I explicitly decided to build the library statically. Of course, you could leave it until cmake or force the shared assembly to be used)
Regards, Andre
source share