From 7125ecfe466a8e6759fad2c39b2670223f19d467 Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Sun, 25 Jul 2021 12:12:50 +0930 Subject: [PATCH 01/17] Add geotrans package to close #1779 * Add CMakeLists.txt to build geotrans library * Add CCI package configuration * Add functional test package using geotrans library provided sample code --- recipes/geotrans/all/CMakeLists.txt | 24 + recipes/geotrans/all/conandata.yml | 4 + recipes/geotrans/all/conanfile.py | 80 +++ .../geotrans/all/test_package/CMakeLists.txt | 16 + .../geotrans/all/test_package/conanfile.py | 31 + recipes/geotrans/all/test_package/example.cpp | 578 ++++++++++++++++++ recipes/geotrans/config.yml | 3 + 7 files changed, 736 insertions(+) create mode 100644 recipes/geotrans/all/CMakeLists.txt create mode 100644 recipes/geotrans/all/conandata.yml create mode 100644 recipes/geotrans/all/conanfile.py create mode 100644 recipes/geotrans/all/test_package/CMakeLists.txt create mode 100644 recipes/geotrans/all/test_package/conanfile.py create mode 100644 recipes/geotrans/all/test_package/example.cpp create mode 100644 recipes/geotrans/config.yml diff --git a/recipes/geotrans/all/CMakeLists.txt b/recipes/geotrans/all/CMakeLists.txt new file mode 100644 index 0000000000000..a4cf65f3b1307 --- /dev/null +++ b/recipes/geotrans/all/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.4) + +project(geotrans VERSION 3.8 LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +file(GLOB_RECURSE LIB_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/CCS/src/*.cpp") + +add_library(geotrans ${LIB_SOURCES}) + +target_compile_features(geotrans PUBLIC cxx_std_11) +target_compile_options(geotrans PRIVATE -pthread -Wno-deprecated) + +file(GLOB_RECURSE LIB_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/CCS/src/*.h") +set(INCLUDE_DIRS "") + +foreach(file ${LIB_HEADERS}) + get_filename_component(DIR_PATH ${file} PATH) + set(INCLUDE_DIRS ${INCLUDE_DIRS} ${DIR_PATH}) +endforeach() +list(REMOVE_DUPLICATES INCLUDE_DIRS) + +target_include_directories(geotrans PUBLIC include ${INCLUDE_DIRS}) diff --git a/recipes/geotrans/all/conandata.yml b/recipes/geotrans/all/conandata.yml new file mode 100644 index 0000000000000..8d8531d00da07 --- /dev/null +++ b/recipes/geotrans/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "3.8": + url: "https://earth-info.nga.mil/php/download.php?file=wgs-mastertgz" + sha256: "BAA72D3B1AE12F237A8AD30F2DEB3FED2B80FEB759528EA0A72B4B42CB77C565" diff --git a/recipes/geotrans/all/conanfile.py b/recipes/geotrans/all/conanfile.py new file mode 100644 index 0000000000000..f8eb8ff69bda1 --- /dev/null +++ b/recipes/geotrans/all/conanfile.py @@ -0,0 +1,80 @@ +from conans import ConanFile, CMake, tools +import os +import shutil + + +class GeotransConan(ConanFile): + name = "geotrans" + version = "3.8" + license = ( + "NGA GEOTRANS ToS (https://earth-info.nga.mil/php/download.php?file=wgs-terms)" + ) + url = "https://earth-info.nga.mil/" + description = "MSP GEOTRANS is the NGA and DOD approved coordinate converter and datum translator." + topics = ( + "geotrans", + "geodesic", + "geographic", + "coordinate", + "datum", + "geodetic", + "conversion", + "transformation", + ) + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": True, "fPIC": True} + generators = "cmake" + exports_sources = "CMakeLists.txt" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def source(self): + tools.get( + **self.conan_data["sources"][self.version], + strip_root=True, + destination=self._source_subfolder, + filename="master.tgz" + ) + shutil.copy("CMakeLists.txt", self._source_subfolder) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.configure( + source_folder=self._source_subfolder + ) + return self._cmake + + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("*.txt", dst="licenses", src=os.path.join(self._source_subfolder, "GEOTRANS3", "docs")) + self.copy("*", dst="res", src=os.path.join(self._source_subfolder, "data")) + self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "CCS", "src")) + self.copy("*.lib", dst="lib", src="lib", keep_path=False) + self.copy("*.dll", dst="bin", src="lib", keep_path=False) + self.copy("*.so", dst="lib", src="lib", keep_path=False) + self.copy("*.dylib", dst="lib", src="lib", keep_path=False) + self.copy("*.a", dst="lib", src="lib", keep_path=False) + + def package_info(self): + self.cpp_info.resdirs = ["res"] + self.cpp_info.cxxflags = ["-pthread"] + self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.includedirs = [path[0] for path in os.walk("include")] diff --git a/recipes/geotrans/all/test_package/CMakeLists.txt b/recipes/geotrans/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..54ae085be5770 --- /dev/null +++ b/recipes/geotrans/all/test_package/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") +add_executable(example example.cpp) +target_link_libraries(example ${CONAN_LIBS}) + + +# CTest is a testing tool that can be used to test your project. +# enable_testing() +# add_test(NAME example +# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin +# COMMAND example) diff --git a/recipes/geotrans/all/test_package/conanfile.py b/recipes/geotrans/all/test_package/conanfile.py new file mode 100644 index 0000000000000..3861389812b2f --- /dev/null +++ b/recipes/geotrans/all/test_package/conanfile.py @@ -0,0 +1,31 @@ +import os + +from conans import ConanFile, CMake, tools + + +class GeotransTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + default_options = {"geotrans:shared": True} + + def build(self): + cmake = CMake(self) + # Current dir is "test_package/build/" and CMakeLists.txt is + # in "test_package" + cmake.configure() + cmake.build() + + def imports(self): + # self.copy("*.dll", dst="bin", src="bin") + # self.copy("*.dylib*", dst="bin", src="lib") + # self.copy('*.so*', dst='bin', src='lib') + # Import the data files from the package + # The package will not work without these files + self.copy('*', dst='data', src='res') + + def test(self): + if not tools.cross_building(self): + os.chdir("bin") + data_loc = "..{sep}data".format(sep=os.sep) + os.environ["MSPCCS_DATA"] = data_loc + self.run(".{sep}example".format(sep=os.sep)) diff --git a/recipes/geotrans/all/test_package/example.cpp b/recipes/geotrans/all/test_package/example.cpp new file mode 100644 index 0000000000000..6c8030eb1fd90 --- /dev/null +++ b/recipes/geotrans/all/test_package/example.cpp @@ -0,0 +1,578 @@ +// Classification : UNCLASSIFIED + +/****************************************************************************** +* Filename : testCoordinateConversionSample.h +* +* Copyright 2007 BAE Systems National Security Solutions Inc. 1989-2006 +* ALL RIGHTS RESERVED +* +* MODIFICATION HISTORY: +* +* DATE NAME DR# DESCRIPTION +* +* 05/12/10 S Gillis BAEts26542 MSP TS MSL-HAE conversion +* should use CCS +* 06/11/10 S. Gillis BAEts26724 Fixed memory error problem +* when MSPCCS_DATA is not set +* 08/26/11 K Ou BAEts27716 Improved CCS sample code +* +******************************************************************************/ + +#include +#include + +#include "CoordinateConversionService.h" +#include "CoordinateSystemParameters.h" +#include "GeodeticParameters.h" +#include "CoordinateTuple.h" +#include "GeodeticCoordinates.h" +#include "CartesianCoordinates.h" +#include "Accuracy.h" +#include "MGRSorUSNGCoordinates.h" +#include "UTMParameters.h" +#include "UTMCoordinates.h" +#include "CoordinateType.h" +#include "HeightType.h" +#include "CoordinateConversionException.h" +/** + * Sample code to demontrate how to use the MSP Coordinate Conversion Service. + * + * Includes the following conversions: + * + * |=============================|=============================| + * | Source | Target | + * |=============================+=============================| + * | Geodetic (Ellipsoid Height) | Geocentric | + * | Geocentric | Geodetic (Ellipsoid Height) | + * |-----------------------------+-----------------------------| + * | Geocentric | Geodetic (MSL EGM 96 15M) | + * |-----------------------------+-----------------------------| + * | Geodetic (Ellipsoid Height) | Geodetic (MSL EGM 96 15M) | + * | Geodetic (MSL EGM 96 15M) | Geodetic (Ellipsoid Height) | + * |-----------------------------+-----------------------------| + * | Geocentric | UTM | + * |-----------------------------+-----------------------------| + * | Geocentric | MGRS | + * |-----------------------------+-----------------------------| + * + **/ + + +/** + * Function which uses the given Geodetic (Ellipsoid Height) to Geocentric + * Coordinate Conversion Service, 'ccsGeodeticEllipsoidToGeocentric', to + * convert the given lat, lon, and height to x, y, z coordinates. + **/ +void convertGeodeticEllipsoidToGeocentric( + MSP::CCS::CoordinateConversionService& ccsGeodeticEllipsoidToGeocentric, + double lat, + double lon, + double height, + double& x, + double& y, + double& z) +{ + MSP::CCS::Accuracy sourceAccuracy; + MSP::CCS::Accuracy targetAccuracy; + MSP::CCS::GeodeticCoordinates sourceCoordinates( + MSP::CCS::CoordinateType::geodetic, lon, lat, height); + MSP::CCS::CartesianCoordinates targetCoordinates( + MSP::CCS::CoordinateType::geocentric); + + ccsGeodeticEllipsoidToGeocentric.convertSourceToTarget( + &sourceCoordinates, + &sourceAccuracy, + targetCoordinates, + targetAccuracy); + + x = targetCoordinates.x(); + y = targetCoordinates.y(); + z = targetCoordinates.z(); +} + + +/** + * Function which uses the given Geodetic (Ellipsoid Height) to Geocentric + * Coordinate Conversion Service, 'ccsGeodeticEllipsoidToGeocentric', to + * convert the given x, y, z coordinates to a lat, lon, and height. + **/ +void convertGeocentricToGeodeticEllipsoid( + MSP::CCS::CoordinateConversionService& ccsGeodeticEllipsoidToGeocentric, + double x, + double y, + double z, + double& lat, + double& lon, + double& height) +{ + MSP::CCS::Accuracy geocentricAccuracy; + MSP::CCS::Accuracy geodeticAccuracy; + MSP::CCS::CartesianCoordinates geocentricCoordinates( + MSP::CCS::CoordinateType::geocentric, x, y, z); + MSP::CCS::GeodeticCoordinates geodeticCoordinates; + + // Note that the Geodetic (Ellipsoid Height) to Geocentric Coordinate + // Conversion Service is used here in conjunction with the + // convertTargetToSource() method (as opposed to a Geocentric to + // Geodetic (Ellipsoid Height) Coordinate Conversion Service in + // conjunction with the convertSourceToTarget() method) + ccsGeodeticEllipsoidToGeocentric.convertTargetToSource( + &geocentricCoordinates, + &geocentricAccuracy, + geodeticCoordinates, + geodeticAccuracy); + + lat = geodeticCoordinates.latitude(); + lon = geodeticCoordinates.longitude(); + height = geodeticCoordinates.height(); +} + + +/** + * Function which uses the given Geocentric to Geodetic (MSL EGM 96 15M) + * Coordinate Conversion Service, 'ccsGeocentricToGeodeticMslEgm96', to + * convert the given x, y, z coordinates to a lat, lon, and height. + **/ +void convertGeocentricToGeodeticMslEgm96( + MSP::CCS::CoordinateConversionService& ccsGeocentricToGeodeticMslEgm96, + double x, + double y, + double z, + double& lat, + double& lon, + double& height) +{ + MSP::CCS::Accuracy sourceAccuracy; + MSP::CCS::Accuracy targetAccuracy; + MSP::CCS::CartesianCoordinates sourceCoordinates( + MSP::CCS::CoordinateType::geocentric, x, y, z); + MSP::CCS::GeodeticCoordinates targetCoordinates( + MSP::CCS::CoordinateType::geodetic, lon, lat, height); + + ccsGeocentricToGeodeticMslEgm96.convertSourceToTarget( + &sourceCoordinates, + &sourceAccuracy, + targetCoordinates, + targetAccuracy ); + + lat = targetCoordinates.latitude(); + lon = targetCoordinates.longitude(); + height = targetCoordinates.height(); +} + + +/** + * Function which uses the given Geodetic (MSL EGM 96 15M) to Geodetic + * (Ellipsoid Height) Coordinate Conversion Service, + * 'ccsMslEgm96ToEllipsoidHeight', to convert the given MSL height at the + * given lat, lon, to an Ellipsoid height. + **/ +void convertMslEgm96ToEllipsoidHeight( + MSP::CCS::CoordinateConversionService& ccsMslEgm96ToEllipsoidHeight, + double lat, + double lon, + double mslHeight, + double& ellipsoidHeight) +{ + MSP::CCS::Accuracy sourceAccuracy; + MSP::CCS::Accuracy targetAccuracy; + MSP::CCS::GeodeticCoordinates sourceCoordinates( + MSP::CCS::CoordinateType::geodetic, lon, lat, mslHeight); + MSP::CCS::GeodeticCoordinates targetCoordinates; + + ccsMslEgm96ToEllipsoidHeight.convertSourceToTarget( + &sourceCoordinates, + &sourceAccuracy, + targetCoordinates, + targetAccuracy); + + ellipsoidHeight = targetCoordinates.height(); +} + + +/** + * Function which uses the given Geodetic (Ellipsoid Height) to Geodetic + * (MSL EGM 96 15M) Coordinate Conversion Service, + * 'ccsEllipsoidHeightToMslEgm96', to convert the given Ellipsoid height at + * the given lat, lon, to an MSL height. + **/ +void convertEllipsoidHeightToMslEgm96( + MSP::CCS::CoordinateConversionService& ccsEllipsoidHeightToMslEgm96, + double lat, + double lon, + double ellipsoidHeight, + double& mslHeight) +{ + MSP::CCS::Accuracy sourceAccuracy; + MSP::CCS::Accuracy targetAccuracy; + + MSP::CCS::GeodeticCoordinates sourceCoordinates( + MSP::CCS::CoordinateType::geodetic, lon, lat, ellipsoidHeight); + MSP::CCS::GeodeticCoordinates targetCoordinates; + + ccsEllipsoidHeightToMslEgm96.convertSourceToTarget( + &sourceCoordinates, + &sourceAccuracy, + targetCoordinates, + targetAccuracy); + + mslHeight = targetCoordinates.height(); +} + + +/** + * Function which uses the given Geocentric to UTM Coordinate Conversion + * Service, 'ccsGeocentricToUtm', to convert the given x, y, z coordinates + * a UTM zone, hemisphere, Easting and Northing. + **/ +void convertGeocentricToUtm( + MSP::CCS::CoordinateConversionService& ccsGeocentricToUtm, + double x, + double y, + double z, + long& zone, + char& hemisphere, + double& easting, + double& northing) +{ + MSP::CCS::Accuracy sourceAccuracy; + MSP::CCS::Accuracy targetAccuracy; + MSP::CCS::CartesianCoordinates sourceCoordinates( + MSP::CCS::CoordinateType::geocentric, x, y, z); + MSP::CCS::UTMCoordinates targetCoordinates; + + ccsGeocentricToUtm.convertSourceToTarget( + &sourceCoordinates, + &sourceAccuracy, + targetCoordinates, + targetAccuracy); + + zone = targetCoordinates.zone(); + hemisphere = targetCoordinates.hemisphere(); + easting = targetCoordinates.easting(); + northing = targetCoordinates.northing(); +} + + +/** + * Function which uses the given Geocentric to MGRS Coordinate Conversion + * Service, 'ccsGeocentricToMgrs', to convert the given x, y, z coordinates + * to an MGRS string and precision. + **/ +std::string convertGeocentricToMgrs( + MSP::CCS::CoordinateConversionService& ccsGeocentricToMgrs, + double x, + double y, + double z, + MSP::CCS::Precision::Enum& precision) +{ + char* p; + std::string mgrsString; + + MSP::CCS::Accuracy sourceAccuracy; + MSP::CCS::Accuracy targetAccuracy; + MSP::CCS::CartesianCoordinates sourceCoordinates( + MSP::CCS::CoordinateType::geocentric, x, y, z); + MSP::CCS::MGRSorUSNGCoordinates targetCoordinates; + + ccsGeocentricToMgrs.convertSourceToTarget( + &sourceCoordinates, + &sourceAccuracy, + targetCoordinates, + targetAccuracy ); + + // Returned value, 'p', points to targetCoordinate's internal character + // array so assign/copy the character array to mgrsString to avoid + // introducing memory management issues + p = targetCoordinates.MGRSString(); + mgrsString = p; + + precision = targetCoordinates.precision(); + + return mgrsString; +} + + +/****************************************************************************** + * Main function + ******************************************************************************/ + +int main(int argc, char **argv) +{ + const char* WGE = "WGE"; + + // initialize status value to one, indicating an error condition + int status = 1; + + std::cout << "Coordinate Conversion Service Sample Test Driver" << std::endl; + std::cout << std::endl; + + // + // Coordinate System Parameters + // + MSP::CCS::GeodeticParameters ellipsoidParameters( + MSP::CCS::CoordinateType::geodetic, + MSP::CCS::HeightType::ellipsoidHeight); + + MSP::CCS::CoordinateSystemParameters geocentricParameters( + MSP::CCS::CoordinateType::geocentric); + + MSP::CCS::GeodeticParameters mslEgm96Parameters( + MSP::CCS::CoordinateType::geodetic, + MSP::CCS::HeightType::EGM96FifteenMinBilinear); + + MSP::CCS::UTMParameters utmParameters( + MSP::CCS::CoordinateType::universalTransverseMercator, + 1, + 0); + + MSP::CCS::CoordinateSystemParameters mgrsParameters( + MSP::CCS::CoordinateType::militaryGridReferenceSystem); + + std::cout << "Coordinate system parameters set" << '\n'; + // + // Coordinate Conversion Services + // + MSP::CCS::CoordinateConversionService ccsGeodeticEllipsoidToGeocentric( + WGE, &ellipsoidParameters, + WGE, &geocentricParameters); + + MSP::CCS::CoordinateConversionService ccsGeocentricToGeodeticMslEgm96( + WGE, &geocentricParameters, + WGE, &mslEgm96Parameters); + + MSP::CCS::CoordinateConversionService ccsMslEgm96ToEllipsoidHeight( + WGE, &mslEgm96Parameters, + WGE, &ellipsoidParameters); + MSP::CCS::CoordinateConversionService ccsEllipsoidHeightToMslEgm96( + WGE, &ellipsoidParameters, + WGE, &mslEgm96Parameters); + + MSP::CCS::CoordinateConversionService ccsGeocentricToUtm( + WGE, &geocentricParameters, + WGE, &utmParameters); + MSP::CCS::CoordinateConversionService ccsGeocentricToMgrs( + WGE, &geocentricParameters, + WGE, &mgrsParameters); + std::cout << "Coordinate conversion services parameters set" << '\n'; + + try { + + // + // Geodetic (Ellipsoid Height) to Geocentric + // + double lat = 0.56932; + double lon = -2.04552; + double height = 0.0; + + double x, y, z; + + std::cout << "convertGeodeticEllipsoidToGeocentric" << '\n'; + convertGeodeticEllipsoidToGeocentric( + ccsGeodeticEllipsoidToGeocentric, + lat, lon, height, + x, y, z); + + std::cout << "Convert Geodetic (Ellipsoid Height) to Geocentric" << std::endl + << std::endl + << "Lat (radians): " << lat << std::endl + << "Lon (radians): " << lon << std::endl + << "Height(m): " << height << std::endl + << std::endl + << "x: " << x << std::endl + << "y: " << y << std::endl + << "z: " << z << std::endl + << std::endl; + + // + // Geocentric to Geodetic (Ellipsoid Height) + // + + // function convertGeocentricToGeodeticEllipsoid() reuses the + // ccsGeodeticEllipsoidToGeocentric instance to perform the reverse + // conversion + convertGeocentricToGeodeticEllipsoid( + ccsGeodeticEllipsoidToGeocentric, + x, y, z, + lat, lon, height); + + std::cout << "Revert Geocentric To Geodetic (Ellipsoid Height): " << std::endl + << std::endl + << "x: " << x << std::endl + << "y: " << y << std::endl + << "z: " << z << std::endl + << std::endl + << "Lat (radians): " << lat << std::endl + << "Lon (radians): " << lon << std::endl + << "Height(m): " << height << std::endl + << std::endl; + + + // reuse ccsGeodeticEllipsoidToGeocentric instance to perform another + // Geodetic (Ellipsoid Height) to Geocentric conversions + lat = 0.76388; + lon = 0.60566; + height = 11.0; + + convertGeodeticEllipsoidToGeocentric( + ccsGeodeticEllipsoidToGeocentric, + lat, lon, height, + x, y, z); + + std::cout << "Convert Geodetic (Ellipsoid Height) to Geocentric" << std::endl + << std::endl + << "Lat (radians): " << lat << std::endl + << "Lon (radians): " << lon << std::endl + << "Height(m): " << height << std::endl + << std::endl + << "x: " << x << std::endl + << "y: " << y << std::endl + << "z: " << z << std::endl + << std::endl; + + // reuse ccsGeodeticEllipsoidToGeocentric instance to perform another + // Geodetic (Ellipsoid Height) to Geocentric conversions + lat = 0.71458; + lon = 0.88791; + height = 22.0; + + convertGeodeticEllipsoidToGeocentric( + ccsGeodeticEllipsoidToGeocentric, + lat, lon, height, + x, y, z); + + std::cout << "Convert Geodetic (Ellipsoid Height) to Geocentric" << std::endl + << std::endl + << "Lat (radians): " << lat << std::endl + << "Lon (radians): " << lon << std::endl + << "Height(m): " << height << std::endl + << std::endl + << "x: " << x << std::endl + << "y: " << y << std::endl + << "z: " << z << std::endl + << std::endl; + + // + // Geocentric to Geodetic (MSL EGM96 15M) + // + x = 3851747; + y = 3719589; + z = 3454013; + + double mslHeight; + + convertGeocentricToGeodeticMslEgm96( + ccsGeocentricToGeodeticMslEgm96, + x, y, z, + lat, lon, mslHeight); + + std::cout << "Convert Geocentric To Geodetic MSL EGM96: " << std::endl + << std::endl + << "x: " << x << std::endl + << "y: " << y << std::endl + << "z: " << z << std::endl + << std::endl + << "Lat (radians): " << lat << std::endl + << "Lon (radians): " << lon << std::endl + << "MSL EGM96 15M Height: " << mslHeight << std::endl + << std::endl; + + // + // Geodetic (MSL EGM96 15M) to Geodetic (Ellipsoid Height) + // + convertMslEgm96ToEllipsoidHeight( + ccsMslEgm96ToEllipsoidHeight, + lat, lon, mslHeight, + height); + + std::cout << "Convert Geodetic (MSL EMG96 15M Height) To Geodetic (Ellipsoid Height)" << std::endl + << std::endl + << "Lat (radians): " << lat << std::endl + << "Lon (radians): " << lon << std::endl + << "MSL EGM96 15M Height: " << mslHeight << std::endl + << std::endl + << "Ellipsoid Height: " << height << std::endl + << std::endl; + + // + // Geodetic (Ellipsoid Height) to Geodetic (MSL EMG96 15M) + // + convertEllipsoidHeightToMslEgm96( + ccsEllipsoidHeightToMslEgm96, + lat, lon, height, + mslHeight); + + std::cout << "Revert Geodetic (Ellipsoid Height) To Geodetic (MSL EGM96 15M) Height" << std::endl + << std::endl + << "Lat (radians): " << lat << std::endl + << "Lon (radians): " << lon << std::endl + << "Height(m): " << height << std::endl + << std::endl + << "MSL EGM96 15M Height: " << mslHeight << std::endl + << std::endl; + + // + // Geocentric to UTM + // + long zone; + char hemi; + double easting, northing; + convertGeocentricToUtm( + ccsGeocentricToUtm, + x, y, z, + zone, hemi, easting, northing); + + std::cout << "Convert Geocentric To UTM: " << std::endl + << std::endl + << "x: " << x << std::endl + << "y: " << y << std::endl + << "z: " << z << std::endl + << std::endl + << "Zone: " << zone << std::endl + << "Hemisphere: " << hemi << std::endl + << "Easting: " << easting << std::endl + << "Northing: " << northing<< std::endl + << std::endl; + + // + // Geocentric to MGRS + // + std::string mgrsString; + MSP::CCS::Precision::Enum precision; + + mgrsString = convertGeocentricToMgrs( + ccsGeocentricToMgrs, + x, y, z, + precision); + + std::cout << "Convert Geocentric To MGRS: " << std::endl + << std::endl + << "x: " << x << std::endl + << "y: " << y << std::endl + << "z: " << z << std::endl + << std::endl + << "MGRS: " << mgrsString << std::endl + << "Precision: " << precision << std::endl + << std::endl; + + // set status value to zero to indicate successful completion + status = 0; + + } catch(MSP::CCS::CoordinateConversionException& e) { + // catch and report any exceptions thrown by the Coordinate + // Conversion Service + std::cerr + << "ERROR: Coordinate Conversion Service exception encountered - " + << e.getMessage() + << std::endl; + + } catch(std::exception& e) { + // catch and report any unexpected exceptions thrown + std::cerr << "ERROR: Unexpected exception encountered - " + << e.what() << std::endl; + } + + return status; +} + +// Classification : UNCLASSIFIED diff --git a/recipes/geotrans/config.yml b/recipes/geotrans/config.yml new file mode 100644 index 0000000000000..a874c72606420 --- /dev/null +++ b/recipes/geotrans/config.yml @@ -0,0 +1,3 @@ +versions: + "3.8": + folder: all From 8b7c205498fe3996c19531cb60ac9f76ac936d57 Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Mon, 26 Jul 2021 00:44:22 +0930 Subject: [PATCH 02/17] Modify CMake recipe to build both libraries instead of just one * Build both libMSPdtcc and libMSPCoordinateConversionService to remain consistent with the upstream package. This is a change from the previous state in which both of these libraries were bundled into one. * Remove extraneous comments from test_package conanfile * Remove extraneous print statements from test_package example.cpp --- recipes/geotrans/all/CMakeLists.txt | 66 ++++++++++++++----- .../geotrans/all/test_package/conanfile.py | 6 +- recipes/geotrans/all/test_package/example.cpp | 2 - 3 files changed, 52 insertions(+), 22 deletions(-) diff --git a/recipes/geotrans/all/CMakeLists.txt b/recipes/geotrans/all/CMakeLists.txt index a4cf65f3b1307..5d37068f927c1 100644 --- a/recipes/geotrans/all/CMakeLists.txt +++ b/recipes/geotrans/all/CMakeLists.txt @@ -1,24 +1,60 @@ cmake_minimum_required(VERSION 3.4) - project(geotrans VERSION 3.8 LANGUAGES CXX) - +#### +# Conan +#### include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -file(GLOB_RECURSE LIB_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/CCS/src/*.cpp") - -add_library(geotrans ${LIB_SOURCES}) - -target_compile_features(geotrans PUBLIC cxx_std_11) -target_compile_options(geotrans PRIVATE -pthread -Wno-deprecated) - -file(GLOB_RECURSE LIB_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/CCS/src/*.h") -set(INCLUDE_DIRS "") +#### +# Directories +#### + +set(DTCCDIR "${CMAKE_CURRENT_SOURCE_DIR}/CCS/src/dtcc/CoordinateSystems") +set(CCSERVICEDIR "${CMAKE_CURRENT_SOURCE_DIR}/CCS/src") +set(SRCDIR "${CMAKE_CURRENT_SOURCE_DIR}/GEOTRANS3/java_gui/geotrans3/jni") + +#### +# Sources +#### +file(GLOB_RECURSE DTCCSRCS "${DTCCDIR}/*.cpp") +set(CCSSRCS "${CCSERVICEDIR}/CoordinateConversion/CoordinateConversionService.cpp") +file(GLOB_RECURSE CCSERVICESRCS "${CCSERVICEDIR}/dtcc/*.cpp") +list(FILTER CCSERVICESRCS EXCLUDE REGEX ".*${DTCCDIR}.*") +set(SRCS "${SRCDIR}/strtoval.cpp" "${SRCDIR}/fiomeths.cpp") + +#### +# Includes +#### + +# Construct DTCC includes +file(GLOB_RECURSE DTCC_HEADERS "${DTCCDIR}/*.h") +set(DTTCINCS "") +foreach(file ${DTCC_HEADERS}) + get_filename_component(DIR_PATH ${file} PATH) + set(DTTCINCS ${DTTCINCS} ${DIR_PATH}) +endforeach() +list(REMOVE_DUPLICATES DTTCINCS) -foreach(file ${LIB_HEADERS}) +# Construct CCS includes. This is all headers not in DTTCINCS +file(GLOB_RECURSE CCS_HEADERS "${CCSERVICEDIR}/*.h") +set(INCS ${SRCDIR}) +foreach(file ${CCS_HEADERS}) get_filename_component(DIR_PATH ${file} PATH) - set(INCLUDE_DIRS ${INCLUDE_DIRS} ${DIR_PATH}) + set(INCS ${INCS} ${DIR_PATH}) endforeach() -list(REMOVE_DUPLICATES INCLUDE_DIRS) +list(REMOVE_DUPLICATES INCS) +list(FILTER INCS EXCLUDE REGEX ".*${DTCCDIR}.*") + + +# Create libMSPdtcc +add_library(MSPdtcc ${DTCCSRCS} ${CCSERVICESRCS}) +target_compile_features(MSPdtcc PUBLIC cxx_std_11) +target_compile_options(MSPdtcc PRIVATE -pthread -Wno-deprecated) +target_include_directories(MSPdtcc PUBLIC include ${DTTCINCS} ${INCS}) -target_include_directories(geotrans PUBLIC include ${INCLUDE_DIRS}) +# Create libMSPCoordinateConversionService +add_library(MSPCoordinateConversionService ${CCSSRCS} ${CCSERVICESRCS}) +target_compile_features(MSPCoordinateConversionService PUBLIC cxx_std_11) +target_compile_options(MSPCoordinateConversionService PRIVATE -pthread -Wno-deprecated) +target_include_directories(MSPCoordinateConversionService PUBLIC include ${DTTCINCS} ${INCS}) diff --git a/recipes/geotrans/all/test_package/conanfile.py b/recipes/geotrans/all/test_package/conanfile.py index 3861389812b2f..2e53a5968cd7d 100644 --- a/recipes/geotrans/all/test_package/conanfile.py +++ b/recipes/geotrans/all/test_package/conanfile.py @@ -1,5 +1,4 @@ import os - from conans import ConanFile, CMake, tools @@ -16,12 +15,9 @@ def build(self): cmake.build() def imports(self): - # self.copy("*.dll", dst="bin", src="bin") - # self.copy("*.dylib*", dst="bin", src="lib") - # self.copy('*.so*', dst='bin', src='lib') # Import the data files from the package # The package will not work without these files - self.copy('*', dst='data', src='res') + self.copy("*", dst="data", src="res") def test(self): if not tools.cross_building(self): diff --git a/recipes/geotrans/all/test_package/example.cpp b/recipes/geotrans/all/test_package/example.cpp index 6c8030eb1fd90..dcdb44554da17 100644 --- a/recipes/geotrans/all/test_package/example.cpp +++ b/recipes/geotrans/all/test_package/example.cpp @@ -329,7 +329,6 @@ int main(int argc, char **argv) MSP::CCS::CoordinateSystemParameters mgrsParameters( MSP::CCS::CoordinateType::militaryGridReferenceSystem); - std::cout << "Coordinate system parameters set" << '\n'; // // Coordinate Conversion Services // @@ -354,7 +353,6 @@ int main(int argc, char **argv) MSP::CCS::CoordinateConversionService ccsGeocentricToMgrs( WGE, &geocentricParameters, WGE, &mgrsParameters); - std::cout << "Coordinate conversion services parameters set" << '\n'; try { From 6638006f94a6e1f1ec5d649077063f51de501497 Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Mon, 26 Jul 2021 23:54:28 +0930 Subject: [PATCH 03/17] Add component definitions to package_info * Add component definitions to package_info. This will allow cmake utilities like find_package to search for and find the package and its component libraries, which will enable linking against these individually for more granular control. --- recipes/geotrans/all/conanfile.py | 41 +++++++++++++------ .../geotrans/all/test_package/CMakeLists.txt | 18 ++++---- .../geotrans/all/test_package/conanfile.py | 7 +++- 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/recipes/geotrans/all/conanfile.py b/recipes/geotrans/all/conanfile.py index f8eb8ff69bda1..de0256ec584ba 100644 --- a/recipes/geotrans/all/conanfile.py +++ b/recipes/geotrans/all/conanfile.py @@ -32,10 +32,6 @@ class GeotransConan(ConanFile): def _source_subfolder(self): return "source_subfolder" - @property - def _build_subfolder(self): - return "build_subfolder" - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -53,20 +49,23 @@ def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) - self._cmake.configure( - source_folder=self._source_subfolder - ) + self._cmake.configure(source_folder=self._source_subfolder) return self._cmake - def build(self): cmake = self._configure_cmake() cmake.build() def package(self): - self.copy("*.txt", dst="licenses", src=os.path.join(self._source_subfolder, "GEOTRANS3", "docs")) + self.copy( + "*.txt", + dst="licenses", + src=os.path.join(self._source_subfolder, "GEOTRANS3", "docs"), + ) self.copy("*", dst="res", src=os.path.join(self._source_subfolder, "data")) - self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "CCS", "src")) + self.copy( + "*.h", dst="include", src=os.path.join(self._source_subfolder, "CCS", "src") + ) self.copy("*.lib", dst="lib", src="lib", keep_path=False) self.copy("*.dll", dst="bin", src="lib", keep_path=False) self.copy("*.so", dst="lib", src="lib", keep_path=False) @@ -75,6 +74,22 @@ def package(self): def package_info(self): self.cpp_info.resdirs = ["res"] - self.cpp_info.cxxflags = ["-pthread"] - self.cpp_info.libs = tools.collect_libs(self) - self.cpp_info.includedirs = [path[0] for path in os.walk("include")] + self.cpp_info.name = "geotrans" + self.cpp_info.names["cmake_find_package"] = "geotrans" + self.cpp_info.names["cmake_find_package_multi"] = "geotrans" + self.cpp_info.components["dtcc"].names["cmake_find_package"] = "dtcc" + self.cpp_info.components["dtcc"].names["cmake_find_package_multi"] = "dtcc" + self.cpp_info.components["dtcc"].libs = ["MSPdtcc"] + self.cpp_info.components["dtcc"].includedirs = [ + path[0] + for path in os.walk(os.path.join("include", "dtcc", "CoordinateSystems")) + ] + self.cpp_info.components["dtcc"].cxxflags = ["-pthread"] + self.cpp_info.components["ccs"].names["cmake_find_package"] = "ccs" + self.cpp_info.components["ccs"].names["cmake_find_package_multi"] = "ccs" + self.cpp_info.components["ccs"].libs = ["MSPCoordinateConversionService"] + self.cpp_info.components["ccs"].requires = ["dtcc"] + self.cpp_info.components["ccs"].includedirs = [ + path[0] for path in os.walk("include") + ] + self.cpp_info.components["ccs"].cxxflags = ["-pthread"] diff --git a/recipes/geotrans/all/test_package/CMakeLists.txt b/recipes/geotrans/all/test_package/CMakeLists.txt index 54ae085be5770..02a8e4e7bd3b4 100644 --- a/recipes/geotrans/all/test_package/CMakeLists.txt +++ b/recipes/geotrans/all/test_package/CMakeLists.txt @@ -3,14 +3,14 @@ project(PackageTest CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() +include(${CMAKE_BINARY_DIR}/conan_paths.cmake) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") -add_executable(example example.cpp) -target_link_libraries(example ${CONAN_LIBS}) - +find_package(geotrans REQUIRED COMPONENTS dtcc ccs) +# +set(EXTERNAL_LIBS + geotrans::dtcc + geotrans::ccs + ) -# CTest is a testing tool that can be used to test your project. -# enable_testing() -# add_test(NAME example -# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin -# COMMAND example) +add_executable(example example.cpp) +target_link_libraries(example ${EXTERNAL_LIBS}) diff --git a/recipes/geotrans/all/test_package/conanfile.py b/recipes/geotrans/all/test_package/conanfile.py index 2e53a5968cd7d..29f7f9db6fe33 100644 --- a/recipes/geotrans/all/test_package/conanfile.py +++ b/recipes/geotrans/all/test_package/conanfile.py @@ -4,8 +4,11 @@ class GeotransTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake" - default_options = {"geotrans:shared": True} + generators = ( + "cmake", + "cmake_find_package", + "cmake_paths", + ) def build(self): cmake = CMake(self) From b11f52ca1199aed161e787d577ea13baadf1c67a Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Tue, 27 Jul 2021 00:37:26 +0930 Subject: [PATCH 04/17] Rectify errors identified by cci hooks * No longer a shared library by default * Update homepage metadata * Update URL metadata --- recipes/geotrans/all/conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/geotrans/all/conanfile.py b/recipes/geotrans/all/conanfile.py index de0256ec584ba..851d7d6c06b4d 100644 --- a/recipes/geotrans/all/conanfile.py +++ b/recipes/geotrans/all/conanfile.py @@ -9,7 +9,8 @@ class GeotransConan(ConanFile): license = ( "NGA GEOTRANS ToS (https://earth-info.nga.mil/php/download.php?file=wgs-terms)" ) - url = "https://earth-info.nga.mil/" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://earth-info.nga.mil/" description = "MSP GEOTRANS is the NGA and DOD approved coordinate converter and datum translator." topics = ( "geotrans", @@ -23,7 +24,7 @@ class GeotransConan(ConanFile): ) settings = "os", "compiler", "build_type", "arch" options = {"shared": [True, False], "fPIC": [True, False]} - default_options = {"shared": True, "fPIC": True} + default_options = {"shared": False, "fPIC": True} generators = "cmake" exports_sources = "CMakeLists.txt" _cmake = None @@ -74,7 +75,6 @@ def package(self): def package_info(self): self.cpp_info.resdirs = ["res"] - self.cpp_info.name = "geotrans" self.cpp_info.names["cmake_find_package"] = "geotrans" self.cpp_info.names["cmake_find_package_multi"] = "geotrans" self.cpp_info.components["dtcc"].names["cmake_find_package"] = "dtcc" From cd1c510bd187ea9a972530501f23f85dfe73c000 Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Fri, 30 Jul 2021 23:30:33 +0930 Subject: [PATCH 05/17] Apply suggestions from code review Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Co-authored-by: Anonymous Maarten --- recipes/geotrans/all/CMakeLists.txt | 10 +++++++++- recipes/geotrans/all/conanfile.py | 16 +++++---------- .../geotrans/all/test_package/CMakeLists.txt | 9 ++------- .../geotrans/all/test_package/conanfile.py | 20 ++++--------------- 4 files changed, 20 insertions(+), 35 deletions(-) diff --git a/recipes/geotrans/all/CMakeLists.txt b/recipes/geotrans/all/CMakeLists.txt index 5d37068f927c1..0523159e2e3ac 100644 --- a/recipes/geotrans/all/CMakeLists.txt +++ b/recipes/geotrans/all/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.4) +cmake_minimum_required(VERSION 3.8) project(geotrans VERSION 3.8 LANGUAGES CXX) #### # Conan @@ -58,3 +58,11 @@ add_library(MSPCoordinateConversionService ${CCSSRCS} ${CCSERVICESRCS}) target_compile_features(MSPCoordinateConversionService PUBLIC cxx_std_11) target_compile_options(MSPCoordinateConversionService PRIVATE -pthread -Wno-deprecated) target_include_directories(MSPCoordinateConversionService PUBLIC include ${DTTCINCS} ${INCS}) + +include(GnuInstallDirs) +install(TARGETS MSPdtcc MSPCoordinateConversionService + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) +install(DIRECTORY data/ DESTINATION res) diff --git a/recipes/geotrans/all/conanfile.py b/recipes/geotrans/all/conanfile.py index 851d7d6c06b4d..acf16bcb150ce 100644 --- a/recipes/geotrans/all/conanfile.py +++ b/recipes/geotrans/all/conanfile.py @@ -63,17 +63,11 @@ def package(self): dst="licenses", src=os.path.join(self._source_subfolder, "GEOTRANS3", "docs"), ) - self.copy("*", dst="res", src=os.path.join(self._source_subfolder, "data")) - self.copy( - "*.h", dst="include", src=os.path.join(self._source_subfolder, "CCS", "src") - ) - self.copy("*.lib", dst="lib", src="lib", keep_path=False) - self.copy("*.dll", dst="bin", src="lib", keep_path=False) - self.copy("*.so", dst="lib", src="lib", keep_path=False) - self.copy("*.dylib", dst="lib", src="lib", keep_path=False) - self.copy("*.a", dst="lib", src="lib", keep_path=False) + cmake = self._configure_cmake() + cmake.install() def package_info(self): + self.user_info.data_path = os.path.join(self.package_folder, "res") self.cpp_info.resdirs = ["res"] self.cpp_info.names["cmake_find_package"] = "geotrans" self.cpp_info.names["cmake_find_package_multi"] = "geotrans" @@ -84,7 +78,7 @@ def package_info(self): path[0] for path in os.walk(os.path.join("include", "dtcc", "CoordinateSystems")) ] - self.cpp_info.components["dtcc"].cxxflags = ["-pthread"] + self.cpp_info.components["dtcc"].system_libs = ["pthread"] self.cpp_info.components["ccs"].names["cmake_find_package"] = "ccs" self.cpp_info.components["ccs"].names["cmake_find_package_multi"] = "ccs" self.cpp_info.components["ccs"].libs = ["MSPCoordinateConversionService"] @@ -92,4 +86,4 @@ def package_info(self): self.cpp_info.components["ccs"].includedirs = [ path[0] for path in os.walk("include") ] - self.cpp_info.components["ccs"].cxxflags = ["-pthread"] + self.cpp_info.components["ccs"].system_libs = ["pthread"] diff --git a/recipes/geotrans/all/test_package/CMakeLists.txt b/recipes/geotrans/all/test_package/CMakeLists.txt index 02a8e4e7bd3b4..63d56fa03bc28 100644 --- a/recipes/geotrans/all/test_package/CMakeLists.txt +++ b/recipes/geotrans/all/test_package/CMakeLists.txt @@ -2,15 +2,10 @@ cmake_minimum_required(VERSION 3.1) project(PackageTest CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) include(${CMAKE_BINARY_DIR}/conan_paths.cmake) find_package(geotrans REQUIRED COMPONENTS dtcc ccs) -# -set(EXTERNAL_LIBS - geotrans::dtcc - geotrans::ccs - ) add_executable(example example.cpp) -target_link_libraries(example ${EXTERNAL_LIBS}) +target_link_libraries(example geotrans::dtcc geotrans::ccs) diff --git a/recipes/geotrans/all/test_package/conanfile.py b/recipes/geotrans/all/test_package/conanfile.py index 29f7f9db6fe33..72b88166d390b 100644 --- a/recipes/geotrans/all/test_package/conanfile.py +++ b/recipes/geotrans/all/test_package/conanfile.py @@ -4,27 +4,15 @@ class GeotransTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = ( - "cmake", - "cmake_find_package", - "cmake_paths", - ) + generators = "cmake", "cmake_find_package" def build(self): cmake = CMake(self) - # Current dir is "test_package/build/" and CMakeLists.txt is - # in "test_package" cmake.configure() cmake.build() - def imports(self): - # Import the data files from the package - # The package will not work without these files - self.copy("*", dst="data", src="res") - def test(self): if not tools.cross_building(self): - os.chdir("bin") - data_loc = "..{sep}data".format(sep=os.sep) - os.environ["MSPCCS_DATA"] = data_loc - self.run(".{sep}example".format(sep=os.sep)) + with tools.environment_append({"MSPCCS_DATA": self.deps_user_info["geotrans"].data_path}): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) From c2f2e9e8dd6e3da1683b9d69f228b68f2309847a Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Fri, 30 Jul 2021 23:32:34 +0930 Subject: [PATCH 06/17] Improve geotrans package as per code review * Fix CMake installation process * Refactor CMakeLists to be operated from the root source directory rather than source_subfolder. This removes the requirements to use the shutil package from within conanfile.py * Transition to usage of find_package for Threads library. This will allow thread library discovery to be performed in an OS agnostic way. * Test consumer package sets the required MPCCS_DATA environment variable to the data folder within the conan package folder rather than copying it to the consumers working directory. This is for CCI CI runner testing efficiency purposes, elimintating the need for a copy. --- recipes/geotrans/all/CMakeLists.txt | 32 +++++++++++++++---- recipes/geotrans/all/conanfile.py | 27 +++++++--------- .../geotrans/all/test_package/CMakeLists.txt | 11 ++----- .../geotrans/all/test_package/conanfile.py | 17 +++------- 4 files changed, 45 insertions(+), 42 deletions(-) diff --git a/recipes/geotrans/all/CMakeLists.txt b/recipes/geotrans/all/CMakeLists.txt index 5d37068f927c1..7e13173c0016c 100644 --- a/recipes/geotrans/all/CMakeLists.txt +++ b/recipes/geotrans/all/CMakeLists.txt @@ -3,16 +3,17 @@ project(geotrans VERSION 3.8 LANGUAGES CXX) #### # Conan #### -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +include(${CMAKE_SOURCE_DIR}/conanbuildinfo.cmake) conan_basic_setup() #### # Directories #### -set(DTCCDIR "${CMAKE_CURRENT_SOURCE_DIR}/CCS/src/dtcc/CoordinateSystems") -set(CCSERVICEDIR "${CMAKE_CURRENT_SOURCE_DIR}/CCS/src") -set(SRCDIR "${CMAKE_CURRENT_SOURCE_DIR}/GEOTRANS3/java_gui/geotrans3/jni") +set(SRC_SUBFOLDER "${CMAKE_SOURCE_DIR}/source_subfolder") +set(DTCCDIR "${SRC_SUBFOLDER}/CCS/src/dtcc/CoordinateSystems") +set(CCSERVICEDIR "${SRC_SUBFOLDER}/CCS/src") +set(SRCDIR "${SRC_SUBFOLDER}/GEOTRANS3/java_gui/geotrans3/jni") #### # Sources @@ -46,15 +47,34 @@ endforeach() list(REMOVE_DUPLICATES INCS) list(FILTER INCS EXCLUDE REGEX ".*${DTCCDIR}.*") +set(PUBLIC_HEADERS ${DTTC_HEADERS} ${CCS_HEADERS}) + +#### +# Dependencies +#### + +find_package(Threads REQUIRED) # Create libMSPdtcc add_library(MSPdtcc ${DTCCSRCS} ${CCSERVICESRCS}) target_compile_features(MSPdtcc PUBLIC cxx_std_11) -target_compile_options(MSPdtcc PRIVATE -pthread -Wno-deprecated) +target_compile_options(MSPdtcc PRIVATE -Wno-deprecated) target_include_directories(MSPdtcc PUBLIC include ${DTTCINCS} ${INCS}) +set_target_properties(MSPdtcc PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}") +target_link_libraries(MSPdtcc PRIVATE Threads::Threads) # Create libMSPCoordinateConversionService add_library(MSPCoordinateConversionService ${CCSSRCS} ${CCSERVICESRCS}) target_compile_features(MSPCoordinateConversionService PUBLIC cxx_std_11) -target_compile_options(MSPCoordinateConversionService PRIVATE -pthread -Wno-deprecated) +target_compile_options(MSPCoordinateConversionService PRIVATE -Wno-deprecated) target_include_directories(MSPCoordinateConversionService PUBLIC include ${DTTCINCS} ${INCS}) +set_target_properties(MSPCoordinateConversionService PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}") + +include(GNUInstallDirs) +install(TARGETS MSPdtcc MSPCoordinateConversionService + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +) +install(DIRECTORY "${SRC_SUBFOLDER}/data/" DESTINATION res) diff --git a/recipes/geotrans/all/conanfile.py b/recipes/geotrans/all/conanfile.py index de0256ec584ba..67fa7960d7e07 100644 --- a/recipes/geotrans/all/conanfile.py +++ b/recipes/geotrans/all/conanfile.py @@ -32,6 +32,10 @@ class GeotransConan(ConanFile): def _source_subfolder(self): return "source_subfolder" + @property + def _build_subfolder(self): + return "build_subfolder" + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -43,13 +47,12 @@ def source(self): destination=self._source_subfolder, filename="master.tgz" ) - shutil.copy("CMakeLists.txt", self._source_subfolder) def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) - self._cmake.configure(source_folder=self._source_subfolder) + self._cmake.configure(build_folder=self._build_subfolder) return self._cmake def build(self): @@ -62,17 +65,11 @@ def package(self): dst="licenses", src=os.path.join(self._source_subfolder, "GEOTRANS3", "docs"), ) - self.copy("*", dst="res", src=os.path.join(self._source_subfolder, "data")) - self.copy( - "*.h", dst="include", src=os.path.join(self._source_subfolder, "CCS", "src") - ) - self.copy("*.lib", dst="lib", src="lib", keep_path=False) - self.copy("*.dll", dst="bin", src="lib", keep_path=False) - self.copy("*.so", dst="lib", src="lib", keep_path=False) - self.copy("*.dylib", dst="lib", src="lib", keep_path=False) - self.copy("*.a", dst="lib", src="lib", keep_path=False) + cmake = self._configure_cmake() + cmake.install() def package_info(self): + self.user_info.data_path = os.path.join(self.package_folder, "res") self.cpp_info.resdirs = ["res"] self.cpp_info.name = "geotrans" self.cpp_info.names["cmake_find_package"] = "geotrans" @@ -81,10 +78,11 @@ def package_info(self): self.cpp_info.components["dtcc"].names["cmake_find_package_multi"] = "dtcc" self.cpp_info.components["dtcc"].libs = ["MSPdtcc"] self.cpp_info.components["dtcc"].includedirs = [ - path[0] - for path in os.walk(os.path.join("include", "dtcc", "CoordinateSystems")) + path[0] for path in os.walk("include") ] - self.cpp_info.components["dtcc"].cxxflags = ["-pthread"] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["dtcc"].system_libs.append("pthread") + self.cpp_info.components["ccs"].names["cmake_find_package"] = "ccs" self.cpp_info.components["ccs"].names["cmake_find_package_multi"] = "ccs" self.cpp_info.components["ccs"].libs = ["MSPCoordinateConversionService"] @@ -92,4 +90,3 @@ def package_info(self): self.cpp_info.components["ccs"].includedirs = [ path[0] for path in os.walk("include") ] - self.cpp_info.components["ccs"].cxxflags = ["-pthread"] diff --git a/recipes/geotrans/all/test_package/CMakeLists.txt b/recipes/geotrans/all/test_package/CMakeLists.txt index 02a8e4e7bd3b4..51d9a59f5225e 100644 --- a/recipes/geotrans/all/test_package/CMakeLists.txt +++ b/recipes/geotrans/all/test_package/CMakeLists.txt @@ -2,15 +2,8 @@ cmake_minimum_required(VERSION 3.1) project(PackageTest CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() -include(${CMAKE_BINARY_DIR}/conan_paths.cmake) +conan_basic_setup(TARGETS) find_package(geotrans REQUIRED COMPONENTS dtcc ccs) -# -set(EXTERNAL_LIBS - geotrans::dtcc - geotrans::ccs - ) - add_executable(example example.cpp) -target_link_libraries(example ${EXTERNAL_LIBS}) +target_link_libraries(example geotrans::dtcc geotrans::ccs) diff --git a/recipes/geotrans/all/test_package/conanfile.py b/recipes/geotrans/all/test_package/conanfile.py index 29f7f9db6fe33..b73247b1e87ae 100644 --- a/recipes/geotrans/all/test_package/conanfile.py +++ b/recipes/geotrans/all/test_package/conanfile.py @@ -7,24 +7,17 @@ class GeotransTestConan(ConanFile): generators = ( "cmake", "cmake_find_package", - "cmake_paths", ) def build(self): cmake = CMake(self) - # Current dir is "test_package/build/" and CMakeLists.txt is - # in "test_package" cmake.configure() cmake.build() - def imports(self): - # Import the data files from the package - # The package will not work without these files - self.copy("*", dst="data", src="res") - def test(self): if not tools.cross_building(self): - os.chdir("bin") - data_loc = "..{sep}data".format(sep=os.sep) - os.environ["MSPCCS_DATA"] = data_loc - self.run(".{sep}example".format(sep=os.sep)) + with tools.environment_append( + {"MSPCCS_DATA": self.deps_user_info["geotrans"].data_path} + ): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) From 3201118dc4424f7dead50b90c35ebac12158046c Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Sat, 31 Jul 2021 00:25:16 +0930 Subject: [PATCH 07/17] Add output to inform the user about geotrans MPCCS_DATA envvar This will ideally make it easier for the user to understand the requirements of them to correctly configure the MPCCS_DATA environment variable prior to attempting to use the geotrans library. --- recipes/geotrans/all/conanfile.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/recipes/geotrans/all/conanfile.py b/recipes/geotrans/all/conanfile.py index 48717cec7faba..5286292f062be 100644 --- a/recipes/geotrans/all/conanfile.py +++ b/recipes/geotrans/all/conanfile.py @@ -59,6 +59,12 @@ def _configure_cmake(self): def build(self): cmake = self._configure_cmake() cmake.build() + self.output.info("""geotrans: In order to use this library, the MPCCS_DATA environment variable *must* be set. An example of setting this can be found in the consumer `conanfile.py` example in `test_package/conanfile.py` of this package recipe. Alternatively, this data directory can be moved to a location of your choice from its location in `res` using the `imports` method available in a consumer `conanfile.py`, i.e.: + +def imports(self): + self.copy("*", dst="data", src="res") + +You can then set the environment variable MPCCS_DATA to the location of this `data` directory.""") def package(self): self.copy( From 688b378bc65aa2434a35995838332ffff1891a09 Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Sat, 31 Jul 2021 01:14:08 +0930 Subject: [PATCH 08/17] Rectify fPIC management as per KB-H007 to address CI issues * Delete fPIC option when shared library is being built * Remove superfluous shutil import --- recipes/geotrans/all/conanfile.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/recipes/geotrans/all/conanfile.py b/recipes/geotrans/all/conanfile.py index 5286292f062be..3ec7c31f647e7 100644 --- a/recipes/geotrans/all/conanfile.py +++ b/recipes/geotrans/all/conanfile.py @@ -1,6 +1,5 @@ from conans import ConanFile, CMake, tools import os -import shutil class GeotransConan(ConanFile): @@ -40,6 +39,8 @@ def _build_subfolder(self): def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if self.options.shared: + del self.options.fPIC def source(self): tools.get( @@ -59,12 +60,14 @@ def _configure_cmake(self): def build(self): cmake = self._configure_cmake() cmake.build() - self.output.info("""geotrans: In order to use this library, the MPCCS_DATA environment variable *must* be set. An example of setting this can be found in the consumer `conanfile.py` example in `test_package/conanfile.py` of this package recipe. Alternatively, this data directory can be moved to a location of your choice from its location in `res` using the `imports` method available in a consumer `conanfile.py`, i.e.: + self.output.info( + """geotrans: In order to use this library, the MPCCS_DATA environment variable *must* be set. An example of setting this can be found in the consumer `conanfile.py` example in `test_package/conanfile.py` of this package recipe. Alternatively, this data directory can be moved to a location of your choice from its location in `res` using the `imports` method available in a consumer `conanfile.py`, i.e.: def imports(self): self.copy("*", dst="data", src="res") -You can then set the environment variable MPCCS_DATA to the location of this `data` directory.""") +You can then set the environment variable MPCCS_DATA to the location of this `data` directory.""" + ) def package(self): self.copy( From 3425370066c6055dee54068c3cb2ae11271bc552 Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Sat, 31 Jul 2021 01:33:59 +0930 Subject: [PATCH 09/17] Update recipes/geotrans/all/conanfile.py Co-authored-by: Rui Oliveira --- recipes/geotrans/all/conanfile.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/recipes/geotrans/all/conanfile.py b/recipes/geotrans/all/conanfile.py index 3ec7c31f647e7..be21b8010c0c2 100644 --- a/recipes/geotrans/all/conanfile.py +++ b/recipes/geotrans/all/conanfile.py @@ -41,7 +41,12 @@ def config_options(self): del self.options.fPIC if self.options.shared: del self.options.fPIC - + def configure(self): + if self.options.shared: + del self.options.fPIC + # And if this is a C library: + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd def source(self): tools.get( **self.conan_data["sources"][self.version], From aab06b1a7ae681254faaedc3bdc61e35597bfb67 Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Sat, 31 Jul 2021 01:35:14 +0930 Subject: [PATCH 10/17] Remove fPIC management from config_options function * Remove superfluous fPIC management from config_options function * Remove superfluous C library requirements to remove cpp flags --- recipes/geotrans/all/conanfile.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/recipes/geotrans/all/conanfile.py b/recipes/geotrans/all/conanfile.py index be21b8010c0c2..d79105a9d479d 100644 --- a/recipes/geotrans/all/conanfile.py +++ b/recipes/geotrans/all/conanfile.py @@ -39,14 +39,11 @@ def _build_subfolder(self): def config_options(self): if self.settings.os == "Windows": del self.options.fPIC - if self.options.shared: - del self.options.fPIC + def configure(self): if self.options.shared: del self.options.fPIC - # And if this is a C library: - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + def source(self): tools.get( **self.conan_data["sources"][self.version], From 5f0fa06360088c5d1b2c50494f49b1626737c2f3 Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Sat, 31 Jul 2021 21:49:18 +0930 Subject: [PATCH 11/17] Link dtcc library to ccs and remove cmake_find_package values * Link MSPdtcc to MSPCoordinateConversionService to satisfy linkage requirements on macOS. This rectifies CI failures. * Remove cmake_find_package(_multi) assignments from conanfile.py at the advice of @madebr --- recipes/geotrans/all/CMakeLists.txt | 1 + recipes/geotrans/all/conanfile.py | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/recipes/geotrans/all/CMakeLists.txt b/recipes/geotrans/all/CMakeLists.txt index fe2abc43e4fe7..bfdc3375056c3 100644 --- a/recipes/geotrans/all/CMakeLists.txt +++ b/recipes/geotrans/all/CMakeLists.txt @@ -69,6 +69,7 @@ target_compile_features(MSPCoordinateConversionService PUBLIC cxx_std_11) target_compile_options(MSPCoordinateConversionService PRIVATE -Wno-deprecated) target_include_directories(MSPCoordinateConversionService PUBLIC include ${DTTCINCS} ${INCS}) set_target_properties(MSPCoordinateConversionService PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}") +target_link_libraries(MSPCoordinateConversionService PUBLIC MSPdtcc) include(GNUInstallDirs) install(TARGETS MSPdtcc MSPCoordinateConversionService diff --git a/recipes/geotrans/all/conanfile.py b/recipes/geotrans/all/conanfile.py index d79105a9d479d..40041bb79a2f3 100644 --- a/recipes/geotrans/all/conanfile.py +++ b/recipes/geotrans/all/conanfile.py @@ -83,10 +83,6 @@ def package(self): def package_info(self): self.user_info.data_path = os.path.join(self.package_folder, "res") self.cpp_info.resdirs = ["res"] - self.cpp_info.names["cmake_find_package"] = "geotrans" - self.cpp_info.names["cmake_find_package_multi"] = "geotrans" - self.cpp_info.components["dtcc"].names["cmake_find_package"] = "dtcc" - self.cpp_info.components["dtcc"].names["cmake_find_package_multi"] = "dtcc" self.cpp_info.components["dtcc"].libs = ["MSPdtcc"] self.cpp_info.components["dtcc"].includedirs = [ path[0] for path in os.walk("include") @@ -94,8 +90,6 @@ def package_info(self): if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["dtcc"].system_libs.append("pthread") - self.cpp_info.components["ccs"].names["cmake_find_package"] = "ccs" - self.cpp_info.components["ccs"].names["cmake_find_package_multi"] = "ccs" self.cpp_info.components["ccs"].libs = ["MSPCoordinateConversionService"] self.cpp_info.components["ccs"].requires = ["dtcc"] self.cpp_info.components["ccs"].includedirs = [ From 32dd18f843fe52c8e934726bc3fe85fb43de860d Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Sat, 31 Jul 2021 22:17:00 +0930 Subject: [PATCH 12/17] Remove -Wno-deprecated compilation flag for windows compatability --- recipes/geotrans/all/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/recipes/geotrans/all/CMakeLists.txt b/recipes/geotrans/all/CMakeLists.txt index bfdc3375056c3..ce63b15c5d963 100644 --- a/recipes/geotrans/all/CMakeLists.txt +++ b/recipes/geotrans/all/CMakeLists.txt @@ -58,7 +58,6 @@ find_package(Threads REQUIRED) # Create libMSPdtcc add_library(MSPdtcc ${DTCCSRCS} ${CCSERVICESRCS}) target_compile_features(MSPdtcc PUBLIC cxx_std_11) -target_compile_options(MSPdtcc PRIVATE -Wno-deprecated) target_include_directories(MSPdtcc PUBLIC include ${DTTCINCS} ${INCS}) set_target_properties(MSPdtcc PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}") target_link_libraries(MSPdtcc PRIVATE Threads::Threads) @@ -66,7 +65,6 @@ target_link_libraries(MSPdtcc PRIVATE Threads::Threads) # Create libMSPCoordinateConversionService add_library(MSPCoordinateConversionService ${CCSSRCS} ${CCSERVICESRCS}) target_compile_features(MSPCoordinateConversionService PUBLIC cxx_std_11) -target_compile_options(MSPCoordinateConversionService PRIVATE -Wno-deprecated) target_include_directories(MSPCoordinateConversionService PUBLIC include ${DTTCINCS} ${INCS}) set_target_properties(MSPCoordinateConversionService PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}") target_link_libraries(MSPCoordinateConversionService PUBLIC MSPdtcc) From 2094356cd87dfcc622e8d26828753c19b29c28d9 Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Sun, 1 Aug 2021 23:21:03 +0930 Subject: [PATCH 13/17] Add MSVC compatability to geotrans * Add LITTLE_ENDIAN pre-processor definition to enable the reading of the provided binary data files on Windows systems. --- recipes/geotrans/all/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recipes/geotrans/all/CMakeLists.txt b/recipes/geotrans/all/CMakeLists.txt index ce63b15c5d963..edee9451a8964 100644 --- a/recipes/geotrans/all/CMakeLists.txt +++ b/recipes/geotrans/all/CMakeLists.txt @@ -58,6 +58,9 @@ find_package(Threads REQUIRED) # Create libMSPdtcc add_library(MSPdtcc ${DTCCSRCS} ${CCSERVICESRCS}) target_compile_features(MSPdtcc PUBLIC cxx_std_11) +if (WIN32) + add_compile_definitions(MSPdtcc PRIVATE LITTLE_ENDIAN=1) +endif(WIN32) target_include_directories(MSPdtcc PUBLIC include ${DTTCINCS} ${INCS}) set_target_properties(MSPdtcc PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}") target_link_libraries(MSPdtcc PRIVATE Threads::Threads) From 14a32461357b6f6ba8f23c348ac282085ee6d0c4 Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Thu, 5 Aug 2021 00:28:43 +0930 Subject: [PATCH 14/17] Fix windows build by exporting symbols to ensure lib is created * Add CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS definition when building shared libraries on windows to ensure that all symbols are exported and .lib object is created. --- recipes/geotrans/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/geotrans/all/conanfile.py b/recipes/geotrans/all/conanfile.py index 40041bb79a2f3..9674558f86f9b 100644 --- a/recipes/geotrans/all/conanfile.py +++ b/recipes/geotrans/all/conanfile.py @@ -56,6 +56,8 @@ def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) + if self.settings.os == "Windows" and self.options.shared: + self._cmake.definitions["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True self._cmake.configure(build_folder=self._build_subfolder) return self._cmake From 4e828af1fcdf493433fc94b195c88bfbcfe0c157 Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Sun, 19 Sep 2021 15:39:21 +0930 Subject: [PATCH 15/17] Apply suggestions from code review * Move responsibility for setting MSPCCS_DATA environment variable from consumer to package * Remove usage output from build method * Remove explicit assignment of resdir value Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com> --- recipes/geotrans/all/conanfile.py | 13 +++---------- recipes/geotrans/all/test_package/conanfile.py | 7 ++----- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/recipes/geotrans/all/conanfile.py b/recipes/geotrans/all/conanfile.py index 9674558f86f9b..12ee93c112156 100644 --- a/recipes/geotrans/all/conanfile.py +++ b/recipes/geotrans/all/conanfile.py @@ -64,14 +64,6 @@ def _configure_cmake(self): def build(self): cmake = self._configure_cmake() cmake.build() - self.output.info( - """geotrans: In order to use this library, the MPCCS_DATA environment variable *must* be set. An example of setting this can be found in the consumer `conanfile.py` example in `test_package/conanfile.py` of this package recipe. Alternatively, this data directory can be moved to a location of your choice from its location in `res` using the `imports` method available in a consumer `conanfile.py`, i.e.: - -def imports(self): - self.copy("*", dst="data", src="res") - -You can then set the environment variable MPCCS_DATA to the location of this `data` directory.""" - ) def package(self): self.copy( @@ -83,8 +75,9 @@ def package(self): cmake.install() def package_info(self): - self.user_info.data_path = os.path.join(self.package_folder, "res") - self.cpp_info.resdirs = ["res"] + mpccs_data_path = os.path.join(self.package_folder, "res") + self.output.info("Creating MPCCS_DATA environment variable: {}".format(mpccs_data_path)) + self.env_info.MPCCS_DATA = mpccs_data_path self.cpp_info.components["dtcc"].libs = ["MSPdtcc"] self.cpp_info.components["dtcc"].includedirs = [ path[0] for path in os.walk("include") diff --git a/recipes/geotrans/all/test_package/conanfile.py b/recipes/geotrans/all/test_package/conanfile.py index b73247b1e87ae..004110bfe091c 100644 --- a/recipes/geotrans/all/test_package/conanfile.py +++ b/recipes/geotrans/all/test_package/conanfile.py @@ -16,8 +16,5 @@ def build(self): def test(self): if not tools.cross_building(self): - with tools.environment_append( - {"MSPCCS_DATA": self.deps_user_info["geotrans"].data_path} - ): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) From e63a5b330937e1644c59188f0343188332489c15 Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Sun, 19 Sep 2021 16:16:31 +0930 Subject: [PATCH 16/17] Apply changes from code review * Remove version number of library from CMakeLists.txt * Remove version number of library from conanfile.py * Move definition of CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS from conanfile to CMakeLists.txt * Add commentary on requisite environment variables to be set to consumer conanfile.py * Re-add call to tools.environment_append to ensure that MPCCS_DATA environment variable is set when executing the example binary --- recipes/geotrans/all/CMakeLists.txt | 4 ++-- recipes/geotrans/all/conanfile.py | 3 --- recipes/geotrans/all/test_package/conanfile.py | 13 +++++++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/recipes/geotrans/all/CMakeLists.txt b/recipes/geotrans/all/CMakeLists.txt index edee9451a8964..4e9341cf898cb 100644 --- a/recipes/geotrans/all/CMakeLists.txt +++ b/recipes/geotrans/all/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.8) -project(geotrans VERSION 3.8 LANGUAGES CXX) +project(geotrans LANGUAGES CXX) #### # Conan #### @@ -54,7 +54,7 @@ set(PUBLIC_HEADERS ${DTTC_HEADERS} ${CCS_HEADERS}) #### find_package(Threads REQUIRED) - +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # Create libMSPdtcc add_library(MSPdtcc ${DTCCSRCS} ${CCSERVICESRCS}) target_compile_features(MSPdtcc PUBLIC cxx_std_11) diff --git a/recipes/geotrans/all/conanfile.py b/recipes/geotrans/all/conanfile.py index 12ee93c112156..aeba297ba1ccd 100644 --- a/recipes/geotrans/all/conanfile.py +++ b/recipes/geotrans/all/conanfile.py @@ -4,7 +4,6 @@ class GeotransConan(ConanFile): name = "geotrans" - version = "3.8" license = ( "NGA GEOTRANS ToS (https://earth-info.nga.mil/php/download.php?file=wgs-terms)" ) @@ -56,8 +55,6 @@ def _configure_cmake(self): if self._cmake: return self._cmake self._cmake = CMake(self) - if self.settings.os == "Windows" and self.options.shared: - self._cmake.definitions["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True self._cmake.configure(build_folder=self._build_subfolder) return self._cmake diff --git a/recipes/geotrans/all/test_package/conanfile.py b/recipes/geotrans/all/test_package/conanfile.py index 004110bfe091c..f04a962cdcb85 100644 --- a/recipes/geotrans/all/test_package/conanfile.py +++ b/recipes/geotrans/all/test_package/conanfile.py @@ -16,5 +16,14 @@ def build(self): def test(self): if not tools.cross_building(self): - bin_path = os.path.join("bin", "example") - self.run(bin_path, run_environment=True) + # NOTE: In order to use this library, the MPCCS_DATA environment variable *must* be set. + # The path to the appropriate data directory is available in the env_info variable. This can be + # accessed from a consumer package using `self.deps_env_info["geotrans"].MPCCS_DATA. + # Alternatively, this data directory can be moved to a location of your choice from its location + # in `res`, using the `imports()` method. + # This new location can then be used as the value for the MPCCS_DATA environment variable. + with tools.environment_append( + {"MSPCCS_DATA": self.deps_env_info["geotrans"].MPCCS_DATA} + ): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) From 77a972e897d66b530c28e25f7c199c2f443c7f68 Mon Sep 17 00:00:00 2001 From: Samuel Dowling Date: Fri, 15 Oct 2021 08:45:35 +1030 Subject: [PATCH 17/17] [geotrans] Update source URL to use JFrog Artifactory * Update geotrans 3.8 source URL to use JFrog Artifactory. This resolves a build reproducibility issue caused by the fact that NGA don't host a versioned mirror of the source files. The JFrog mirror provided is now versioned and will be able to be downloaded even after the release of geotrans 3.9 Co-authored-by: Javier G. Sogo --- recipes/geotrans/all/conandata.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/geotrans/all/conandata.yml b/recipes/geotrans/all/conandata.yml index 8d8531d00da07..c23de4c86ebcd 100644 --- a/recipes/geotrans/all/conandata.yml +++ b/recipes/geotrans/all/conandata.yml @@ -1,4 +1,4 @@ sources: "3.8": - url: "https://earth-info.nga.mil/php/download.php?file=wgs-mastertgz" + url: "https://c3i.jfrog.io/artifactory/cci-sources-backup/sources/geotrans/geotrans-3.8.tgz" sha256: "BAA72D3B1AE12F237A8AD30F2DEB3FED2B80FEB759528EA0A72B4B42CB77C565"