Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
82 changes: 82 additions & 0 deletions recipes/geotrans/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
cmake_minimum_required(VERSION 3.8)
project(geotrans LANGUAGES CXX)
####
# Conan
####
include(${CMAKE_SOURCE_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

####
# Directories
####

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
####
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)

# 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(INCS ${INCS} ${DIR_PATH})
endforeach()
list(REMOVE_DUPLICATES INCS)
list(FILTER INCS EXCLUDE REGEX ".*${DTCCDIR}.*")

set(PUBLIC_HEADERS ${DTTC_HEADERS} ${CCS_HEADERS})

####
# Dependencies
####

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)
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)

# Create libMSPCoordinateConversionService
add_library(MSPCoordinateConversionService ${CCSSRCS} ${CCSERVICESRCS})
target_compile_features(MSPCoordinateConversionService PUBLIC cxx_std_11)
target_include_directories(MSPCoordinateConversionService PUBLIC include ${DTTCINCS} ${INCS})
Comment thread
samuel-emrys marked this conversation as resolved.
set_target_properties(MSPCoordinateConversionService PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}")
target_link_libraries(MSPCoordinateConversionService PUBLIC MSPdtcc)

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)
4 changes: 4 additions & 0 deletions recipes/geotrans/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"3.8":
url: "https://c3i.jfrog.io/artifactory/cci-sources-backup/sources/geotrans/geotrans-3.8.tgz"
sha256: "BAA72D3B1AE12F237A8AD30F2DEB3FED2B80FEB759528EA0A72B4B42CB77C565"
89 changes: 89 additions & 0 deletions recipes/geotrans/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from conans import ConanFile, CMake, tools
import os


class GeotransConan(ConanFile):
name = "geotrans"
license = (
"NGA GEOTRANS ToS (https://earth-info.nga.mil/php/download.php?file=wgs-terms)"
)
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",
"geodesic",
"geographic",
"coordinate",
"datum",
"geodetic",
"conversion",
"transformation",
)
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "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

Comment thread
samuel-emrys marked this conversation as resolved.
def configure(self):
if self.options.shared:
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"
)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.configure(build_folder=self._build_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"),
)
cmake = self._configure_cmake()
cmake.install()

def package_info(self):
Comment thread
samuel-emrys marked this conversation as resolved.
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")
]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["dtcc"].system_libs.append("pthread")

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")
]
9 changes: 9 additions & 0 deletions recipes/geotrans/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.1)
project(PackageTest CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(geotrans REQUIRED COMPONENTS dtcc ccs)
add_executable(example example.cpp)
target_link_libraries(example geotrans::dtcc geotrans::ccs)
29 changes: 29 additions & 0 deletions recipes/geotrans/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os
from conans import ConanFile, CMake, tools


class GeotransTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = (
"cmake",
"cmake_find_package",
)

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

def test(self):
if not tools.cross_building(self):
# 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)
Loading