From 13706de14bce8f8bfd1cb7db226d12cbd927b1b4 Mon Sep 17 00:00:00 2001 From: iphydf Date: Wed, 14 Feb 2018 23:21:57 +0000 Subject: Don't build all the small sub-libraries. This caused us to build everything 2-4 times, now we only build it 1-2 times (depending on selection of static/shared builds). The disadvantage is that now it's more up to the reviewer to ensure modularity (we still catch it in the bazel build, though). --- cmake/CompileGTest.cmake | 9 +++++++++ cmake/ModulePackage.cmake | 10 ++-------- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'cmake') diff --git a/cmake/CompileGTest.cmake b/cmake/CompileGTest.cmake index 520ca06a..1974901e 100644 --- a/cmake/CompileGTest.cmake +++ b/cmake/CompileGTest.cmake @@ -47,3 +47,12 @@ if(GTEST_ALL_CC) endif() endif() endif() + +function(unit_test subdir target) + if(HAVE_GTEST) + add_executable(unit_${target}_test ${subdir}/${target}_test.cpp) + target_link_modules(unit_${target}_test toxcore gtest) + set_target_properties(unit_${target}_test PROPERTIES COMPILE_FLAGS "${TEST_CXX_FLAGS}") + add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} unit_${target}_test) + endif() +endfunction() diff --git a/cmake/ModulePackage.cmake b/cmake/ModulePackage.cmake index 8ee8d6d7..f0eef7c9 100644 --- a/cmake/ModulePackage.cmake +++ b/cmake/ModulePackage.cmake @@ -28,12 +28,6 @@ function(pkg_use_module mod pkg) endif() endfunction() -macro(add_submodule super lib) - add_module(${lib} ${ARGN}) - set(${super}_SUBLIBS ${${super}_SUBLIBS} ${lib}) - set(${super}_SOURCES ${${super}_SOURCES} ${${lib}_SOURCES}) -endmacro() - function(add_module lib) set(${lib}_SOURCES ${ARGN} PARENT_SCOPE) @@ -132,8 +126,8 @@ function(target_link_modules target) set(_targets ${_targets} ${target}) # Executables preferably link against static libraries, so they are # standalone and can be shipped without any external dependencies. As a - # frame of reference: tests become roughly 1-1.5M binaries instead of - # 100-200K on x86_64 Linux. + # frame of reference: tests become roughly 600-800K binaries instead of + # 50-100K on x86_64 Linux. set(${target}_primary static) set(${target}_secondary shared) endif() -- cgit v1.2.3