Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ endif()
file(TO_CMAKE_PATH ${MV_INSTALL_DIR} MV_INSTALL_DIR)

# Other user-facing options
option(MV_USE_GTEST "Use GoogleTest" OFF)
option(MV_PUBLIC_TEST "Test the public part of the ManiVault core" OFF)
option(MV_USE_AVX "Use AVX if available - by default OFF" OFF)
option(MV_PRECOMPILE_HEADERS "Precompile several headers for faster compilation" ON)
option(MV_UNITY_BUILD "Combine target source files into batches for faster compilation" OFF)
Expand All @@ -36,16 +36,6 @@ endif()
include(ManiVault/cmake/Utils.cmake)
mv_set_version()

# -----------------------------------------------------------------------------
# Tests
# -----------------------------------------------------------------------------

if (MV_USE_GTEST)
message(WARNING "MV_USE_GTEST: currently no test are available")
#enable_testing()
#add_subdirectory(external/googletest)
endif()

# -----------------------------------------------------------------------------
# Main project
# -----------------------------------------------------------------------------
Expand Down
29 changes: 28 additions & 1 deletion ManiVault/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ CPMAddPackage(
OPTIONS "BUILD_EXAMPLES OFF"
)

enable_testing()

# Google test
CPMAddPackage(
NAME GTest
GITHUB_REPOSITORY google/googletest
VERSION 1.13.0
)

if(MV_UNITY_BUILD)
set_target_properties(qt6advanceddocking PROPERTIES UNITY_BUILD ON)
endif()
Expand Down Expand Up @@ -203,6 +212,9 @@ target_link_libraries(${MV_PUBLIC_LIB} PRIVATE Qt6::Widgets)
target_link_libraries(${MV_PUBLIC_LIB} PRIVATE Qt6::OpenGL)
target_link_libraries(${MV_PUBLIC_LIB} PRIVATE Qt6::OpenGLWidgets)
target_link_libraries(${MV_PUBLIC_LIB} PRIVATE Qt6::WebEngineWidgets)
target_link_libraries(${MV_PUBLIC_LIB} PRIVATE GTest::gtest)
target_link_libraries(${MV_PUBLIC_LIB} PRIVATE GTest::gtest_main)


# Use AVX if enabled and available
check_and_set_AVX(${MV_PUBLIC_LIB} ${MV_USE_AVX})
Expand Down Expand Up @@ -281,7 +293,6 @@ if(APPLE)
set_target_properties( ${MV_EXE} PROPERTIES BUILD_WITH_INSTALL_RPATH True)
endif()


# -----------------------------------------------------------------------------
# Plugin projects
# -----------------------------------------------------------------------------
Expand All @@ -301,6 +312,14 @@ add_subdirectory(src/plugins/TextData)
add_subdirectory(src/plugins/ClusterData)
add_subdirectory(src/plugins/ImageData)

# -----------------------------------------------------------------------------
# Test project(s)
# -----------------------------------------------------------------------------

# Test the public part of the ManiVault core
if (MV_PUBLIC_TEST)
add_subdirectory(test/MV_Public_test)
endif()

# -----------------------------------------------------------------------------
# Installation
Expand Down Expand Up @@ -473,6 +492,14 @@ if(NOT APPLE)
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:QuaZip> ${MV_INSTALL_DIR}/$<CONFIGURATION>$<IF:$<CXX_COMPILER_ID:MSVC>,,/lib/>
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:zlib> ${MV_INSTALL_DIR}/$<CONFIGURATION>$<IF:$<CXX_COMPILER_ID:MSVC>,,/lib/>
)

if (MV_PUBLIC_TEST)
add_custom_command(TARGET ${MV_EXE} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Installing: Google test runtime libraries"
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:gtest> ${MV_INSTALL_DIR}/$<CONFIGURATION>$<IF:$<CXX_COMPILER_ID:MSVC>,,/lib/>
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:gtest_main> ${MV_INSTALL_DIR}/$<CONFIGURATION>$<IF:$<CXX_COMPILER_ID:MSVC>,,/lib/>
)
endif()

# Create symlink with slightly different name required on some linux distributions
if(UNIX)
Expand Down
3 changes: 3 additions & 0 deletions ManiVault/cmake/CMakeMvSourcesPublic.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ set(PUBLIC_NUMERICAL_ACTIONS_HEADERS

set(PUBLIC_NUMERICAL_ACTIONS_SOURCES
src/actions/NumericalAction.cpp
src/actions/NumericalAction_test.cpp
src/actions/DecimalAction.cpp
src/actions/DecimalAction_test.cpp
src/actions/IntegralAction.cpp
src/actions/IntegralAction_test.cpp
src/actions/NumericalRangeAction.cpp
src/actions/DecimalRangeAction.cpp
src/actions/IntegralRangeAction.cpp
Expand Down
14 changes: 14 additions & 0 deletions ManiVault/src/actions/DecimalAction_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

#include "DecimalAction.h"

#include <gtest/gtest.h>

using namespace mv::gui;

TEST(DecimalAction, CheckInitialization) {
DecimalAction decimalAction(nullptr, "", 0.f, 100.f, 50.f);

EXPECT_EQ(decimalAction.getMinimum(), 0.f);
EXPECT_EQ(decimalAction.getMaximum(), 100.f);
EXPECT_EQ(decimalAction.getValue(), 50.f);
}
16 changes: 16 additions & 0 deletions ManiVault/src/actions/IntegralAction_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

#include "IntegralAction.h"

#include <gtest/gtest.h>

using namespace mv::gui;

TEST(IntegralAction, CheckInitialization) {
IntegralAction integralAction(nullptr, "", 0, 100, 50);

EXPECT_EQ(integralAction.getMinimum(), 0);
EXPECT_EQ(integralAction.getMaximum(), 100);
EXPECT_EQ(integralAction.getValue(), 50);
EXPECT_EQ(integralAction.getPrefix(), "");
EXPECT_EQ(integralAction.getSuffix(), "");
}
32 changes: 32 additions & 0 deletions ManiVault/src/actions/NumericalAction_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

#include "NumericalAction.h"

#include <gtest/gtest.h>

using namespace mv::gui;

TEST(IntegralAction, CheckInitialization) {
NumericalAction integralAction(nullptr, "", 0, 100, 50);

EXPECT_EQ(integralAction.getMinimum(), 0);
EXPECT_EQ(integralAction.getMaximum(), 100);
EXPECT_EQ(integralAction.getValue(), 50);
EXPECT_EQ(integralAction.getPrefix(), "");
EXPECT_EQ(integralAction.getSuffix(), "");

NumericalAction floatAction(nullptr, "", 0.f, 100.f, 50.f);

EXPECT_EQ(floatAction.getMinimum(), 0.f);
EXPECT_EQ(floatAction.getMaximum(), 100.f);
EXPECT_EQ(floatAction.getValue(), 50.f);
EXPECT_EQ(floatAction.getPrefix(), "");
EXPECT_EQ(floatAction.getSuffix(), "");

NumericalAction doubleAction(nullptr, "", 0., 100., 50.);

EXPECT_EQ(doubleAction.getMinimum(), 0.);
EXPECT_EQ(doubleAction.getMaximum(), 100.);
EXPECT_EQ(doubleAction.getValue(), 50.);
EXPECT_EQ(doubleAction.getPrefix(), "");
EXPECT_EQ(doubleAction.getSuffix(), "");
}
6 changes: 6 additions & 0 deletions ManiVault/src/actions/TriggerAction_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <gtest/gtest.h>

// Simple test example
TEST(SampleTest, AddTest) {
EXPECT_EQ(1 + 1, 2);
}
68 changes: 68 additions & 0 deletions ManiVault/test/MV_Public_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
cmake_minimum_required(VERSION 3.17)

set(MV_PUBLIC_TEST "MV_Public_test")
PROJECT(${MV_PUBLIC_TEST})

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DWIN32 /EHsc /MP /permissive- /Zc:__cplusplus")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:LIBCMT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
endif(MSVC)

# Check if the directory to the ManiVault installation has been provided
if(NOT DEFINED MV_INSTALL_DIR)
set(MV_INSTALL_DIR "" CACHE PATH "Directory where ManiVault is installed")
message(FATAL_ERROR "Please set MV_INSTALL_DIR to the directory where ManiVault is installed")
endif()
file(TO_CMAKE_PATH ${MV_INSTALL_DIR} MV_INSTALL_DIR)

find_package(Qt6 COMPONENTS Widgets WebEngineWidgets REQUIRED)

enable_testing()

CPMAddPackage(
NAME GTest
GITHUB_REPOSITORY google/googletest
VERSION 1.13.0
)

set(MV_PUBLIC_SRC_DIR ../../src)

file(GLOB_RECURSE MV_PUBLIC_TESTS "${MV_PUBLIC_SRC_DIR}/*_test.cpp")

foreach(_var ${MV_PUBLIC_SRC_DIR})
message(STATUS "${_var}: ${${_var}}")
endforeach()

add_executable(${MV_PUBLIC_TEST} ${MV_PUBLIC_TESTS})

target_include_directories(${MV_PUBLIC_TEST} PRIVATE "${MV_INSTALL_DIR}/$<CONFIGURATION>/include/")

target_link_libraries(${MV_PUBLIC_TEST} PRIVATE Qt6::Core)
target_link_libraries(${MV_PUBLIC_TEST} PRIVATE Qt6::Widgets)
target_link_libraries(${MV_PUBLIC_TEST} PRIVATE Qt6::WebEngineWidgets)
target_link_libraries(${MV_PUBLIC_TEST} PRIVATE ${MV_PUBLIC_LIB})
target_link_libraries(${MV_PUBLIC_TEST} PRIVATE GTest::gtest)
target_link_libraries(${MV_PUBLIC_TEST} PRIVATE GTest::gtest_main)

#add_test(NAME ${MV_PUBLIC_TEST} COMMAND ${MV_PUBLIC_TEST})

#target_include_directories(${MV_PUBLIC_TEST} PRIVATE "${MV_INSTALL_DIR}/$<CONFIGURATION>/include/")

target_compile_features(${MV_PUBLIC_TEST} PRIVATE cxx_std_17)

install(TARGETS ${MV_PUBLIC_TEST}
RUNTIME DESTINATION ${MV_INSTALL_DIR}/$<CONFIGURATION> COMPONENT MV_PUBLIC_TEST
)

add_custom_command(TARGET ${MV_PUBLIC_TEST} POST_BUILD
COMMAND ${CMAKE_COMMAND}
--install ${CMAKE_CURRENT_BINARY_DIR}
--config $<CONFIGURATION>
--prefix ${MV_INSTALL_DIR}/$<CONFIGURATION>
)