From 813cfbec05a459061640b61d6f62315bb763fd91 Mon Sep 17 00:00:00 2001
From: Cristian C Lalescu <Cristian.Lalescu@ds.mpg.de>
Date: Fri, 8 Mar 2019 13:25:14 +0100
Subject: [PATCH] [broken] setup.py now uses cmake instead of gcc

package is broken, when I try `run_all_tests.sh" I get a linking
problem:

compiling code with command
g++ symmetrize_test-single-v2.21.2.post31+gb443b20.dirty.cpp -o symmetrize_test-single-v2.21.2.post31+gb443b20.dirty -Wall -Wfatal-errors -O2 -g -mtune=native -march=native -ffast-math -std=c++11 -fopenmp -gdwarf-2 -rdynamic -fPIC -I/usr/lib/openmpi/include -I/scratch.local/chichi/installs/include -I/scratch.local/chichi/installs/py3/lib/python3.5/site-packages/bfps-2.21.2.post31+gb443b20.dirty-py3.5.egg/bfps/cpp -L/usr/lib/openmpi/lib -L/scratch.local/chichi/installs/lib -L/scratch.local/chichi/installs/lib64 -Wl,-rpath=/usr/lib/openmpi/lib -Wl,-rpath=/scratch.local/chichi/installs/lib -Wl,-rpath=/scratch.local/chichi/installs/lib64 -L/scratch.local/chichi/installs/py3/lib/python3.5/site-packages/bfps-2.21.2.post31+gb443b20.dirty-py3.5.egg/bfps -Wl,-rpath=/scratch.local/chichi/installs/py3/lib/python3.5/site-packages/bfps-2.21.2.post31+gb443b20.dirty-py3.5.egg/bfps -lbfps -lhdf5 -lfftw3_omp -lfftw3f_omp -lfftw3_mpi -lfftw3 -lfftw3f_mpi -lfftw3f -lmpi_cxx -lmpi -fopenmp
/scratch.local/chichi/installs/py3/lib/python3.5/site-packages/bfps-2.21.2.post31+gb443b20.dirty-py3.5.egg/bfps/libbfps.a(symmetrize_test.cpp.o): In function `symmetrize_test<float>::do_work()':
symmetrize_test.cpp:(.text._ZN15symmetrize_testIfE7do_workEv[_ZN15symmetrize_testIfE7do_workEv]+0x42): undefined reference to `fftw_planner_string_to_flag[abi:cxx11]'
symmetrize_test.cpp:(.text._ZN15symmetrize_testIfE7do_workEv[_ZN15symmetrize_testIfE7do_workEv]+0xc8): undefined reference to `fftw_planner_string_to_flag[abi:cxx11]'
/scratch.local/chichi/installs/py3/lib/python3.5/site-packages/bfps-2.21.2.post31+gb443b20.dirty-py3.5.egg/bfps/libbfps.a(symmetrize_test.cpp.o): In function `symmetrize_test<double>::do_work()':
symmetrize_test.cpp:(.text._ZN15symmetrize_testIdE7do_workEv[_ZN15symmetrize_testIdE7do_workEv]+0x42): undefined reference to `fftw_planner_string_to_flag[abi:cxx11]'
symmetrize_test.cpp:(.text._ZN15symmetrize_testIdE7do_workEv[_ZN15symmetrize_testIdE7do_workEv]+0xc8): undefined reference to `fftw_planner_string_to_flag[abi:cxx11]'
collect2: error: ld returned 1 exit status
---
 CMakeLists_packages.txt |  5 ++++
 setup.py                | 61 ++++++++++++++++++++++-------------------
 2 files changed, 38 insertions(+), 28 deletions(-)

diff --git a/CMakeLists_packages.txt b/CMakeLists_packages.txt
index 7b745a6d..17a1099c 100644
--- a/CMakeLists_packages.txt
+++ b/CMakeLists_packages.txt
@@ -1,7 +1,11 @@
 # vim: syntax=cmake
 
 #cmake_policy(SET CMP0074 NEW)
+
+set(MPI_STATIC ON)
 find_package(MPI REQUIRED)
+
+set(HDF5_STATIC ON)
 find_package(HDF5 REQUIRED)
 
 ###############################################################################
@@ -13,6 +17,7 @@ endif()
 
 ###############################################################################
 # ugly manual settings for FFTW.
+set(FFTW_STATIC ON)
 if (NOT DEFINED ENV{FFTW_BASE})
     message(FATAL_ERROR "Required FFTW_BASE environment variable is not defined.")
 endif()
diff --git a/setup.py b/setup.py
index 34f63082..23f9c266 100644
--- a/setup.py
+++ b/setup.py
@@ -145,7 +145,6 @@ particle_headers = [
         'cpp/particles/particles_field_computer.hpp',
         'cpp/particles/particles_generic_interp.hpp',
         'cpp/particles/particles_inner_computer_empty.hpp',
-        #'cpp/particles/particles_inner_computer.hpp',
         'cpp/particles/particles_input_hdf5.hpp',
         'cpp/particles/particles_output_hdf5.hpp',
         'cpp/particles/particles_output_mpiio.hpp',
@@ -231,33 +230,39 @@ class CompileLibCommand(distutils.cmd.Command):
             eca += ['-DUSE_FFTWESTIMATE']
         if self.disable_fftw_omp:
             eca += ['-DNO_FFTWOMP']
-        for fname in src_file_list:
-            ifile = 'bfps/cpp/' + fname + '.cpp'
-            ofile = 'obj/' + fname + '.o'
-            if not os.path.exists(ofile):
-                need_to_compile_file = True
-            else:
-                need_to_compile_file = False
-                if not need_to_compile:
-                    latest = libtime
-                    dependency_list = get_file_dependency_list(fname)
-                    for depname in dependency_list.split()[1:]:
-                        latest = max(latest,
-                                     datetime.datetime.fromtimestamp(os.path.getctime(depname)))
-                need_to_compile_file = (latest > libtime)
-            if need_to_compile_file:
-                command_strings = [compiler, '-c']
-                command_strings += ['bfps/cpp/' + fname + '.cpp']
-                command_strings += ['-o', 'obj/' + fname + '.o']
-                command_strings += eca
-                command_strings += ['-I' + idir for idir in include_dirs]
-                command_strings.append('-Ibfps/cpp/')
-                print(' '.join(command_strings))
-                subprocess.check_call(command_strings)
-        command_strings = ['ar', 'rvs', 'bfps/libbfps.a']
-        command_strings += ['obj/' + fname + '.o' for fname in src_file_list]
-        print(' '.join(command_strings))
-        subprocess.check_call(command_strings)
+        os.makedirs('cmake_build_dir', exist_ok = True)
+        os.chdir('cmake_build_dir')
+        subprocess.check_call(['cmake', '..'])
+        subprocess.check_call(['make', '-j4'])
+        os.chdir('..')
+        subprocess.check_call(['cp', 'cmake_build_dir/libbfps.a', 'bfps/'])
+        #for fname in src_file_list:
+        #    ifile = 'bfps/cpp/' + fname + '.cpp'
+        #    ofile = 'obj/' + fname + '.o'
+        #    if not os.path.exists(ofile):
+        #        need_to_compile_file = True
+        #    else:
+        #        need_to_compile_file = False
+        #        if not need_to_compile:
+        #            latest = libtime
+        #            dependency_list = get_file_dependency_list(fname)
+        #            for depname in dependency_list.split()[1:]:
+        #                latest = max(latest,
+        #                             datetime.datetime.fromtimestamp(os.path.getctime(depname)))
+        #        need_to_compile_file = (latest > libtime)
+        #    if need_to_compile_file:
+        #        command_strings = [compiler, '-c']
+        #        command_strings += ['bfps/cpp/' + fname + '.cpp']
+        #        command_strings += ['-o', 'obj/' + fname + '.o']
+        #        command_strings += eca
+        #        command_strings += ['-I' + idir for idir in include_dirs]
+        #        command_strings.append('-Ibfps/cpp/')
+        #        print(' '.join(command_strings))
+        #        subprocess.check_call(command_strings)
+        #command_strings = ['ar', 'rvs', 'bfps/libbfps.a']
+        #command_strings += ['obj/' + fname + '.o' for fname in src_file_list]
+        #print(' '.join(command_strings))
+        #subprocess.check_call(command_strings)
 
         ### save compiling information
         pickle.dump(
-- 
GitLab