From e98fcb0cefc128d74edf3ece59dafe49fc221fbd Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Keck <Jean-Baptiste.Keck@imag.fr>
Date: Wed, 17 Feb 2016 18:06:20 +0100
Subject: [PATCH] Modified CMake and setup.py.in to generate only one swig c++
 lib and use it for c++ mains and tests.

---
 HySoP/CMakeLists.txt                          | 77 +++++++++++++--
 HySoP/setup.py.in                             | 94 +++++++++++++------
 HySoP/src/CMakeLists.txt                      | 52 +---------
 HySoP/src/hysop++/main/poissonSolver.cpp      |  2 +-
 .../src/data/multi_array/multi_array_view.h   |  4 +-
 HySoP/src/hysop++/src/detail/index_seq.h      |  1 -
 HySoP/src/hysop++/src/maths/polynomial.h      |  2 +-
 HySoP/src/hysop++/src/utils/constants.h       |  4 +-
 .../tests/testDiffSolver/CMakeLists.txt       |  1 +
 .../hysop++/tests/testPlanner/CMakeLists.txt  |  1 +
 .../tests/testPoissonSolver/CMakeLists.txt    |  1 +
 .../hysop++/tests/testPolynoms/CMakeLists.txt |  1 +
 HySoP/swig/constants.i                        |  7 ++
 HySoP/swig/cpp2hysop.i                        |  3 +
 HySoP/swig/types.i                            |  7 ++
 15 files changed, 169 insertions(+), 88 deletions(-)
 create mode 100644 HySoP/swig/constants.i
 create mode 100644 HySoP/swig/types.i

diff --git a/HySoP/CMakeLists.txt b/HySoP/CMakeLists.txt
index 0491bc9e1..b7da70264 100644
--- a/HySoP/CMakeLists.txt
+++ b/HySoP/CMakeLists.txt
@@ -19,7 +19,7 @@ if(POLICY CMP0042)
   cmake_policy(SET CMP0042 OLD)
 endif()
 # Set cmake modules directory (i.e. the one which contains all user-defined FindXXX.cmake files among other things)
-set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake)
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
 # Force out-of-source build
 include(OutOfSourceBuild)
 # Some usefull macros
@@ -57,7 +57,7 @@ if(NOT WITH_LIB_CXX)
 endif()
 
 # We can not run scales or fftw without mpi ...
-if(WITH_FFTW OR WITH_SCALES OR WITH_HYSOP_PLUS_PLUS)
+if(WITH_FFTW OR WITH_SCALES)
   set(USE_MPI "ON")
 endif()
 
@@ -90,11 +90,11 @@ set(PACKAGE_NAME HySoP)
 # - Global setup (interp and lib) -
 find_package(PythonFull REQUIRED)
 include(FindPythonModule)
-find_package(SWIG 2.0.7 REQUIRED)
+find_package(SWIG 3.0.8 REQUIRED)
 # WARNING FP : for cmake < 3.0 UseSWIG.cmake
 # does not work properly (bug for swig outdir)
 if(CMAKE_VERSION VERSION_LESS 3.0.0)
-  set(SWIG_USE_FILE ${CMAKE_SOURCE_DIR}/cmake/UseSWIG.cmake)
+    set(SWIG_USE_FILE ${CMAKE_SOURCE_DIR}/CMake/UseSWIG.cmake)
 endif()
 include(${SWIG_USE_FILE})
 
@@ -151,8 +151,28 @@ if(WITH_LIB_FORTRAN OR WITH_LIB_CXX)
   add_subdirectory(src)
 endif()
 
-# ====== Generates python files required for build/install process ======
 
+#C++ variables used by setup.py.in for swig
+set(CMAKE_CXX_FLAGS                "${CMAKE_CXX_FLAGS} -W -Wall -Wextra -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter -std=c++11")
+set(CMAKE_CXX_FLAGS_DEBUG          "${CMAKE_CXX_FLAGS_DEBUG}")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
+set(CMAKE_CXX_FLAGS_RELEASE        "${CMAKE_CXX_FLAGS_RELEASE}")
+set(CMAKE_EXE_LINKER_FLAGS         "${CMAKE_EXE_LINKER_FLAGS}")
+
+if(NOT FFTW_FOUND)
+    find_package(FFTW REQUIRED)
+endif()
+set(CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+set(CXX_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
+set(CXX_EXT_INCLUDES ${PYTHON_INCLUDE_DIR} ${FFTW_INCLUDES})
+set(CXX_EXT_LIBS ${PYTHON_LIBRARIES} ${FFTW_LIBRARIES})
+set(CXX_EXT_LIB_DIRS "")
+set(CXX_EXTRA_DEFINES "")
+
+#swig package name (lib name generated by swig)
+set(CPP_2_HYSOP "cpp2hysop")
+
+# ====== Generates python files required for build/install process ======
 # The file setup.py will be generated from setup.py.in.
 if(EXISTS ${CMAKE_SOURCE_DIR}/setup.py.in)
   message(STATUS "Generate setup.py file ...")
@@ -169,17 +189,58 @@ endif()
 # ====== Create (and setup) build target ======
 set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/build)
 
+
+set(PYTHON_SETUP "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
 if(WITH_LIB_FORTRAN)
   add_custom_target(python-build ALL 
-    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py build config_fc --f90exec=${CMAKE_Fortran_COMPILER}
-    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "build hysop package")
+      COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_SETUP} build config_fc --f90exec=${CMAKE_Fortran_COMPILER}
+      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "build hysop package")
   add_dependencies(python-build ${HYSOP_LIBRARY_NAME})
 else()
   add_custom_target(python-build ALL 
-    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py build
+    COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_SETUP} build
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "build hysop package")
 endif()
 
+# Hysop C++ library is generated in setup.py by swig
+# --- C++ main and tests  ---
+if(WITH_LIB_CXX)
+    set(HYSOP_CXX_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/build/libcpp2hysop.so")
+    set(HYSOP_CXX_LIBRARY_DEP "cpp2hysoplib")
+    add_custom_target(${HYSOP_CXX_LIBRARY_DEP}
+        DEPENDS python-build
+        COMMAND cp `find ${CMAKE_CURRENT_BINARY_DIR}/build -name _${CPP_2_HYSOP}.so` ${HYSOP_CXX_LIBRARY}
+        WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/build"
+        COMMENT "Copy c++ library")
+
+    get_filename_component(CXX_DIR  "${CMAKE_SOURCE_DIR}/src/hysop++" ABSOLUTE)
+    get_filename_component(CXX_MAIN_DIR "${CXX_DIR}/main"             ABSOLUTE)
+    get_filename_component(CXX_TEST_DIR "${CXX_DIR}/tests"            ABSOLUTE)
+    get_filename_component(CXX_SOURCE_DIR "${CXX_DIR}/src"            ABSOLUTE)
+    
+    list(APPEND cxx_local_include_dirs "${CXX_SOURCE_DIR}")
+    include_directories(${cxx_local_include_dirs})
+    include_directories(SYSTEM ${CXX_EXT_INCLUDES})
+    link_directories(${CXX_EXT_LIB_DIRS})
+
+    if(WITH_MAIN_CXX)
+        list(APPEND cxx_executable_sources "${CXX_MAIN_DIR}/poissonSolver.cpp")
+        list(APPEND cxx_executable_sources "${CXX_MAIN_DIR}/diffSolver.cpp")
+        foreach(cxx_main_source ${cxx_executable_sources})
+            get_filename_component(cxx_exec_name "${cxx_main_source}" NAME_WE)
+            add_executable(${cxx_exec_name} ${cxx_main_source})
+            add_dependencies(${cxx_exec_name} ${HYSOP_CXX_LIBRARY_DEP})
+            target_link_libraries(${cxx_exec_name} ${HYSOP_CXX_LIBRARY} ${CXX_EXT_LIBS})
+        endforeach()
+    endif()
+
+    if(WITH_TESTS)
+        add_subdirectory(${CXX_TEST_DIR})
+    endif()
+endif()
+
+
+
 # ====== Create a Target to clean sources (remove .pyc files) and build dir ======
 
 file(GLOB_RECURSE PYCFILES "${CMAKE_SOURCE_DIR}/*.pyc")
diff --git a/HySoP/setup.py.in b/HySoP/setup.py.in
index 6c8cd130b..fc99a5125 100644
--- a/HySoP/setup.py.in
+++ b/HySoP/setup.py.in
@@ -8,38 +8,77 @@ from numpy.distutils.core import setup, Extension
 from numpy.distutils.misc_util import Configuration
 import os
 import glob
+import fnmatch
 
+def parseCmakeVar(var):
+    if var != "":
+        return var.split(';')
+    else:
+        return None
 
-def create_swig_extension(name, src_dirs=None, sources=None):
+def create_swig_extension(name, inc_dirs, src_dirs=None, sources=None):
     """Create a python module from C++ files, using swig
     """
+    
+    swig_dir  = os.path.join('@CMAKE_SOURCE_DIR@', 'swig')
+    swig_config_file = os.path.join(swig_dir, name+'.i')
+
+    include_dirs = set(inc_dirs)
     if sources is None:
         sources = []
-        assert src_dirs is not None
-        for sdir in src_dirs:
-            #sources += glob.glob(os.path.join(sdir, '*.i'))
-            sources += glob.glob(os.path.join(sdir, '*.cpp'))
-    swig_dir = os.path.join('@CMAKE_SOURCE_DIR@', 'swig')
-    sources.insert(0, os.path.join(swig_dir, 'cpp2hysop.i'))
-    inc_dirs = set([])
-    for f in sources:
-        inc_dirs.add(os.path.dirname(f))
-    inc_dirs = list(inc_dirs)
+        if(src_dirs == None):
+            assert(inc_dirs != None)
+            for idir in inc_dirs:
+                #sources += glob.glob(os.path.join(idir, '**/*.cpp'), recursive=True)
+                for root, dirnames, filenames in os.walk(idir):
+                    for filename in fnmatch.filter(filenames, '*.cpp'):
+                        sources.append(os.path.join(root, filename))
+
+        else:
+            for sdir in src_dirs:
+                sources += glob.glob(os.path.join(sdir, '*.cpp'))
+    else:
+        for f in sources:
+            include_dirs.add(os.path.dirname(f))
+
+    sources.insert(0,swig_config_file)
+    include_dirs = list(include_dirs)
+
+    name = 'hysop._' + name
+    swig_opts = ['-I' + swig_dir,
+                 '-c++', '-modern']
+                 #-outdir', '/Users/Franck/toto',
+    
+    extern_includes = parseCmakeVar("@CXX_EXT_INCLUDES@")
+    if(extern_includes != None):
+        for exti in extern_includes:
+            include_dirs.append(exti)
+
+    libraries = parseCmakeVar("@CXX_EXT_LIBS@")
+    library_dirs = parseCmakeVar("@CXX_EXT_LIB_DIRS@")
+    extra_compile_args = parseCmakeVar("@CXX_FLAGS@")
+    extra_link_args = parseCmakeVar("@CXX_LINKER_FLAGS@")
+    define_macros = parseCmakeVar("@CXX_EXTRA_DEFINES@")
+
+    #print "INCLUDE_DIRS=",include_dirs
+    #print "LIBRARIES=",libraries
+    #print "LIBRARY_DIRS=",library_dirs
+    #print "EXTRA_COMPILE_ARGS=",extra_compile_args
+    #print "EXTRA_LINK_ARGS=",extra_link_args
+    #print "DEFINE_MACROS=",define_macros
     #  To avoid -I -I in compiler call, which results in a bug:
     #while inc_dir.count('') > 0:
     #    inc_dir.remove('')
     #inc_dir.append('@CMAKE_BINARY_DIR@/Modules')
-    swig_opts = ['-I' + swig_dir,
-                 #-outdir', '/Users/Franck/toto',
-                 '-c++', '-modern',
-                 ]
-    extra_link_args = []  # ['-lopenblas', '-lgomp']
-    name = 'hysop._' + name
+    
     swig_ext = Extension(name, sources=sources, language='c++',
                          swig_opts=swig_opts,
-                         extra_link_args=extra_link_args,
-                         include_dirs=inc_dirs,
-                         extra_compile_args=[''])
+                         include_dirs=include_dirs,
+                         library_dirs=library_dirs,
+                         libraries=libraries,
+                         define_macros=define_macros,
+                         extra_compile_args=extra_compile_args,
+                         extra_link_args=extra_link_args)
 
     return swig_ext
 
@@ -143,15 +182,16 @@ data_files = []
 
 # --- C++ files and swig interface --
 # path to .i files
-swig_dirs = [os.path.join('@CMAKE_SOURCE_DIR@','swig')]
+swig_include_dirs = [os.path.join('@CMAKE_SOURCE_DIR@','swig')]
 
 # C++ files and swig interface
-cpp_src_dirs = ['src/fftw','src/hysop++']
-for sd in cpp_src_dirs:
-    swig_dirs.append(os.path.join('@CMAKE_SOURCE_DIR@', sd))
+cpp_include_dirs = ['src/fftw','src/hysop++/src']
+for id in cpp_include_dirs:
+    swig_include_dirs.append(os.path.join('@CMAKE_SOURCE_DIR@', id))
+
 ext = {}
-ext['cpp2hysop'] = create_swig_extension(
-    name='cpp2hysop', src_dirs=swig_dirs)
+cpp2hysop = "@CPP_2_HYSOP@"
+ext[cpp2hysop] = create_swig_extension(name=cpp2hysop, inc_dirs=swig_include_dirs)
 for ex in ext:
     ext_modules.append(ext[ex])
 
@@ -169,7 +209,7 @@ if "@WITH_GPU@" is "ON":
               if cl_file[0] != '.' and cl_file[0] != '#' and cl_file[-3:] == '.cl']))
 
 descr = 'Hybrid Computation with Particles.'
-authors = 'G.H Cottet, J.M Etancelin, C.Mimeau, F.Pérignon, C. Picard'
+authors = 'G.H Cottet, J.M Etancelin, J.B Keck, C.Mimeau, F.Pérignon, C. Picard'
 # authors = 'HySoP development team'
 config = Configuration(
     name=name,
diff --git a/HySoP/src/CMakeLists.txt b/HySoP/src/CMakeLists.txt
index da8d5d0d1..9364f9158 100644
--- a/HySoP/src/CMakeLists.txt
+++ b/HySoP/src/CMakeLists.txt
@@ -17,6 +17,11 @@ if(WITH_FFTW)
     ${${HYSOP_LIBRARY_NAME}_SRCDIRS} fftw
     )
 endif()
+if(WITH_LIB_CXX)
+  set(${HYSOP_LIBRARY_NAME}_SRCDIRS
+    ${${HYSOP_LIBRARY_NAME}_SRCDIRS} hysop++/src
+    )
+endif()
 
 #set(SCALES_DIR scalesReduced)
 set(SCALES_DIR scalesInterface)
@@ -63,7 +68,6 @@ set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/Modules)
 #  Add compilation flags:
 #append_Fortran_FLAGS("-Wall -fPIC -ffree-line-length-none -DBLOCKING_SEND_PLUS -DBLOCKING_SEND")
 append_Fortran_FLAGS("-Wall -fPIC -ffree-line-length-none")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -Wextra -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter -std=c++11")
 
 if(USE_MPI)
   # Find MPI for fortran.
@@ -99,52 +103,6 @@ if(WITH_FFTW)
   set(FFTWLIB ${dirlist} CACHE PATH "fftw libraries dir")
 endif()
 
-# --- HySoP++ ---
-if(WITH_LIB_CXX)
-    get_filename_component(CXX_DIR  "${CMAKE_CURRENT_SOURCE_DIR}/hysop++" ABSOLUTE)
-    get_filename_component(CXX_MAIN_DIR "${CXX_DIR}/main"             ABSOLUTE)
-    get_filename_component(CXX_TEST_DIR "${CXX_DIR}/tests"            ABSOLUTE)
-    get_filename_component(CXX_SOURCE_DIR "${CXX_DIR}/src"            ABSOLUTE)
-
-    find_package(FFTW REQUIRED)
-    set(CXX_EXT_INCLUDES ${FFTW_INCLUDES})
-    set(CXX_EXT_LIBS ${FFTW_LIBRARIES})
-    set(CXX_EXT_LIB_DIRS "")
-    
-    file(GLOB_RECURSE cxx_header_files ${CXX_SOURCE_DIR}*.h)
-    file(GLOB_RECURSE cxx_source_files ${CXX_SOURCE_DIR}/*.cpp)
-    
-    list(APPEND cxx_executable_sources "${CXX_MAIN_DIR}/poissonSolver.cpp")
-    list(APPEND cxx_executable_sources "${CXX_MAIN_DIR}/diffSolver.cpp")
-
-    set(cxx_source_files_no_main ${cxx_source_files})
-    foreach(cxx_main_source ${cxx_executable_sources})
-        list(REMOVE_ITEM cxx_source_files_no_main "${cxx_main_source}")
-    endforeach()
-    
-    list(APPEND cxx_local_include_dirs "${CXX_SOURCE_DIR}")
-    include_directories(${cxx_local_include_dirs})
-    include_directories(SYSTEM ${CXX_EXT_INCLUDES})
-    #link_directories(${CXX_EXT_LIB_DIRS})
-
-    set(HYSOP_CXX_LIBRARY "hysop++")
-    add_library(${HYSOP_CXX_LIBRARY} STATIC ${cxx_source_files_no_main} ${cxx_header_files})
-    target_link_libraries(${HYSOP_CXX_LIBRARY} ${CXX_EXT_LIBS})
-
-    if(WITH_MAIN_CXX)
-        foreach(cxx_main_source ${cxx_executable_sources})
-            get_filename_component(cxx_exec_name "${cxx_main_source}" NAME_WE)
-            add_executable(${cxx_exec_name} ${cxx_main_source})
-            target_link_libraries(${cxx_exec_name} ${HYSOP_CXX_LIBRARY} ${CXX_EXT_LIBS})
-        endforeach()
-    endif()
-
-    if(WITH_TESTS)
-        add_subdirectory(${CXX_TEST_DIR})
-    endif()
-
-endif()
-
 # ============= Generates HySoPConfig.hpp =============
 # The file HYSOP_LIBRARY_NAME_defines.hpp will be generated from config.hpp.cmake;
 if(EXISTS ${CMAKE_SOURCE_DIR}/config.hpp.cmake)
diff --git a/HySoP/src/hysop++/main/poissonSolver.cpp b/HySoP/src/hysop++/main/poissonSolver.cpp
index 3ad9b5453..6806499bd 100644
--- a/HySoP/src/hysop++/main/poissonSolver.cpp
+++ b/HySoP/src/hysop++/main/poissonSolver.cpp
@@ -63,7 +63,7 @@ void test(bool includePeriodicBds=false) {
     shape.fill(16);
     domainSize.fill(2*hysop::constants::pi);
 
-    T eps = std::numeric_limits<T>::epsilon();
+    const T eps = std::numeric_limits<T>::epsilon();
     const std::size_t N = std::accumulate(shape.begin(), shape.end(), 1, std::multiplies<std::size_t>());
     
     ref.resize(domainSize).reshape(shape);
diff --git a/HySoP/src/hysop++/src/data/multi_array/multi_array_view.h b/HySoP/src/hysop++/src/data/multi_array/multi_array_view.h
index 75d4fc89b..c23d35371 100644
--- a/HySoP/src/hysop++/src/data/multi_array/multi_array_view.h
+++ b/HySoP/src/hysop++/src/data/multi_array/multi_array_view.h
@@ -35,7 +35,9 @@ namespace hysop {
 
 
         /* Implementation */
-                    
+
+
+// remove boost warning 
 #pragma GCC diagnostic push 
 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
         template <typename T, std::size_t Dim>
diff --git a/HySoP/src/hysop++/src/detail/index_seq.h b/HySoP/src/hysop++/src/detail/index_seq.h
index 2db6ab5c5..e324244ab 100644
--- a/HySoP/src/hysop++/src/detail/index_seq.h
+++ b/HySoP/src/hysop++/src/detail/index_seq.h
@@ -28,7 +28,6 @@ namespace hysop {
             };
         
         
-        
         template <std::size_t count, int i0=0, int step=1>
             using index_seq_gen = typename index_seq_impl<count,step,i0>::type;
         
diff --git a/HySoP/src/hysop++/src/maths/polynomial.h b/HySoP/src/hysop++/src/maths/polynomial.h
index d0bfaa977..e8d151a06 100644
--- a/HySoP/src/hysop++/src/maths/polynomial.h
+++ b/HySoP/src/hysop++/src/maths/polynomial.h
@@ -49,7 +49,7 @@ namespace hysop {
                     Polynomial& applyToCoefficients(const std::function<void(T&)>& func);
                     Polynomial& applyToCoefficients(const std::function<void(T&, const Index<Dim>&)>& func);
                     
-                    /* apply func(T&, const Index<Dim>&, farg0, fargs...) on all coefficients */
+                    /* apply func(T&, const Index<Dim>&, farg0, fargs...) to all coefficients */
                     template <typename Functor, typename Arg0, typename... Args> 
                         Polynomial& applyToCoefficients(const Functor& func, Arg0&& farg0, Args&&... fargs);
                     
diff --git a/HySoP/src/hysop++/src/utils/constants.h b/HySoP/src/hysop++/src/utils/constants.h
index e2bad74ba..344a143e3 100644
--- a/HySoP/src/hysop++/src/utils/constants.h
+++ b/HySoP/src/hysop++/src/utils/constants.h
@@ -7,8 +7,8 @@
 
 namespace hysop {
     namespace constants {
-        static constexpr hysop::types::complex I(0.0L,1.0L);
-        static constexpr hysop::types::complex Z(0.0L,0.0L);
+        static constexpr hysop::types::complex I = hysop::types::complex(0.0L,1.0L);
+        static constexpr hysop::types::complex Z = hysop::types::complex(0.0L,0.0L);
         static constexpr long double pi = acosl(-1.0L);
     }
 }
diff --git a/HySoP/src/hysop++/tests/testDiffSolver/CMakeLists.txt b/HySoP/src/hysop++/tests/testDiffSolver/CMakeLists.txt
index eda82de15..d97166f65 100644
--- a/HySoP/src/hysop++/tests/testDiffSolver/CMakeLists.txt
+++ b/HySoP/src/hysop++/tests/testDiffSolver/CMakeLists.txt
@@ -4,6 +4,7 @@ set(SRCS ${CPP_SRCS})
 
 get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
 add_executable(${test_name} ${SRCS})
+add_dependencies(${test_name} ${HYSOP_CXX_LIBRARY_DEP})
 
 target_link_libraries(${test_name} ${HYSOP_CXX_LIBRARY})
 target_link_libraries(${test_name} ${GTEST_LIBRARIES} ${CXX_EXT_LIBS})
diff --git a/HySoP/src/hysop++/tests/testPlanner/CMakeLists.txt b/HySoP/src/hysop++/tests/testPlanner/CMakeLists.txt
index eda82de15..d97166f65 100644
--- a/HySoP/src/hysop++/tests/testPlanner/CMakeLists.txt
+++ b/HySoP/src/hysop++/tests/testPlanner/CMakeLists.txt
@@ -4,6 +4,7 @@ set(SRCS ${CPP_SRCS})
 
 get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
 add_executable(${test_name} ${SRCS})
+add_dependencies(${test_name} ${HYSOP_CXX_LIBRARY_DEP})
 
 target_link_libraries(${test_name} ${HYSOP_CXX_LIBRARY})
 target_link_libraries(${test_name} ${GTEST_LIBRARIES} ${CXX_EXT_LIBS})
diff --git a/HySoP/src/hysop++/tests/testPoissonSolver/CMakeLists.txt b/HySoP/src/hysop++/tests/testPoissonSolver/CMakeLists.txt
index eda82de15..d97166f65 100644
--- a/HySoP/src/hysop++/tests/testPoissonSolver/CMakeLists.txt
+++ b/HySoP/src/hysop++/tests/testPoissonSolver/CMakeLists.txt
@@ -4,6 +4,7 @@ set(SRCS ${CPP_SRCS})
 
 get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
 add_executable(${test_name} ${SRCS})
+add_dependencies(${test_name} ${HYSOP_CXX_LIBRARY_DEP})
 
 target_link_libraries(${test_name} ${HYSOP_CXX_LIBRARY})
 target_link_libraries(${test_name} ${GTEST_LIBRARIES} ${CXX_EXT_LIBS})
diff --git a/HySoP/src/hysop++/tests/testPolynoms/CMakeLists.txt b/HySoP/src/hysop++/tests/testPolynoms/CMakeLists.txt
index 802cfd2e2..eedc73c4a 100644
--- a/HySoP/src/hysop++/tests/testPolynoms/CMakeLists.txt
+++ b/HySoP/src/hysop++/tests/testPolynoms/CMakeLists.txt
@@ -4,6 +4,7 @@ set(SRCS ${CPP_SRCS})
 
 get_filename_component(test_name ${CMAKE_CURRENT_SOURCE_DIR} NAME)
 add_executable(${test_name} ${SRCS})
+add_dependencies(${test_name} ${HYSOP_CXX_LIBRARY_DEP})
 
 target_link_libraries(${test_name} ${HYSOP_LIBRARY})
 target_link_libraries(${test_name} ${GTEST_LIBRARIES} ${EXT_LIBRARIES})
diff --git a/HySoP/swig/constants.i b/HySoP/swig/constants.i
new file mode 100644
index 000000000..929176357
--- /dev/null
+++ b/HySoP/swig/constants.i
@@ -0,0 +1,7 @@
+
+// -*- C++ -*-
+%{
+  #include "utils/constants.h"
+%}
+
+%include "utils/constants.h"
diff --git a/HySoP/swig/cpp2hysop.i b/HySoP/swig/cpp2hysop.i
index e7478c1ec..abc7b82a9 100644
--- a/HySoP/swig/cpp2hysop.i
+++ b/HySoP/swig/cpp2hysop.i
@@ -3,4 +3,7 @@
 
 %include start.i
 
+%include constants.i
+
 %include fftw.i
+
diff --git a/HySoP/swig/types.i b/HySoP/swig/types.i
new file mode 100644
index 000000000..6a2ef1049
--- /dev/null
+++ b/HySoP/swig/types.i
@@ -0,0 +1,7 @@
+
+// -*- C++ -*-
+%{
+  #include "utils/types.h"
+%}
+
+%include "utils/types.h"
-- 
GitLab