From 62e1d01bb4293bbb33083e01bbe8d699174dde62 Mon Sep 17 00:00:00 2001
From: ELATTAOUI <xavier.elattaoui@synchrotron-soleil.fr>
Date: Thu, 24 Oct 2024 16:56:14 +0200
Subject: [PATCH] Added conan receipe

---
 .gitattributes            |  1 +
 .gitignore                |  9 +++++++++
 CMakeLists.txt            | 27 +++++++++++++++++++++++++++
 Jenkinsfile               |  1 +
 conanfile.py              | 26 ++++++++++++++++++++++++++
 pom.xml                   |  2 +-
 test_package/conanfile.py | 17 +++++++++++++++++
 7 files changed, 82 insertions(+), 1 deletion(-)
 create mode 100644 .gitattributes
 create mode 100644 .gitignore
 create mode 100644 CMakeLists.txt
 create mode 100644 Jenkinsfile
 create mode 100644 conanfile.py
 create mode 100644 test_package/conanfile.py

diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..94f480d
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto eol=lf
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..00b3211
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+.project
+bin
+target
+build
+CMakeUserPresets.json
+# Ignore all files in folder test_package
+test_package/*
+# except conanfile.py
+!test_package/conanfile.py
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..d04718d
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,27 @@
+cmake_minimum_required(VERSION 3.15)
+project(${PROJECT_NAME} CXX)
+
+find_package(yat4tango CONFIG REQUIRED)
+if (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
+    find_package(crashreporting2 CONFIG)
+endif()
+
+add_compile_definitions(PROJECT_NAME=${PROJECT_NAME})
+add_compile_definitions(PROJECT_VERSION=${PROJECT_VERSION})
+
+file(GLOB_RECURSE sources
+    src/*.cpp
+)
+
+set(includedirs 
+    src
+)
+
+add_executable(${EXECUTABLE_NAME} ${sources})
+target_include_directories(${EXECUTABLE_NAME} PRIVATE ${includedirs})
+target_link_libraries(${EXECUTABLE_NAME} PRIVATE yat4tango::yat4tango)
+if (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
+    target_link_libraries(${EXECUTABLE_NAME} PRIVATE crashreporting2::crashreporting2)
+endif()
+
+install(TARGETS ${EXECUTABLE_NAME} DESTINATION "." RUNTIME DESTINATION bin)
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000..4d99c5a
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1 @@
+conan.create(['el6-gcc44-x86-shared'])
diff --git a/conanfile.py b/conanfile.py
new file mode 100644
index 0000000..0ba948e
--- /dev/null
+++ b/conanfile.py
@@ -0,0 +1,26 @@
+from conan import ConanFile
+
+
+class PREVAC_VCHRecipe(ConanFile):
+    name = "PREVAC_VCH"
+    executable = "ds_PREVAC_VCH"
+    version = "1.0.2"
+    package_type = "application"
+    user = "soleil"
+    python_requires = "base/[>=1.0]@soleil/stable"
+    python_requires_extend = "base.Device"
+
+    license = "GPL-3.0-or-later"
+    author = "X. Elattaoui"
+    url = "<Package recipe repository url here, for issues about the package>"
+    description = "Prevac VCH device"
+    topics = ("control-system", "tango", "device")
+
+    settings = "os", "compiler", "build_type", "arch"
+
+    exports_sources = "CMakeLists.txt", "src/*"
+    
+    def requirements(self):
+        self.requires("yat4tango/[>=1.0]@soleil/stable")
+        if self.settings.os == "Linux":
+            self.requires("crashreporting2/[>=1.0]@soleil/stable")
diff --git a/pom.xml b/pom.xml
index 86e881e..1295ebc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
    </parent>
    <groupId>fr.soleil.device</groupId>
    <artifactId>PREVAC_VCH-${aol}-${mode}</artifactId>
-   <version>1.0.1</version>
+   <version>1.0.2</version>
    <packaging>nar</packaging>
    <name>PREVAC_VCH</name>
    <description>PREVAC_VCH device</description>
diff --git a/test_package/conanfile.py b/test_package/conanfile.py
new file mode 100644
index 0000000..be0c4e2
--- /dev/null
+++ b/test_package/conanfile.py
@@ -0,0 +1,17 @@
+import os
+from conan import ConanFile
+from conan.tools.build import can_run
+
+
+class PREVAC_VCHTestConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+
+    def requirements(self):
+        self.requires(self.tested_reference_str)
+
+    def test(self):
+        if can_run(self):
+            if self.settings.os == "Windows":
+                self.run("ds_PREVAC_VCH 2>&1 | findstr \"usage\"", env="conanrun")
+            else:
+                self.run("ds_PREVAC_VCH 2>&1 | grep \"usage\"", env="conanrun")
-- 
GitLab