From c3e40d3da32e95ebcff189d1ccc8a2dfed4b2f8e Mon Sep 17 00:00:00 2001
From: Sergey Yakubov <sergey.yakubov@desy.de>
Date: Wed, 9 Dec 2020 15:11:29 +0100
Subject: [PATCH] cleanup cmake files, fix bugs

---
 CMakeLists.txt                                | 27 ++++++++-----------
 common/cpp/CMakeLists.txt                     |  2 +-
 consumer/CMakeLists.txt                       |  1 -
 .../python/source_dist_linux/CMakeLists.txt   |  8 +++---
 deploy/build_env/centos/build.sh              |  7 ++---
 .../python/source_dist_linux/CMakeLists.txt   |  7 +++++
 .../api/python/source_dist_linux/setup.py.in  |  4 +--
 tests/automatic/CMakeLists.txt                |  9 ++-----
 .../asapo_fabric/parallel_data_transfer.cpp   |  2 +-
 .../asapo_fabric/simple_data_transfer.cpp     |  2 +-
 .../asapo_fabric/wrong_memory_info.cpp        |  2 +-
 11 files changed, 34 insertions(+), 37 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d905a35ef..b9d5114a5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,18 +30,19 @@ if (APPLE)
     link_directories("/usr/local/lib")
 endif()
 
-
-option(BUILD_TESTS "Uses googletest to build tests" OFF)
-option(BUILD_INTEGRATION_TESTS "Include integration tests (CMAKE >3.7 is needed)" OFF)
-option(BUILD_CPP_DOCS "Uses doxygen to build the C++ documentaion" OFF)
-option(BUILD_BROKER "Build broker" OFF)
-option(BUILD_EVENT_MONITOR_PRODUCER "Build the event monitor producer" OFF)
-option(BUILD_PYTHON_DOCS "Uses sphinx to build the Python documentaion" OFF)
-option(BUILD_CORE "Build core asapo services" ON)
+option(BUILD_CLIENTS_ONLY "Build clients only" OFF)
 option(BUILD_CONSUMER_TOOLS "Build consumer tools" OFF)
+option(BUILD_EVENT_MONITOR_PRODUCER "Build the event monitor producer" OFF)
+
+option(BUILD_TESTS "Build unit tests" OFF)
+option(BUILD_INTEGRATION_TESTS "Include integration tests" OFF)
+
 option(BUILD_EXAMPLES "Build examples" OFF)
 option(INSTALL_EXAMPLES "Install examples" OFF)
 
+option(BUILD_CPP_DOCS "Build the C++ documentaion with doxygen" OFF)
+option(BUILD_PYTHON_DOCS "Build the Python documentaion with sphinx" OFF)
+
 option(ENABLE_LIBFABRIC "Enables LibFabric support for RDMA transfers" OFF)
 option(ENABLE_LIBFABRIC_LOCALHOST "Emulates LibFabric stack over TCP. Only for localhost and testing purposes." OFF)
 
@@ -92,19 +93,13 @@ include(testing_cpp)
 
 include(prepare_asapo)
 
-if(BUILD_CONSUMER_TOOLS)
-    set (BUILD_MONGODB_CLIENTLIB ON)
-endif()
-
 add_subdirectory(common/cpp)
 
 add_subdirectory(producer)
 add_subdirectory(consumer)
 
-if (BUILD_CORE)
-    if (BUILD_BROKER) #TODO: Somehow make it clear that this is needed by examples/consumer/getnext_broker
-        add_subdirectory(broker)
-    endif()
+if (NOT BUILD_CLIENTS_ONLY)
+add_subdirectory(broker)
 add_subdirectory(receiver)
 add_subdirectory(discovery)
 add_subdirectory(authorizer)
diff --git a/common/cpp/CMakeLists.txt b/common/cpp/CMakeLists.txt
index be02a9d8e..4ef322e21 100644
--- a/common/cpp/CMakeLists.txt
+++ b/common/cpp/CMakeLists.txt
@@ -14,7 +14,7 @@ add_subdirectory(src/request)
 
 add_subdirectory(src/asapo_fabric)
 
-if(BUILD_MONGODB_CLIENTLIB)
+if(NOT BUILD_CLIENTS_ONLY)
     add_subdirectory(src/database)
 endif()
 
diff --git a/consumer/CMakeLists.txt b/consumer/CMakeLists.txt
index 9f330fbbd..b0bc14d1f 100644
--- a/consumer/CMakeLists.txt
+++ b/consumer/CMakeLists.txt
@@ -3,6 +3,5 @@ add_subdirectory(api/python)
 
 
 if(BUILD_CONSUMER_TOOLS)
-    set (BUILD_MONGODB ON)
     add_subdirectory(tools)
 endif()
diff --git a/consumer/api/python/source_dist_linux/CMakeLists.txt b/consumer/api/python/source_dist_linux/CMakeLists.txt
index cfe17b654..99d58f4cd 100644
--- a/consumer/api/python/source_dist_linux/CMakeLists.txt
+++ b/consumer/api/python/source_dist_linux/CMakeLists.txt
@@ -6,12 +6,12 @@ ADD_CUSTOM_TARGET(python-dist ALL
         COMMAND ${Python_EXECUTABLE} setup.py sdist
         )
 
-ADD_CUSTOM_TARGET(python-rpm
-        COMMAND PACKAGE_PREFIX=python- python setup.py bdist_rpm --release=${PACKAGE_RELEASE_SUFFIX}
+ADD_CUSTOM_TARGET(python-rpm-consumer
+        COMMAND PACKAGE_PREFIX=python- python setup.py bdist_rpm --release=${PACKAGE_RELEASE_SUFFIX} --requires=numpy
         )
 
-ADD_CUSTOM_TARGET(python3-rpm
-        COMMAND PACKAGE_PREFIX=python3- python3 setup.py bdist_rpm --release=${PACKAGE_RELEASE_SUFFIX}
+ADD_CUSTOM_TARGET(python3-rpm-consumer
+        COMMAND PACKAGE_PREFIX=python3- python3 setup.py bdist_rpm --release=${PACKAGE_RELEASE_SUFFIX} --requires=python3-numpy
         )
 
 #get_property(ASAPO_CONSUMER_LIB TARGET asapo-consumer PROPERTY LOCATION)
diff --git a/deploy/build_env/centos/build.sh b/deploy/build_env/centos/build.sh
index e1e64484a..8f01bd363 100755
--- a/deploy/build_env/centos/build.sh
+++ b/deploy/build_env/centos/build.sh
@@ -5,12 +5,13 @@ cmake \
     -DCMAKE_BUILD_TYPE="Release" \
     -DENABLE_LIBFABRIC=ON \
     -DINSTALL_EXAMPLES=ON \
-    -DBUILD_CORE=OFF \
+    -DBUILD_CLIENTS_ONLY=ON \
     -DPACKAGE_RELEASE_SUFFIX=$OS \
+    -DNUMPY_VERSION=0   \
     -DLIBCURL_DIR=/curl \
     ..
 make package
-cd consumer/api/python/source_dist_linux && make python-rpm && make python3-rpm && cd -
-cd producer/api/python/source_dist_linux && make python-rpm && make python3-rpm
+cd consumer/api/python/source_dist_linux && make python-rpm-consumer && make python3-rpm-consumer && cd -
+cd producer/api/python/source_dist_linux && make python-rpm-producer && make python3-rpm-producer
 
 
diff --git a/producer/api/python/source_dist_linux/CMakeLists.txt b/producer/api/python/source_dist_linux/CMakeLists.txt
index b78e6388c..ff359b363 100644
--- a/producer/api/python/source_dist_linux/CMakeLists.txt
+++ b/producer/api/python/source_dist_linux/CMakeLists.txt
@@ -3,6 +3,13 @@ configure_file(MANIFEST.in MANIFEST.in @ONLY)
 
 file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/setup.py INPUT ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
 
+ADD_CUSTOM_TARGET(python-rpm-producer
+		COMMAND PACKAGE_PREFIX=python- python setup.py bdist_rpm --release=${PACKAGE_RELEASE_SUFFIX} --requires=numpy
+		)
+
+ADD_CUSTOM_TARGET(python3-rpm-producer
+		COMMAND PACKAGE_PREFIX=python3- python3 setup.py bdist_rpm --release=${PACKAGE_RELEASE_SUFFIX} --requires=python3-numpy
+		)
 
 ADD_CUSTOM_TARGET(python-dist-producer ALL
         COMMAND ${Python_EXECUTABLE} setup.py sdist
diff --git a/producer/api/python/source_dist_linux/setup.py.in b/producer/api/python/source_dist_linux/setup.py.in
index bf47d09d1..c129fcdb8 100644
--- a/producer/api/python/source_dist_linux/setup.py.in
+++ b/producer/api/python/source_dist_linux/setup.py.in
@@ -1,6 +1,6 @@
 from distutils.core import setup
 from distutils.core import Extension
-import numpy
+import numpy, os
 
 ext_modules = [
     Extension("asapo_producer", ["asapo_producer.cpp"],
@@ -12,7 +12,7 @@ ext_modules = [
 ]
 
 setup(
-      name ="asapo_producer",
+      name = os.environ.get('PACKAGE_PREFIX', '') + "asapo_producer",
       ext_modules = ext_modules,
       version = "@PYTHON_ASAPO_VERSION@",
       setup_requires=["numpy>=@NUMPY_VERSION@", "cython>=0.28"],
diff --git a/tests/automatic/CMakeLists.txt b/tests/automatic/CMakeLists.txt
index b7282bce4..915166876 100644
--- a/tests/automatic/CMakeLists.txt
+++ b/tests/automatic/CMakeLists.txt
@@ -6,14 +6,9 @@ add_subdirectory(system_io)
 
 add_subdirectory(json_parser)
 
-if(BUILD_MONGODB_CLIENTLIB)
-    add_subdirectory(mongo_db)
-endif()
-
+add_subdirectory(mongo_db)
 
-if(BUILD_BROKER)
-    add_subdirectory(broker)
-endif()
+add_subdirectory(broker)
 
 add_subdirectory(authorizer)
 
diff --git a/tests/automatic/asapo_fabric/parallel_data_transfer.cpp b/tests/automatic/asapo_fabric/parallel_data_transfer.cpp
index 79197f86b..b541b5913 100644
--- a/tests/automatic/asapo_fabric/parallel_data_transfer.cpp
+++ b/tests/automatic/asapo_fabric/parallel_data_transfer.cpp
@@ -5,7 +5,7 @@
 #include <iostream>
 #include <cstring>
 #include <future>
-#include <request/request.h>
+#include "asapo/request/request.h"
 
 using namespace asapo;
 using namespace fabric;
diff --git a/tests/automatic/asapo_fabric/simple_data_transfer.cpp b/tests/automatic/asapo_fabric/simple_data_transfer.cpp
index 742b82f4f..e811d4644 100644
--- a/tests/automatic/asapo_fabric/simple_data_transfer.cpp
+++ b/tests/automatic/asapo_fabric/simple_data_transfer.cpp
@@ -5,7 +5,7 @@
 #include <iostream>
 #include <cstring>
 #include <future>
-#include <request/request.h>
+#include "asapo/request/request.h"
 
 using namespace asapo;
 using namespace fabric;
diff --git a/tests/automatic/asapo_fabric/wrong_memory_info.cpp b/tests/automatic/asapo_fabric/wrong_memory_info.cpp
index 7104b98c6..52259b58e 100644
--- a/tests/automatic/asapo_fabric/wrong_memory_info.cpp
+++ b/tests/automatic/asapo_fabric/wrong_memory_info.cpp
@@ -5,7 +5,7 @@
 #include <iostream>
 #include <cstring>
 #include <future>
-#include <request/request.h>
+#include "asapo/request/request.h"
 
 using namespace asapo;
 using namespace fabric;
-- 
GitLab