Add BARRIER_BUILD_TESTS CMake option to make tests optional

This commit is contained in:
James Le Cuirot 2020-08-21 22:22:48 +01:00
parent d186548a53
commit 4a031b8ce5
No known key found for this signature in database
GPG Key ID: 1226415D00DD3137
4 changed files with 11 additions and 2 deletions

View File

@ -20,6 +20,7 @@ project (barrier C CXX)
option (BARRIER_BUILD_GUI "Build the GUI" ON)
option (BARRIER_BUILD_INSTALLER "Build the installer" ON)
option (BARRIER_BUILD_TESTS "Build the tests" ON)
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
set (CMAKE_CXX_STANDARD 14)
@ -49,7 +50,6 @@ else()
endif()
set (libs)
include_directories (BEFORE SYSTEM ./ext/gtest/include)
if (UNIX)
if (NOT APPLE)

View File

@ -19,7 +19,10 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR}/lib)
add_subdirectory(lib)
add_subdirectory(cmd)
add_subdirectory(test)
if (BARRIER_BUILD_TESTS)
add_subdirectory(test)
endif()
if (BARRIER_BUILD_GUI)
add_subdirectory(gui)

View File

@ -24,7 +24,9 @@
#include "common/stdset.h"
#include "common/stdvector.h"
#ifdef TEST_ENV
#include <gtest/gtest_prod.h>
#endif
namespace barrier {
@ -327,6 +329,7 @@ public:
//@}
private:
#ifdef TEST_ENV
FRIEND_TEST(KeyMapTests,
findBestKey_requiredDown_matchExactFirstItem);
FRIEND_TEST(KeyMapTests,
@ -340,6 +343,7 @@ private:
FRIEND_TEST(KeyMapTests,
findBestKey_onlyOneRequiredDown_matchTwoRequiredChangesItem);
FRIEND_TEST(KeyMapTests, findBestKey_noRequiredDown_cannotMatch);
#endif
private:
//! Ways to synthesize a key

View File

@ -15,6 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define TEST_ENV
#include "barrier/KeyMap.h"
#include "test/global/gtest.h"