From 7539267d370ae9a1b547008a937bd7f57bece541 Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Thu, 16 Apr 2020 20:43:49 +0200 Subject: Add an option to disable unittest build, & disable them on Docker build (#9677) --- src/CMakeLists.txt | 11 +++++++++-- src/cmake_config.h.in | 1 + src/main.cpp | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'src') 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 -- cgit v1.2.3