Skip to content

Commit f840b34

Browse files
authored
Merge pull request #1272 from SpaceIm/proj/6.3.1
add proj/6.3.1
2 parents 46dc609 + bf6f2f7 commit f840b34

File tree

8 files changed

+213
-0
lines changed

8 files changed

+213
-0
lines changed

recipes/proj/6.x.x/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.1.2)
2+
project(cmake_wrapper)
3+
4+
include(conanbuildinfo.cmake)
5+
conan_basic_setup(TARGETS)
6+
7+
add_subdirectory("source_subfolder")

recipes/proj/6.x.x/conandata.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
sources:
2+
"6.3.1":
3+
url: "https://github.com/OSGeo/PROJ/releases/download/6.3.1/proj-6.3.1.tar.gz"
4+
sha256: "6de0112778438dcae30fcc6942dee472ce31399b9e5a2b67e8642529868c86f8"
5+
patches:
6+
"6.3.1":
7+
- patch_file: "patches/conanize-cmake.patch"
8+
base_path: "source_subfolder"

recipes/proj/6.x.x/conanfile.py

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
from conans import ConanFile, CMake, tools
2+
import glob
3+
import os
4+
5+
6+
class ProjConan(ConanFile):
7+
name = "proj"
8+
license = "MIT"
9+
url = "https://github.com/conan-io/conan-center-index"
10+
homepage = "https://proj.org"
11+
description = "Cartographic Projections and Coordinate Transformations Library"
12+
topics = ("conan", "dsp", "proj", "proj4", "projections", "gis", "geospatial")
13+
settings = "os", "compiler", "build_type", "arch"
14+
options = {
15+
"shared": [True, False],
16+
"fPIC": [True, False],
17+
"threadsafe": [True, False]
18+
}
19+
default_options = {
20+
"shared": False,
21+
"fPIC": True,
22+
"threadsafe": True
23+
}
24+
25+
generators = "cmake"
26+
exports_sources = ["CMakeLists.txt", "patches/*"]
27+
28+
_cmake = None
29+
30+
@property
31+
def _source_subfolder(self):
32+
return "source_subfolder"
33+
34+
@property
35+
def _build_subfolder(self):
36+
return "build_subfolder"
37+
38+
def config_options(self):
39+
if self.settings.os == "Windows":
40+
del self.options.fPIC
41+
42+
def requirements(self):
43+
self.requires.add("sqlite3/3.31.1")
44+
45+
def source(self):
46+
tools.get(**self.conan_data["sources"][self.version])
47+
extracted_dir = self.name + "-" + self.version
48+
os.rename(extracted_dir, self._source_subfolder)
49+
50+
def _configure_cmake(self):
51+
if self._cmake:
52+
return self._cmake
53+
self._cmake = CMake(self)
54+
self._cmake.definitions["PROJ_TESTS"] = False
55+
self._cmake.definitions["BUILD_LIBPROJ_SHARED"] = self.options.shared
56+
self._cmake.definitions["USE_THREAD"] = self.options.threadsafe
57+
self._cmake.definitions["ENABLE_LTO"] = False
58+
self._cmake.definitions["JNI_SUPPORT"] = False
59+
self._cmake.definitions["BUILD_CCT"] = True
60+
self._cmake.definitions["BUILD_CS2CS"] = True
61+
self._cmake.definitions["BUILD_GEOD"] = True
62+
self._cmake.definitions["BUILD_GIE"] = True
63+
self._cmake.definitions["BUILD_PROJ"] = True
64+
self._cmake.definitions["BUILD_PROJINFO"] = True
65+
self._cmake.definitions["PROJ_DATA_SUBDIR"] = "res"
66+
self._cmake.configure(build_folder=self._build_subfolder)
67+
return self._cmake
68+
69+
def build(self):
70+
for patch in self.conan_data["patches"][self.version]:
71+
tools.patch(**patch)
72+
cmake = self._configure_cmake()
73+
cmake.build()
74+
75+
def package(self):
76+
self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder)
77+
cmake = self._configure_cmake()
78+
cmake.install()
79+
tools.rmdir(os.path.join(self.package_folder, "share"))
80+
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
81+
for data_file in glob.glob(os.path.join(self.package_folder, "res", "*")):
82+
if not data_file.endswith("proj.db"):
83+
os.remove(data_file)
84+
85+
def package_info(self):
86+
self.cpp_info.names["cmake_find_package"] = "PROJ4"
87+
self.cpp_info.names["cmake_find_package_multi"] = "PROJ4"
88+
self.cpp_info.libs = tools.collect_libs(self)
89+
if self.settings.os == "Linux":
90+
self.cpp_info.system_libs.append("m")
91+
if self.options.threadsafe:
92+
self.cpp_info.system_libs.append("pthread")
93+
if self.options.shared and self.settings.compiler == "Visual Studio":
94+
self.cpp_info.defines.append("PROJ_MSVC_DLL_IMPORT")
95+
self.env_info.PROJ_LIB.append(os.path.join(self.package_folder, "res"))
96+
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--- a/src/lib_proj.cmake
2+
+++ b/src/lib_proj.cmake
3+
@@ -311,7 +311,7 @@ source_group("Source Files\\Transformations"
4+
source_group("Source Files\\ISO19111"
5+
FILES ${SRC_LIBPROJ_ISO19111})
6+
7+
-include_directories(${CMAKE_SOURCE_DIR}/include)
8+
+include_directories(${PROJ4_SOURCE_DIR}/include)
9+
10+
include_directories(${CMAKE_CURRENT_BINARY_DIR})
11+
source_group("CMake Files" FILES CMakeLists.txt)
12+
@@ -440,8 +440,7 @@ if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
13+
target_link_libraries(${PROJ_CORE_TARGET} ${CMAKE_THREAD_LIBS_INIT})
14+
endif()
15+
16+
-include_directories(${SQLITE3_INCLUDE_DIR})
17+
-target_link_libraries(${PROJ_CORE_TARGET} ${SQLITE3_LIBRARY})
18+
+target_link_libraries(${PROJ_CORE_TARGET} CONAN_PKG::sqlite3)
19+
20+
if(MSVC AND BUILD_LIBPROJ_SHARED)
21+
target_compile_definitions(${PROJ_CORE_TARGET}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cmake_minimum_required(VERSION 2.8.11)
2+
project(test_package)
3+
4+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
5+
conan_basic_setup()
6+
7+
add_executable(${PROJECT_NAME} test_package.c)
8+
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
9+
set_property(TARGET ${PROJECT_NAME} PROPERTY LINKER_LANGUAGE CXX)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from conans import ConanFile, CMake, tools
2+
import os
3+
4+
5+
class TestPackageConan(ConanFile):
6+
settings = "os", "compiler", "build_type", "arch"
7+
generators = "cmake"
8+
9+
def build(self):
10+
cmake = CMake(self)
11+
cmake.configure()
12+
cmake.build()
13+
14+
def test(self):
15+
if not tools.cross_building(self.settings):
16+
bin_path = os.path.join("bin", "test_package")
17+
self.run(bin_path, run_environment=True)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* From PROJ quickstart */
2+
3+
#include <stdio.h>
4+
#include <proj.h>
5+
6+
int main (void) {
7+
PJ_CONTEXT *C;
8+
PJ *P;
9+
PJ* P_for_GIS;
10+
PJ_COORD a, b;
11+
12+
/* or you may set C=PJ_DEFAULT_CTX if you are sure you will */
13+
/* use PJ objects from only one thread */
14+
C = proj_context_create();
15+
16+
P = proj_create_crs_to_crs (C,
17+
"EPSG:4326",
18+
"+proj=utm +zone=32 +datum=WGS84", /* or EPSG:32632 */
19+
NULL);
20+
21+
if (0==P) {
22+
fprintf(stderr, "Oops\n");
23+
return 1;
24+
}
25+
26+
/* This will ensure that the order of coordinates for the input CRS */
27+
/* will be longitude, latitude, whereas EPSG:4326 mandates latitude, */
28+
/* longitude */
29+
P_for_GIS = proj_normalize_for_visualization(C, P);
30+
if( 0 == P_for_GIS ) {
31+
fprintf(stderr, "Oops\n");
32+
return 1;
33+
}
34+
proj_destroy(P);
35+
P = P_for_GIS;
36+
37+
/* a coordinate union representing Copenhagen: 55d N, 12d E */
38+
/* Given that we have used proj_normalize_for_visualization(), the order of
39+
/* coordinates is longitude, latitude, and values are expressed in degrees. */
40+
a = proj_coord (12, 55, 0, 0);
41+
42+
/* transform to UTM zone 32, then back to geographical */
43+
b = proj_trans (P, PJ_FWD, a);
44+
printf ("easting: %.3f, northing: %.3f\n", b.enu.e, b.enu.n);
45+
b = proj_trans (P, PJ_INV, b);
46+
printf ("longitude: %g, latitude: %g\n", b.lp.lam, b.lp.phi);
47+
48+
/* Clean up */
49+
proj_destroy (P);
50+
proj_context_destroy (C); /* may be omitted in the single threaded case */
51+
return 0;
52+
}

recipes/proj/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
versions:
2+
"6.3.1":
3+
folder: "6.x.x"

0 commit comments

Comments
 (0)