Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gnsstk: add new recipe #20890

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions recipes/gnsstk/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sources:
"14.3.0":
url: "https://github.com/SGL-UT/gnsstk/archive/refs/tags/v14.3.0.tar.gz"
sha256: "4e72f1464ee4ab5ca6250d6e348c67b6437294637008029dc7161be14c285c63"
patches:
"14.3.0":
- patch_file: "patches/14.0-missing-includes.patch"
patch_description: "Fix missing includes"
patch_type: "portability"
- patch_file: "patches/14.0-21-gcc13-include-fix.patch"
patch_description: "Fix a missing include for GCC 13"
patch_type: "portability"
patch_source: "https://github.com/SGL-UT/gnsstk/pull/21"
110 changes: 110 additions & 0 deletions recipes/gnsstk/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import os

from conan import ConanFile
from conan.tools.build import check_min_cppstd, check_max_cppstd
from conan.tools.cmake import CMake, cmake_layout, CMakeToolchain
from conan.tools.files import get, copy, rmdir, save, replace_in_file, export_conandata_patches, apply_conandata_patches, mkdir, rename
from conan.tools.scm import Version

required_conan_version = ">=2.0.9"


class GNSSTkConan(ConanFile):
name = "gnsstk"
description = (
"The GNSSTk core library provides a number of models and algorithms found in GNSS textbooks and classic papers, "
"such as solving for the user position or estimating atmospheric refraction. "
"Common data formats such as RINEX are supported as well."
)
license = "LGPL-3.0-only", "GPL-3.0-only"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/SGL-UT/gnsstk"
topics = ("gnss", "gps", "rinex")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"build_ext": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"build_ext": True,
}
options_description = {
"build_ext": "Build the ext library, in addition to the core library.",
}
implements = ["auto_shared_fpic"]

def export_sources(self):
export_conandata_patches(self)

def layout(self):
cmake_layout(self, src_folder="src")

def validate(self):
# https://github.com/SGL-UT/gnsstk/blob/v14.0.0/BuildSetup.cmake#L54
check_min_cppstd(self, 11)
# https://github.com/SGL-UT/gnsstk/pull/8
check_max_cppstd(self, 17)

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

apply_conandata_patches(self)
# Disable examples and tests
save(self, os.path.join(self.source_folder, "examples", "CMakeLists.txt"), "")
save(self, os.path.join(self.source_folder, "core", "tests", "CMakeLists.txt"), "")
# Disable warnings as errors
replace_in_file(self, os.path.join(self.source_folder, "BuildSetup.cmake"),
"-Werror=return-type -Werror=deprecated", "")
# Allow static library output
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"),
" SHARED ", " ")

def generate(self):
tc = CMakeToolchain(self)
# https://github.com/SGL-UT/gnsstk/blob/v14.0.0/CMakeLists.txt#L41-L51
tc.variables["BUILD_EXT"] = self.options.build_ext
tc.variables["VERSIONED_HEADER_INSTALL"] = True
tc.variables["USE_RPATH"] = False # Adds install directory to RPATH otherwise
# Relocatable shared libs on macOS
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW"
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
for license in ["LICENSE.md", "COPYING.LESSER.md", "COPYING.md"]:
copy(self, license, dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "share"))
if self.settings.os == "Windows" and self.options.shared:
mkdir(self, os.path.join(self.package_folder, "bin"))
rename(self, os.path.join(self.package_folder, "lib", "gnsstk.dll"),
os.path.join(self.package_folder, "bin", "gnsstk.dll"))

def package_info(self):
# https://github.com/SGL-UT/gnsstk/blob/stable/GNSSTKConfig.cmake.in
self.cpp_info.set_property("cmake_file_name", "GNSSTk")
self.cpp_info.set_property("cmake_target_name", "gnsstk")
self.cpp_info.libs = ["gnsstk"]

versioned_dir = f"gnsstk{Version(self.version).major}"
# For compatibility with the default VERSIONED_HEADER_INSTALL=FALSE option
self.cpp_info.includedirs.append(os.path.join("include", versioned_dir))
# The examples use the headers without a directory prefix
self.cpp_info.includedirs.append(os.path.join("include", versioned_dir, "gnsstk"))

if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("m")

if self.settings.os != "Windows":
self.cpp_info.defines.append("GNSSTK_STATIC_DEFINE")
if self.options.build_ext:
self.cpp_info.defines.append("BUILD_EXT")
22 changes: 22 additions & 0 deletions recipes/gnsstk/all/patches/14.0-21-gcc13-include-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
From 16c2c7e5b8dc80bb0eb46792fcb1f6e3dcbffbf4 Mon Sep 17 00:00:00 2001
From: dominformant <26122827+dominformant@users.noreply.github.com>
Date: Thu, 2 Nov 2023 10:33:46 +0100
Subject: [PATCH] Update ObsID.hpp

Add explicit import of cstdint
---
core/lib/GNSSCore/ObsID.hpp | 1 +
1 file changed, 1 insertion(+)

diff --git a/core/lib/GNSSCore/ObsID.hpp b/core/lib/GNSSCore/ObsID.hpp
index d0251fe4c..612e4d2fa 100755
--- a/core/lib/GNSSCore/ObsID.hpp
+++ b/core/lib/GNSSCore/ObsID.hpp
@@ -47,6 +47,7 @@
#ifndef OBSID_HPP
#define OBSID_HPP

+#include <cstdint>
#include <iostream>
#include <iomanip>
#include <sstream>
122 changes: 122 additions & 0 deletions recipes/gnsstk/all/patches/14.0-missing-includes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
diff --git a/core/lib/FileHandling/Binex/BinexFilterOperators.hpp b/core/lib/FileHandling/Binex/BinexFilterOperators.hpp
--- a/core/lib/FileHandling/Binex/BinexFilterOperators.hpp (revision c4b1b21124a093a1ee8f19c09b9d258d4a6d12aa)
+++ b/core/lib/FileHandling/Binex/BinexFilterOperators.hpp (revision 4d5109c4b0be93be0ca906e25e9a0275d308f73e)
@@ -47,7 +47,7 @@
#include "FileFilter.hpp"
#include "BinexData.hpp"

-#include <set>
+#include <functional>

namespace gnsstk
{
diff --git a/core/lib/FileHandling/RINEX/RinexMetFilterOperators.hpp b/core/lib/FileHandling/RINEX/RinexMetFilterOperators.hpp
--- a/core/lib/FileHandling/RINEX/RinexMetFilterOperators.hpp (revision c4b1b21124a093a1ee8f19c09b9d258d4a6d12aa)
+++ b/core/lib/FileHandling/RINEX/RinexMetFilterOperators.hpp (revision 4d5109c4b0be93be0ca906e25e9a0275d308f73e)
@@ -44,6 +44,7 @@
#ifndef GNSSTK_RINEXMETFILTEROPERATORS_HPP
#define GNSSTK_RINEXMETFILTEROPERATORS_HPP

+#include <functional>
#include <set>

#include "CivilTime.hpp"
diff --git a/core/lib/FileHandling/RINEX/RinexNavFilterOperators.hpp b/core/lib/FileHandling/RINEX/RinexNavFilterOperators.hpp
--- a/core/lib/FileHandling/RINEX/RinexNavFilterOperators.hpp (revision c4b1b21124a093a1ee8f19c09b9d258d4a6d12aa)
+++ b/core/lib/FileHandling/RINEX/RinexNavFilterOperators.hpp (revision 4d5109c4b0be93be0ca906e25e9a0275d308f73e)
@@ -51,6 +51,7 @@
#include "RinexNavHeader.hpp"
#include "GPSWeekSecond.hpp"

+#include <functional>
#include <set>

namespace gnsstk
diff --git a/core/lib/FileHandling/RINEX/RinexObsFilterOperators.hpp b/core/lib/FileHandling/RINEX/RinexObsFilterOperators.hpp
--- a/core/lib/FileHandling/RINEX/RinexObsFilterOperators.hpp (revision c4b1b21124a093a1ee8f19c09b9d258d4a6d12aa)
+++ b/core/lib/FileHandling/RINEX/RinexObsFilterOperators.hpp (revision 4d5109c4b0be93be0ca906e25e9a0275d308f73e)
@@ -50,6 +50,7 @@

#include <set>
#include <algorithm>
+#include <functional>

namespace gnsstk
{
diff --git a/core/lib/FileHandling/RINEX3/Rinex3NavFilterOperators.hpp b/core/lib/FileHandling/RINEX3/Rinex3NavFilterOperators.hpp
--- a/core/lib/FileHandling/RINEX3/Rinex3NavFilterOperators.hpp (revision c4b1b21124a093a1ee8f19c09b9d258d4a6d12aa)
+++ b/core/lib/FileHandling/RINEX3/Rinex3NavFilterOperators.hpp (revision 4d5109c4b0be93be0ca906e25e9a0275d308f73e)
@@ -47,6 +47,7 @@
#include <set>
#include <list>
#include <string>
+#include <functional>

#include "FileFilter.hpp"
#include "Rinex3NavData.hpp"
diff --git a/core/lib/FileHandling/RINEX3/Rinex3ObsFilterOperators.hpp b/core/lib/FileHandling/RINEX3/Rinex3ObsFilterOperators.hpp
--- a/core/lib/FileHandling/RINEX3/Rinex3ObsFilterOperators.hpp (revision c4b1b21124a093a1ee8f19c09b9d258d4a6d12aa)
+++ b/core/lib/FileHandling/RINEX3/Rinex3ObsFilterOperators.hpp (revision 4d5109c4b0be93be0ca906e25e9a0275d308f73e)
@@ -46,6 +46,7 @@

#include <set>
#include <algorithm>
+#include <functional>

#include "FileFilter.hpp"
#include "Rinex3ObsData.hpp"
diff --git a/core/lib/NavFilter/CNavFilterData.hpp b/core/lib/NavFilter/CNavFilterData.hpp
--- a/core/lib/NavFilter/CNavFilterData.hpp (revision c4b1b21124a093a1ee8f19c09b9d258d4a6d12aa)
+++ b/core/lib/NavFilter/CNavFilterData.hpp (revision 4d5109c4b0be93be0ca906e25e9a0275d308f73e)
@@ -40,6 +40,7 @@
#define CNAVFILTERDATA_HPP

#include <stdint.h>
+#include <functional>
#include "NavFilterKey.hpp"
#include "PackedNavBits.hpp"

diff --git a/core/lib/NavFilter/LNavEphMaker.hpp b/core/lib/NavFilter/LNavEphMaker.hpp
--- a/core/lib/NavFilter/LNavEphMaker.hpp (revision c4b1b21124a093a1ee8f19c09b9d258d4a6d12aa)
+++ b/core/lib/NavFilter/LNavEphMaker.hpp (revision 4d5109c4b0be93be0ca906e25e9a0275d308f73e)
@@ -39,6 +39,7 @@
#ifndef LNAVEPHMAKER_HPP
#define LNAVEPHMAKER_HPP

+#include <functional>
#include "NavFilter.hpp"
#include "LNavFilterData.hpp"

diff --git a/core/lib/NavFilter/LNavFilterData.hpp b/core/lib/NavFilter/LNavFilterData.hpp
--- a/core/lib/NavFilter/LNavFilterData.hpp (revision c4b1b21124a093a1ee8f19c09b9d258d4a6d12aa)
+++ b/core/lib/NavFilter/LNavFilterData.hpp (revision 4d5109c4b0be93be0ca906e25e9a0275d308f73e)
@@ -40,6 +40,7 @@
#define LNAVFILTERDATA_HPP

#include <stdint.h>
+#include <functional>
#include "NavFilterKey.hpp"

namespace gnsstk
diff --git a/core/lib/NavFilter/LNavOrderFilter.hpp b/core/lib/NavFilter/LNavOrderFilter.hpp
--- a/core/lib/NavFilter/LNavOrderFilter.hpp (revision c4b1b21124a093a1ee8f19c09b9d258d4a6d12aa)
+++ b/core/lib/NavFilter/LNavOrderFilter.hpp (revision 4d5109c4b0be93be0ca906e25e9a0275d308f73e)
@@ -39,6 +39,7 @@
#ifndef LNAVORDERFILTER_HPP
#define LNAVORDERFILTER_HPP

+#include <functional>
#include "NavFilterMgr.hpp"
#include "NavFilter.hpp"
#include "LNavFilterData.hpp"
diff --git a/core/lib/NavFilter/NavOrderFilter.hpp b/core/lib/NavFilter/NavOrderFilter.hpp
--- a/core/lib/NavFilter/NavOrderFilter.hpp (revision c4b1b21124a093a1ee8f19c09b9d258d4a6d12aa)
+++ b/core/lib/NavFilter/NavOrderFilter.hpp (revision 4d5109c4b0be93be0ca906e25e9a0275d308f73e)
@@ -39,6 +39,7 @@
#ifndef NAVORDERFILTER_HPP
#define NAVORDERFILTER_HPP

+#include <functional>
#include "NavFilterMgr.hpp"
#include "NavFilter.hpp"
#include "NavFilterKey.hpp"
8 changes: 8 additions & 0 deletions recipes/gnsstk/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

find_package(GNSSTk REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE gnsstk)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
29 changes: 29 additions & 0 deletions recipes/gnsstk/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os

from conan.tools.files import copy


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):
copy(self, "bahr1620.04o", self.source_folder, self.cpp.build.bindir)
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
9 changes: 9 additions & 0 deletions recipes/gnsstk/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <Rinex3ObsStream.hpp>

using namespace gnsstk;

int main()
{
Rinex3ObsStream rin("bahr1620.04o");
return 0;
}
3 changes: 3 additions & 0 deletions recipes/gnsstk/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"14.3.0":
folder: all