From f7b51fb2904c5340e9acad435680663c62062c44 Mon Sep 17 00:00:00 2001 From: Patrick MADELA <patrick.madela@synchrotron-soleil.fr> Date: Sun, 10 Sep 2023 23:20:20 +0200 Subject: [PATCH] Add conan recipe --- .gitattributes | 1 + .gitignore | 7 ++++++ CMakeLists.txt | 26 ++++++++++++++++++++++ Jenkinsfile | 1 + conanfile.py | 46 +++++++++++++++++++++++++++++++++++++++ test_package/conanfile.py | 17 +++++++++++++++ 6 files changed, 98 insertions(+) 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..7946446 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.project +bin +target +# 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..0ed3b34 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.15) +project(${PROJECT_NAME} CXX) + +find_package(cpptango CONFIG REQUIRED) +find_package(crashreporting2 CONFIG) + +add_compile_definitions(PROJECT_NAME=${PROJECT_NAME}) +add_compile_definitions(PROJECT_VERSION=${PROJECT_VERSION}) +add_compile_definitions(LOG4TANGO_HAVE_INT64_T) +add_compile_definitions(GPIB_DEVICE_OUTSIDE) +add_compile_definitions(USE_HELPERS_DIR) + +file(GLOB_RECURSE sources + ${CMAKE_SOURCE_DIR}/*.cpp +) + +set(includedirs + ${CMAKE_SOURCE_DIR} +) + +add_executable(${EXECUTABLE_NAME} ${sources}) +target_include_directories(${EXECUTABLE_NAME} PRIVATE ${includedirs}) +target_link_libraries(${EXECUTABLE_NAME} PRIVATE cpptango::cpptango) +target_link_libraries(${EXECUTABLE_NAME} PRIVATE crashreporting2::crashreporting2) + +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..2f72eb8 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,46 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps + + +class Keithley428Recipe(ConanFile): + name = "keithley428" + executable = "ds_Keithley428" + version = "1.2.2" + package_type = "application" + user = "soleil" + + license = "GPL-3.0-or-later" + author = "Florent Langlois" + url = "https://gitlab.synchrotron-soleil.fr/software-control-system/tango-devices/measureinstruments/keithley/keithley428.git" + description = "Keithley428 device" + topics = ("control-system", "tango", "device") + + settings = "os", "compiler", "build_type", "arch" + + exports_sources = "CMakeLists.txt", "*.cpp", "*.h" + + def requirements(self): + self.requires("cpptango/[>=9.0]@soleil/stable") + if self.settings.os == "Linux": + self.requires("crashreporting2/[>=1.0]@soleil/stable") + + def layout(self): + cmake_layout(self) + + def generate(self): + deps = CMakeDeps(self) + deps.generate() + tc = CMakeToolchain(self) + tc.variables["PROJECT_NAME"] = self.name + tc.variables["PROJECT_VERSION"] = self.version + tc.variables["EXECUTABLE_NAME"] = self.executable + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() diff --git a/test_package/conanfile.py b/test_package/conanfile.py new file mode 100644 index 0000000..351d242 --- /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 Keithley428TestConan(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_Keithley428 2>&1 | findstr \"usage\"", env="conanrun") + else: + self.run("ds_Keithley428 2>&1 | grep \"usage\"", env="conanrun") -- GitLab