Add an option to disable unittest build, & disable them on Docker build (#9677)
authorLoïc Blot <nerzhul@users.noreply.github.com>
Thu, 16 Apr 2020 18:43:49 +0000 (20:43 +0200)
committerGitHub <noreply@github.com>
Thu, 16 Apr 2020 18:43:49 +0000 (20:43 +0200)
CMakeLists.txt
Dockerfile
README.md
src/CMakeLists.txt
src/cmake_config.h.in
src/main.cpp

index 8cf89dd1766a5cccc202ed10ebf1dd3a4c21bdb3..ae842918b9d68f418519dddaa9926484af03b52a 100644 (file)
@@ -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")
index 3c41ce0f491da944cf0b5eda341fb5d7703ce811..7c11072881773eb4f0950ecf1dae4b6f9192db92 100644 (file)
@@ -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
index cfd5a8ae0259160fd0084b42bdb5c19784581a78..e9065dfa70cf9639222a380dc4653ec0beb2e9aa 100644 (file)
--- 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
index c3f4f439ff0a2cf2568234a3299bb03627aaf32d..dbd6b59226583c78063ad0e0e59960f6341841f8 100644 (file)
@@ -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
index cb54cb488c09e1e4f0eccafe6098c6657a72db26..cac6335d40eb08dce8ce7fff930451a2cf75fa0c 100644 (file)
@@ -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
index db020661a7c4b97269617750bd7e212ed361111a..82666e463c644e40ea661a0525f83ebf42e9edf6 100644 (file)
@@ -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