I am trying to configure CMake and the ninja as a build system for my project. Except for the application itself, I have an additional executable for unit tests running on gtest. I thought it would be great if they were executed automatically when they were built. Here is how I did it:
βββ build βββ source βββ CMakeLists.txt βββ main.cc βββ ut βββ CMakeLists.txt βββ gtest β βββ ... βββ ut.cc
source / CMakeLists.txt ...
cmake_minimum_required (VERSION 2.6) project (trial) add_subdirectory(ut) add_executable(trial main.cc)
... and source / ut / CMakeLists.txt:
add_subdirectory(gtest) include_directories ("gtest/include") add_executable(ut ut.cc) target_link_libraries(ut LINK_PUBLIC gtest_main) add_custom_target(run_uts COMMAND ut DEPENDS ut WORKING_DIRECTORY ${CMAKE_PROJECT_DIR} )
Now that I will build it, that is:
cd build cmake -GNinja ../source ninja run_uts
It works great, except that the output is colorless. When I run the ut binary, i.e. build/ut/ut , I get beautiful green and red colors. Colors are also present when I use Unix Makefiles as a generator for CMake.
Since I'm only learning CMake, is there something I missed or is it a ninja problem?
source share