diff --git a/CMakeLists.txt b/CMakeLists.txt index 7dad97f2c..c001c7cc9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,8 @@ set(PYBIND11_EXAMPLES example/example13.cpp ) +set(PYBIND11_FIRSTEXAMPLE 1) +set(PYBIND11_LASTEXAMPLE 13) if(${CUDA_FOUND}) macro(add_library_wrapper) @@ -125,7 +127,8 @@ if(${CUDA_FOUND}) add_definitions(-DPYBIND11_CUDA=1) list(APPEND CUDA_NVCC_FLAGS -std=c++11) list(APPEND CUDA_NVCC_FLAGS -arch=${CUDA_ARCH}) - set(PYBIND11_EXAMPLES ${PYBIND11_EXAMPLES} example/example14.cu) + set(PYBIND11_EXAMPLES ${PYBIND11_EXAMPLES} example/example0.cu) + set(PYBIND11_FIRSTEXAMPLE 0) else() macro(add_library_wrapper) add_library(${ARGV}) @@ -207,9 +210,7 @@ endif() enable_testing() set(RUN_TEST ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example/run_test.py) -list(LENGTH PYBIND11_EXAMPLES PYBIND11_NUMEXAMPLES) -math(EXPR PYBIND11_NUMEXAMPLES "${PYBIND11_NUMEXAMPLES} - 1") -foreach(i RANGE 1 ${PYBIND11_NUMEXAMPLES}) +foreach(i RANGE ${PYBIND11_FIRSTEXAMPLE} ${PYBIND11_LASTEXAMPLE}) add_test(NAME example${i} COMMAND ${RUN_TEST} example${i}) endforeach() diff --git a/example/example.cpp b/example/example.cpp index 2f163cf4e..5e18cacda 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -10,6 +10,9 @@ #include "example.h" +#if (PYBIND11_CUDA==1) +void init_ex0(py::module &); +#endif void init_ex1(py::module &); void init_ex2(py::module &); void init_ex3(py::module &); @@ -23,13 +26,13 @@ void init_ex10(py::module &); void init_ex11(py::module &); void init_ex12(py::module &); void init_ex13(py::module &); -#if (PYBIND11_CUDA==1) -void init_ex14(py::module &); -#endif PYBIND11_PLUGIN(example) { py::module m("example", "pybind example plugin"); +#if (PYBIND11_CUDA==1) + init_ex0(m); +#endif init_ex1(m); init_ex2(m); init_ex3(m); @@ -43,9 +46,6 @@ PYBIND11_PLUGIN(example) { init_ex11(m); init_ex12(m); init_ex13(m); -#if (PYBIND11_CUDA==1) - init_ex14(m); -#endif return m.ptr(); } diff --git a/example/example14.cu b/example/example0.cu similarity index 97% rename from example/example14.cu rename to example/example0.cu index e98cfc0b0..c57e720e8 100644 --- a/example/example14.cu +++ b/example/example0.cu @@ -1,5 +1,5 @@ /* - example/example14.cu -- CUDA acceleratred Mandelbrot example + example/example0.cu -- CUDA acceleratred Mandelbrot example Copyright (c) 2012-2016 Axel Huebl @@ -157,6 +157,6 @@ int mandelbrot() { namespace py = pybind11; -void init_ex14(py::module &m) { +void init_ex0(py::module &m) { m.def("mandelbrot", &mandelbrot, "Start mandelbrot calculation"); } diff --git a/example/example14.py b/example/example0.py similarity index 100% rename from example/example14.py rename to example/example0.py diff --git a/example/example14.ref b/example/example0.ref similarity index 100% rename from example/example14.ref rename to example/example0.ref