Skip to content

ENH use variadic templates args in scatter and figure #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@

# Build
/examples/build/*
/contrib/unittests_catch2/build/*
/contrib/unittests_catch2/cmake-
/contrib/unittests_catch2/build/*
/contrib/unittests_catch2/cmake-*

# vim temp files
*.sw*

# IDE directories
.idea
12 changes: 12 additions & 0 deletions contrib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,15 @@ The `WinBuild.cmd` will set up temporal ENV variables and build binaries in (mat

3. Find exe files in examples/build/Release
Note: platforms folder is necessary to make qt works.

## Unit Tests

```cmd
> cd contrib/unittests_catch2
> cmake -S . -B "./build"
> cd build
> make
> ./run_MatplotlibcppTests
```
See `unittests_catch/2README` for more details.

101 changes: 101 additions & 0 deletions contrib/unittests_catch2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# From this directory:
# *WARNING* if you use a virtual python environment, you must have activated it before.
# ./configure
# then follow instructions
# cmake -S . -B /tmp --build doit aussi fonctionner

cmake_minimum_required(VERSION 3.15)

project(MatplotlibcppTests
DESCRIPTION "matplotlibcpp unit tests"
LANGUAGES CXX)

if(${USE_VIRTUEL_ENV})
set(ENV{PATH} "$ENV{VIRTUAL_ENV}/bin:$ENV{PATH}")
endif()

set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 0)
set(PROJECT_VERSION_PATCH 0)
set(PROJECT_VERSION_TWEAK 1)
set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK})

# -----------------------------------------------
# -- CMake's variables
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "Verbose Makefile" FORCE)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# -----------------------------------------------
# -- Catch
set(CATCH_MAIN ON)
option(BUILD_TESTING "Build nemesis-cpp testing" ${CATCH_MAIN})

# Prepare "Catch" library for other executables
add_library(Catch INTERFACE)
target_include_directories(Catch INTERFACE ${PROJECT_SOURCE_DIR})

# -----------------------------------------------
# -- Python
set(PYTHON_VERSION "3.7")
find_package (Python3 COMPONENTS Interpreter Development)
# Valable pour un environnement python dans un python, dans un environnement virtuel ou dans un env spack,
set(SITE_PACKAGES "${Python3_SITELIB}")
set(NUMPY_INCLUDE_DIR "${SITE_PACKAGES}/numpy/core/include/numpy")
set(NUMPY_LIB_DIR "${SITE_PACKAGES}/numpy/core")

# -----------------------------------------------
# -- the project
set(PRJ_FILES "./tu_main.cpp;./tu_matplotlibcpp.cpp")
message(STATUS "PRJ_FILES = ${PRJ_FILES}")
set(TU_EXE "run_${PROJECT_NAME}")

set(MPLCPP_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/../../")
message(STATUS "MPLCPP_INCLUDE = ${MPLCPP_INCLUDE}")
# -----------------------------------------------
# -- rpath ...

# If your compiler is not in a standard path of your OS
if(${USE_CUSTOM_COMPILER})
execute_process(COMMAND bash "-c" "LANG=C ${CMAKE_CXX_COMPILER} -print-search-dirs | sed -n 's/libraries: =//gp' | tr -s ':' ';'"
OUTPUT_VARIABLE GNU_LIBRARIES_SEARCH_DIR)

find_library(STDCPP_LIB stdc++ PATHS ${GNU_LIBRARIES_SEARCH_DIR})
get_filename_component(_COMPILER_LIB_DIR ${STDCPP_LIB} DIRECTORY)
set(COMPILER_RPATH_FLAGS "-Wl,-rpath,${_COMPILER_LIB_DIR}")
endif()

# -----------------------------------------------
# -- build executable
add_executable(${TU_EXE} ${PRJ_FILES})
add_test(NAME matplotlibcpp_tests
COMMAND ${TU_EXE})

target_compile_features(${TU_EXE}
PRIVATE
cxx_std_17
)
target_compile_definitions(${TU_EXE}
PRIVATE
USE_VARIADIC_TEMPLATES_ARGS
CATCH_UNIT_TESTS)
target_compile_options(${TU_EXE}
PRIVATE
-fconcepts
)
target_include_directories(${TU_EXE}
PRIVATE
${Python3_INCLUDE_DIRS}
${NUMPY_INCLUDE_DIR}
${MPLCPP_INCLUDE}
${CMAKE_BINARY_DIR}
)
target_link_libraries(${TU_EXE}
PRIVATE
${Python3_LIBRARIES}
-lstdc++fs
)
target_link_options(${TU_EXE}
PRIVATE
${COMPILER_RPATH_FLAGS}
)

14 changes: 14 additions & 0 deletions contrib/unittests_catch2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Tests with Catch2

Here some tests using [Catch2](https://github.com/catchorg/Catch2).

Only tested on Ubuntu and CentOS 7, with `gcc` 6.2, 6.3 and 8.3.

**warning** I force `Qt5Agg` backend. But it should work with other backend, except 'Agg'.

For running the tests :

cd <matplotlibcpp_home>/contrib/tests_catch2
cmake -S . -B "./build"
cd build
make
Loading