From 6642cf2d5ebb63627eb248e13464bc8fb62084c8 Mon Sep 17 00:00:00 2001
From: Sergey Yakubov <sergey.yakubov@desy.de>
Date: Fri, 29 Oct 2021 11:15:39 +0200
Subject: [PATCH] move getnext from examples

---
 examples/CMakeLists.txt                       |  5 ++-
 examples/consumer/CMakeLists.txt              |  2 --
 .../consumer/getnext/CMakeLists_separate.in   | 34 -------------------
 tests/automatic/CMakeLists.txt                |  3 +-
 .../automatic/support}/getnext/CMakeLists.txt | 11 +-----
 .../automatic/support}/getnext/Makefile.in    |  0
 .../automatic/support}/getnext/check_linux.sh |  0
 .../support}/getnext/check_windows.bat        |  0
 .../automatic/support}/getnext/getnext.cpp    |  0
 9 files changed, 7 insertions(+), 48 deletions(-)
 delete mode 100644 examples/consumer/getnext/CMakeLists_separate.in
 rename {examples/consumer => tests/automatic/support}/getnext/CMakeLists.txt (52%)
 rename {examples/consumer => tests/automatic/support}/getnext/Makefile.in (100%)
 rename {examples/consumer => tests/automatic/support}/getnext/check_linux.sh (100%)
 rename {examples/consumer => tests/automatic/support}/getnext/check_windows.bat (100%)
 rename {examples/consumer => tests/automatic/support}/getnext/getnext.cpp (100%)

diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 70a3f64fd..26a9ae22a 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -3,6 +3,9 @@ if(BUILD_EXAMPLES)
 endif()
 
 if(BUILD_EXAMPLES OR INSTALL_EXAMPLES)
-    add_subdirectory(producer)
     add_subdirectory(consumer)
 endif()
+
+if(BUILD_EXAMPLES OR INSTALL_EXAMPLES OR BUILD_INTEGRATION_TESTS)
+    add_subdirectory(producer)
+endif()
\ No newline at end of file
diff --git a/examples/consumer/CMakeLists.txt b/examples/consumer/CMakeLists.txt
index 3d5359f70..ef375cd94 100644
--- a/examples/consumer/CMakeLists.txt
+++ b/examples/consumer/CMakeLists.txt
@@ -1,7 +1,5 @@
 find_package(Threads)
 
-add_subdirectory(getnext)
-
 if(BUILD_EXAMPLES AND BUILD_PYTHON)
         add_subdirectory(getnext_python)
 endif()
diff --git a/examples/consumer/getnext/CMakeLists_separate.in b/examples/consumer/getnext/CMakeLists_separate.in
deleted file mode 100644
index 3ced42a8e..000000000
--- a/examples/consumer/getnext/CMakeLists_separate.in
+++ /dev/null
@@ -1,34 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-project(@TARGET_NAME@)
-
-set(CMAKE_CXX_STANDARD 11)
-
-IF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
-    SET( CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
-ENDIF()
-
-find_package (Threads)
-
-if (NOT "$ENV{LIBCURL_DIR}" STREQUAL "")
-	if (NOT LIBCURL_DIR)
-	set(LIBCURL_DIR $ENV{LIBCURL_DIR})
-	endif()
-endif ()
-
-
-set (CMAKE_PREFIX_PATH "${LIBCURL_DIR}")
-find_package (CURL REQUIRED)
-message (STATUS "Found cURL libraries: ${CURL_LIBRARIES}")
-message (STATUS "cURL include: ${CURL_INCLUDE_DIRS}")
-
-
-set(TARGET_NAME ${CMAKE_PROJECT_NAME})
-
-set(SOURCE_FILES @SOURCE_FILES@)
-
-link_directories(@CMAKE_INSTALL_PREFIX@/lib)
-
-add_executable(${TARGET_NAME} ${SOURCE_FILES})
-target_include_directories(${TARGET_NAME} PUBLIC @CMAKE_INSTALL_PREFIX@/include)
-target_link_libraries(${TARGET_NAME} asapo-consumer dl ${CURL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
diff --git a/tests/automatic/CMakeLists.txt b/tests/automatic/CMakeLists.txt
index bf5f7ca3b..9f8a5fc24 100644
--- a/tests/automatic/CMakeLists.txt
+++ b/tests/automatic/CMakeLists.txt
@@ -3,9 +3,10 @@ find_package(Threads)
 
 add_subdirectory(common_scripts)
 
-
+add_subdirectory(support/getnext)
 
 add_subdirectory(common/cpp)
+
 add_subdirectory(system_io)
 
 add_subdirectory(json_parser)
diff --git a/examples/consumer/getnext/CMakeLists.txt b/tests/automatic/support/getnext/CMakeLists.txt
similarity index 52%
rename from examples/consumer/getnext/CMakeLists.txt
rename to tests/automatic/support/getnext/CMakeLists.txt
index 1f6310650..f96714ed7 100644
--- a/examples/consumer/getnext/CMakeLists.txt
+++ b/tests/automatic/support/getnext/CMakeLists.txt
@@ -13,13 +13,4 @@ set_target_properties(${TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
 
 add_script_test("${TARGET_NAME}" "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}")
 
-endif()
-
-set (dir share/asapo/examples/consumer/${TARGET_NAME})
-install(FILES ${SOURCE_FILES} DESTINATION "${dir}")
-
-configure_file(CMakeLists_separate.in CMakeLists_separate.txt @ONLY)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists_separate.txt DESTINATION "${dir}" RENAME CMakeLists.txt)
-
-configure_file(Makefile.in Makefile_LINUX @ONLY)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Makefile_LINUX DESTINATION "${dir}")
+endif()
\ No newline at end of file
diff --git a/examples/consumer/getnext/Makefile.in b/tests/automatic/support/getnext/Makefile.in
similarity index 100%
rename from examples/consumer/getnext/Makefile.in
rename to tests/automatic/support/getnext/Makefile.in
diff --git a/examples/consumer/getnext/check_linux.sh b/tests/automatic/support/getnext/check_linux.sh
similarity index 100%
rename from examples/consumer/getnext/check_linux.sh
rename to tests/automatic/support/getnext/check_linux.sh
diff --git a/examples/consumer/getnext/check_windows.bat b/tests/automatic/support/getnext/check_windows.bat
similarity index 100%
rename from examples/consumer/getnext/check_windows.bat
rename to tests/automatic/support/getnext/check_windows.bat
diff --git a/examples/consumer/getnext/getnext.cpp b/tests/automatic/support/getnext/getnext.cpp
similarity index 100%
rename from examples/consumer/getnext/getnext.cpp
rename to tests/automatic/support/getnext/getnext.cpp
-- 
GitLab