summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-02-14 23:21:57 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-02-18 14:11:03 +0000
commit13706de14bce8f8bfd1cb7db226d12cbd927b1b4 (patch)
tree97da6352ca2455e19cef14ca9d664c3d26828598 /cmake
parent83f7beacc575f4a24ebbfeaeed3bd9e38fcef041 (diff)
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).
Diffstat (limited to 'cmake')
-rw-r--r--cmake/CompileGTest.cmake9
-rw-r--r--cmake/ModulePackage.cmake10
2 files changed, 11 insertions, 8 deletions
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)
47 endif() 47 endif()
48 endif() 48 endif()
49endif() 49endif()
50
51function(unit_test subdir target)
52 if(HAVE_GTEST)
53 add_executable(unit_${target}_test ${subdir}/${target}_test.cpp)
54 target_link_modules(unit_${target}_test toxcore gtest)
55 set_target_properties(unit_${target}_test PROPERTIES COMPILE_FLAGS "${TEST_CXX_FLAGS}")
56 add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} unit_${target}_test)
57 endif()
58endfunction()
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)
28 endif() 28 endif()
29endfunction() 29endfunction()
30 30
31macro(add_submodule super lib)
32 add_module(${lib} ${ARGN})
33 set(${super}_SUBLIBS ${${super}_SUBLIBS} ${lib})
34 set(${super}_SOURCES ${${super}_SOURCES} ${${lib}_SOURCES})
35endmacro()
36
37function(add_module lib) 31function(add_module lib)
38 set(${lib}_SOURCES ${ARGN} PARENT_SCOPE) 32 set(${lib}_SOURCES ${ARGN} PARENT_SCOPE)
39 33
@@ -132,8 +126,8 @@ function(target_link_modules target)
132 set(_targets ${_targets} ${target}) 126 set(_targets ${_targets} ${target})
133 # Executables preferably link against static libraries, so they are 127 # Executables preferably link against static libraries, so they are
134 # standalone and can be shipped without any external dependencies. As a 128 # standalone and can be shipped without any external dependencies. As a
135 # frame of reference: tests become roughly 1-1.5M binaries instead of 129 # frame of reference: tests become roughly 600-800K binaries instead of
136 # 100-200K on x86_64 Linux. 130 # 50-100K on x86_64 Linux.
137 set(${target}_primary static) 131 set(${target}_primary static)
138 set(${target}_secondary shared) 132 set(${target}_secondary shared)
139 endif() 133 endif()