(#24810) cigi-cl: new recipe

* Add recipe for library CIGI-CL version 4.0.6a

* PACKAGE LICENSE (KB-H012)
DEFAULT PACKAGE LAYOUT (KB-H013)
PC-FILES (KB-H020)

* No support for Darwin due to use of non-portable pthreads extensions

* Remove 'nullptr'

* Fix: PC-FILES (KB-H020)

* Apply suggestions from code review

Co-authored-by: Uilian Ries <uilianries@gmail.com>

* Simplifying the test package even more

* No longer using 'rm' function

* Rename package

* Fix test_package non C++98 compliant

* INVALID TOPICS (KB-H064): even names and acronyms should be formatted entirely in lowercase

* Update invalid configuration message.

---------

Co-authored-by: Uilian Ries <uilianries@gmail.com>
This commit is contained in:
Luiz Feldmann
2024-08-23 07:49:24 -03:00
committed by GitHub
parent 57d73ad9c8
commit cf1fb2ee1d
6 changed files with 151 additions and 0 deletions

View File

@ -0,0 +1,5 @@
sources:
"4.0.6a":
url:
- "https://master.dl.sourceforge.net/project/cigi/CIGI%20Class%20Library%20%28CCL%29/CCL%20Version%204.0.6a/ccl_4_0%20rev6a.zip"
sha256: "a55099c0418c663e572109bd62ed2f7b411c51af7b404212988e36360e8a13cc"

View File

@ -0,0 +1,102 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, replace_in_file, rmdir
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
from conan.tools.apple import is_apple_os
import os
required_conan_version = ">=1.53.0"
class CigiClConan(ConanFile):
name = "cigi-ccl"
description = "Industry standard communication with compliant image generators"
license = "LGPL-2.1-only"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://cigi.sourceforge.io/product_ccl.php"
topics = ("simulation", "interface engines", "data visualization")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
def layout(self):
cmake_layout(self, src_folder="src")
def validate(self):
if is_apple_os(self):
# CigiOutgoingMsg.cpp:196:38: error: use of undeclared identifier 'PTHREAD_MUTEX_RECURSIVE_NP'
raise ConanInvalidConfiguration(f"{self.settings.os} Conan recipe is not supported on Apple. Contributions are welcome.")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
tc = CMakeToolchain(self)
if is_msvc(self):
tc.variables["USE_MSVC_RUNTIME_LIBRARY_DLL"] = not is_msvc_static_runtime(self)
tc.generate()
def _patch_sources(self):
cmake_lists_fixes = {
# This old CMakeLists.txt had PROJECT() before CMAKE_MINIMUM_REQUIRED(); this order must be inverted
"CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7)": "",
"PROJECT(ccl)": "CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7)\nPROJECT(ccl)",
# Using backslash for path is being interpreted as invalid escape sequence in newer versions of CMake
"Header Files\\": "Header Files/",
"Source Files\\": "Source Files/",
# Incorrectly tries to install both the static and shared targets
"INSTALL(TARGETS cigicl-static cigicl-shared": f"INSTALL(TARGETS {'cigicl-shared' if self.options.shared else 'cigicl-static'}"
}
for old, new in cmake_lists_fixes.items():
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), old, new)
def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.configure()
if self.options.shared:
cmake.build(target="cigicl-shared")
else:
cmake.build(target="cigicl-static")
def package(self):
cmake = CMake(self)
cmake.install()
copy(self, "license.html", self.source_folder, os.path.join(self.package_folder, "licenses"))
copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses"))
rmdir(self, os.path.join(self.package_folder, "share"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
def package_info(self):
self.cpp_info.set_property("pkg_config_name", "cigicl")
build_type_suffix = ""
if self.settings.build_type == "Debug" and self.settings.os == "Windows":
build_type_suffix = "D"
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.extend(["pthread", "m"])
if self.options.shared:
self.cpp_info.libs = ["ccl_dll" + build_type_suffix]
self.cpp_info.defines = ["CCL_DLL"]
else:
self.cpp_info.libs = ["ccl_lib" + build_type_suffix]

View File

@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)
find_package(cigi-ccl REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE cigi-ccl::cigi-ccl)

View File

@ -0,0 +1,25 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"
def requirements(self):
self.requires(self.tested_reference_str)
def layout(self):
cmake_layout(self)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")

View File

@ -0,0 +1,7 @@
#include <cigicl/CigiOutgoingMsg.h>
int main(void) {
CigiOutgoingMsg message;
message.CreateBuffer();
return 0;
}

View File

@ -0,0 +1,3 @@
versions:
"4.0.6a":
folder: all