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

Add proj/6.3.0 #751

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 7 additions & 0 deletions recipes/proj/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8.11)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_subdirectory("source_subfolder")
11 changes: 11 additions & 0 deletions recipes/proj/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sources:
"6.3.0":
url: https://github.com/OSGeo/PROJ/releases/download/6.3.0/proj-6.3.0.tar.gz
sha256: 68ce9ba0005d442c2c1d238a3b9bc6654c358159b4af467b91e8d5b407c79c77

patches:
"6.3.0":
- patch_file: "patches/0001-Include-libdl-for-sqlite.patch"
base_path: "source_subfolder"
- patch_file: "patches/0002-Use-python-instead-of-sqlite.patch"
base_path: "source_subfolder"
79 changes: 79 additions & 0 deletions recipes/proj/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
from conans import ConanFile, CMake, tools
import os


class LibaecConan(ConanFile):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProjConan instead of LibaecConan ;)

name = "proj"
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://proj.org"
description = "Cartographic Projections and Coordinate Transformations Library"
topics = ("conan", "dsp", "proj", "proj4", "projections", "gis", "geospatial")
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", "sqlite_init.py", "patches/*"]

_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 requirements(self):
self.requires("sqlite3/3.31.0")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["PROJ_TESTS"] = False
self._cmake.definitions["BUILD_LIBPROJ_SHARED"] = self.options.shared
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake

def build(self):
for patch in self.conan_data["patches"][self.version]:
tools.patch(**patch)
tools.replace_in_file(os.path.join(self._source_subfolder, "src", "lib_proj.cmake"),
"include_directories(${CMAKE_SOURCE_DIR}/include)",
"include_directories(${PROJ4_SOURCE_DIR}/include)")
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
self.copy("*.db",
src=os.path.join(self.package_folder, "share", "proj"),
dst=os.path.join(self.package_folder, "lib", "proj"))
tools.rmdir(os.path.join(self.package_folder, "share"))
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))

def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
if self.settings.os == "Linux":
self.cpp_info.system_libs = ["pthread", "dl", "m"]
self.env_info.PROJ_LIB.append(os.path.join(self.package_folder, "lib", "proj"))
25 changes: 25 additions & 0 deletions recipes/proj/all/patches/0001-Include-libdl-for-sqlite.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From abe15bcef2004069d5e356c94acd9ffbdf17f16e Mon Sep 17 00:00:00 2001
From: Brennan Ashton <bashton@brennanashton.com>
Date: Wed, 29 Jan 2020 22:59:46 -0800
Subject: [PATCH 1/2] Include libdl for sqlite

---
src/lib_proj.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lib_proj.cmake b/src/lib_proj.cmake
index bc27bafe..280bb959 100644
--- a/src/lib_proj.cmake
+++ b/src/lib_proj.cmake
@@ -441,7 +441,7 @@ if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
endif()

include_directories(${SQLITE3_INCLUDE_DIR})
-target_link_libraries(${PROJ_CORE_TARGET} ${SQLITE3_LIBRARY})
+target_link_libraries(${PROJ_CORE_TARGET} CONAN_PKG::sqlite3)

if(MSVC AND BUILD_LIBPROJ_SHARED)
target_compile_definitions(${PROJ_CORE_TARGET}
--
2.20.1

49 changes: 49 additions & 0 deletions recipes/proj/all/patches/0002-Use-python-instead-of-sqlite.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From fd091e736f87f623373b9362d3ee9867e9204419 Mon Sep 17 00:00:00 2001
From: Brennan Ashton <bashton@brennanashton.com>
Date: Thu, 30 Jan 2020 09:45:58 -0800
Subject: [PATCH 2/2] Use python instead of sqlite

---
CMakeLists.txt | 5 -----
data/CMakeLists.txt | 6 +++++-
2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 53a88de4..50c11238 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -117,11 +117,6 @@ include(policies)
################################################################################
# Check for sqlite3
################################################################################
-find_program(EXE_SQLITE3 sqlite3)
-if(NOT EXE_SQLITE3)
- message(SEND_ERROR "sqlite3 binary not found!")
-endif()
-
find_package(Sqlite3 REQUIRED)
if(NOT SQLITE3_FOUND)
message(SEND_ERROR "sqlite3 dependency not found!")
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
index 8f3965f2..2e8f7c85 100644
--- a/data/CMakeLists.txt
+++ b/data/CMakeLists.txt
@@ -40,10 +40,14 @@ add_custom_command(

add_custom_target(generate_all_sql_in ALL DEPENDS ${ALL_SQL_IN})

+find_package(PythonInterp)
+if(NOT PYTHONINTERP_FOUND)
+ message(SEND_ERROR "python executable not found!")
+endif()
add_custom_command(
OUTPUT ${PROJ_DB}
COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJ_DB}
- COMMAND ${EXE_SQLITE3} -init ${ALL_SQL_IN} ${PROJ_DB} .quit
+ COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/sqlite_init.py ${PROJ_DB} ${ALL_SQL_IN}
# note: we didn't port yet the foreign_key_check done in Makefile.am
DEPENDS generate_all_sql_in ${ALL_SQL_IN}
COMMENT "Generating proj.db"
--
2.20.1

7 changes: 7 additions & 0 deletions recipes/proj/all/sqlite_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import sqlite3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is quite a hack as well, but I see we don't have the executable in the sqlite3 packages so it is the only way to go for now.

On the other hand, this might fail for Conan users that are using the installers (no Python installed).

My question is the following: If the sqlite3 library is expected to have the executable, why don't we package it? Any ideas @madebr @SSE4 @uilianries ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danimtb I've submitted a PR to add sqlite3 CLI: #1004

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please @btashton take a look at the sqlite3 approach and try to use the sqlite3 executable from the Conan package now that we got #1004 merged. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at #1004, sqlite3 will fail when using as a build requirement and cross building (e.g. building an arm application on x86).

import sys

con = sqlite3.connect(sys.argv[1])
with open(sys.argv[2], 'rb') as sql_init:
con.executescript(sql_init.read().decode("UTF-8"))
con.close()
11 changes: 11 additions & 0 deletions recipes/proj/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.1.3)
project(test_package)

set(CMAKE_VERBOSE_MAKEFILE TRUE)

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

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
SSE4 marked this conversation as resolved.
Show resolved Hide resolved
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
20 changes: 20 additions & 0 deletions recipes/proj/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from conans import ConanFile, CMake, tools
import os


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

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

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
52 changes: 52 additions & 0 deletions recipes/proj/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* From PROJ quickstart */

#include <stdio.h>
#include <proj.h>

int main (void) {
PJ_CONTEXT *C;
PJ *P;
PJ* P_for_GIS;
PJ_COORD a, b;

/* or you may set C=PJ_DEFAULT_CTX if you are sure you will */
/* use PJ objects from only one thread */
C = proj_context_create();

P = proj_create_crs_to_crs (C,
"EPSG:4326",
"+proj=utm +zone=32 +datum=WGS84", /* or EPSG:32632 */
NULL);

if (0==P) {
fprintf(stderr, "Oops\n");
return 1;
}

/* This will ensure that the order of coordinates for the input CRS */
/* will be longitude, latitude, whereas EPSG:4326 mandates latitude, */
/* longitude */
P_for_GIS = proj_normalize_for_visualization(C, P);
if( 0 == P_for_GIS ) {
fprintf(stderr, "Oops\n");
return 1;
}
proj_destroy(P);
P = P_for_GIS;

/* a coordinate union representing Copenhagen: 55d N, 12d E */
/* Given that we have used proj_normalize_for_visualization(), the order of
/* coordinates is longitude, latitude, and values are expressed in degrees. */
a = proj_coord (12, 55, 0, 0);

/* transform to UTM zone 32, then back to geographical */
b = proj_trans (P, PJ_FWD, a);
printf ("easting: %.3f, northing: %.3f\n", b.enu.e, b.enu.n);
b = proj_trans (P, PJ_INV, b);
printf ("longitude: %g, latitude: %g\n", b.lp.lam, b.lp.phi);

/* Clean up */
proj_destroy (P);
proj_context_destroy (C); /* may be omitted in the single threaded case */
return 0;
}
3 changes: 3 additions & 0 deletions recipes/proj/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"6.3.0":
folder: all