
Test/CMakeLists.txt (version with all sources included) include_directories(./src)Īdd_executable(TestTableExe test_table.c.


That is sometimes very handy if you have things mocked/stubbed and you don't want to or you can't link all the dependencies of the "code do be tested". But you could group them in some IDEs with the FOLDER target property.Īn alternative would be to just compile the files you need directly into the test. The only disadvantage would be that you will have two targets with the same source files ( TableLib and TestTableLib). )ĬMake will take care that the compiler outputs of TableLib and TestTableLib end up in different directories. Test/CMakeLists.txt add_executable(TestTableExe test_table.c)Īdd_dependencies(TestTableExe TestTableLib) Set_property(TARGET TestTableLib APPEND PROPERTY COMPILE_DEFINITIONS "UNIT_TESTING") I'm trying to configure the ffmpeg source package to build. Src/CMakeLists.txt set(inFiles table.c table.h)

#Recompile with cmake how to#
Taking m.s.'s answer a little further with How to build a program with 2 different values of a variable in CMake, you could even do this in one generated build environment.ĬMakeLists.txt cmake_minimum_required(VERSION 2.8) If Qt Creator cannot load the CMake project, the Projects view shows a