summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2020-04-16 20:43:49 +0200
committerGitHub <noreply@github.com>2020-04-16 20:43:49 +0200
commit7539267d370ae9a1b547008a937bd7f57bece541 (patch)
treef4a04951d7d6e5a4000e0c9bd606e457679e0374
parent093e79ea78c872293386bf10b76416ff284ac5b6 (diff)
downloadminetest-7539267d370ae9a1b547008a937bd7f57bece541.tar.gz
minetest-7539267d370ae9a1b547008a937bd7f57bece541.tar.bz2
minetest-7539267d370ae9a1b547008a937bd7f57bece541.zip
Add an option to disable unittest build, & disable them on Docker build (#9677)
-rw-r--r--CMakeLists.txt1
-rw-r--r--Dockerfile1
-rw-r--r--README.md1
-rw-r--r--src/CMakeLists.txt11
-rw-r--r--src/cmake_config.h.in1
-rw-r--r--src/main.cpp6
6 files changed, 19 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8cf89dd17..ae842918b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,6 +49,7 @@ set(RUN_IN_PLACE ${DEFAULT_RUN_IN_PLACE} CACHE BOOL
set(BUILD_CLIENT TRUE CACHE BOOL "Build client")
set(BUILD_SERVER FALSE CACHE BOOL "Build server")
+set(BUILD_UNITTESTS TRUE CACHE BOOL "Build unittests")
set(WARN_ALL TRUE CACHE BOOL "Enable -Wall for Release build")
diff --git a/Dockerfile b/Dockerfile
index 3c41ce0f4..7c1107288 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -30,6 +30,7 @@ RUN apk add --no-cache git build-base irrlicht-dev cmake bzip2-dev libpng-dev \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SERVER=TRUE \
+ -DBUILD_UNITTESTS=FALSE \
-DBUILD_CLIENT=FALSE && \
make -j2 && \
make install
diff --git a/README.md b/README.md
index cfd5a8ae0..e9065dfa7 100644
--- a/README.md
+++ b/README.md
@@ -218,6 +218,7 @@ General options and their default values:
BUILD_CLIENT=TRUE - Build Minetest client
BUILD_SERVER=FALSE - Build Minetest server
+ BUILD_UNITTESTS=TRUE - Build unittest sources
CMAKE_BUILD_TYPE=Release - Type of build (Release vs. Debug)
Release - Release build
Debug - Debug build
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c3f4f439f..dbd6b5922 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -435,9 +435,12 @@ set(common_SRCS
${JTHREAD_SRCS}
${common_SCRIPT_SRCS}
${UTIL_SRCS}
- ${UNITTEST_SRCS}
)
+if(BUILD_UNITTESTS)
+ set(common_SRCS ${common_SRCS} ${UNITTEST_SRCS})
+endif()
+
# This gives us the icon and file version information
if(WIN32)
@@ -472,8 +475,12 @@ set(client_SRCS
${client_network_SRCS}
${client_irrlicht_changes_SRCS}
${client_SCRIPT_SRCS}
- ${UNITTEST_CLIENT_SRCS}
)
+
+if(BUILD_UNITTESTS)
+ set(client_SRCS ${client_SRCS} ${UNITTEST_CLIENT_SRCS})
+endif()
+
list(SORT client_SRCS)
# Server sources
diff --git a/src/cmake_config.h.in b/src/cmake_config.h.in
index cb54cb488..cac6335d4 100644
--- a/src/cmake_config.h.in
+++ b/src/cmake_config.h.in
@@ -34,3 +34,4 @@
#cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H
#cmakedefine01 CURSES_HAVE_NCURSESW_NCURSES_H
#cmakedefine01 CURSES_HAVE_NCURSESW_CURSES_H
+#cmakedefine01 BUILD_UNITTESTS
diff --git a/src/main.cpp b/src/main.cpp
index db020661a..82666e463 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -187,7 +187,13 @@ int main(int argc, char *argv[])
#ifndef __ANDROID__
// Run unit tests
if (cmd_args.getFlag("run-unittests")) {
+#if BUILD_UNITTESTS
return run_tests();
+#else
+ errorstream << "Unittest support is not enabled in this binary. "
+ << "If you want to enable it, compile project with BUILD_UNITTESTS=1 flag."
+ << std::endl;
+#endif
}
#endif