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

proj: several improvements #1

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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.11)
cmake_minimum_required(VERSION 3.1.2)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
Expand Down
8 changes: 8 additions & 0 deletions recipes/proj/6.x.x/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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/conanize-cmake.patch"
base_path: "source_subfolder"
39 changes: 28 additions & 11 deletions recipes/proj/all/conanfile.py → recipes/proj/6.x.x/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from conans import ConanFile, CMake, tools
import glob
import os


class LibaecConan(ConanFile):
class ProjConan(ConanFile):
name = "proj"
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
Expand All @@ -13,14 +14,16 @@ class LibaecConan(ConanFile):
options = {
"shared": [True, False],
"fPIC": [True, False],
"threadsafe": [True, False]
}
default_options = {
"shared": False,
"fPIC": True,
"threadsafe": True
}

generators = "cmake"
exports_sources = ["CMakeLists.txt", "sqlite_init.py", "patches/*"]
exports_sources = ["CMakeLists.txt", "patches/*"]

_cmake = None

Expand All @@ -37,7 +40,7 @@ def config_options(self):
del self.options.fPIC

def requirements(self):
self.requires("sqlite3/3.31.0")
self.requires.add("sqlite3/3.31.1")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
Expand All @@ -50,30 +53,44 @@ def _configure_cmake(self):
self._cmake = CMake(self)
self._cmake.definitions["PROJ_TESTS"] = False
self._cmake.definitions["BUILD_LIBPROJ_SHARED"] = self.options.shared
self._cmake.definitions["USE_THREAD"] = self.options.threadsafe
self._cmake.definitions["ENABLE_LTO"] = False
self._cmake.definitions["JNI_SUPPORT"] = False
self._cmake.definitions["BUILD_CCT"] = True
self._cmake.definitions["BUILD_CS2CS"] = True
self._cmake.definitions["BUILD_GEOD"] = True
self._cmake.definitions["BUILD_GIE"] = True
self._cmake.definitions["BUILD_PROJ"] = True
self._cmake.definitions["BUILD_PROJINFO"] = True
self._cmake.definitions["PROJ_DATA_SUBDIR"] = "res"
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"))
for data_file in glob.glob(os.path.join(self.package_folder, "res", "*")):
if not data_file.endswith("proj.db"):
os.remove(data_file)

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "PROJ4"
self.cpp_info.names["cmake_find_package_multi"] = "PROJ4"
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"))
self.cpp_info.system_libs.append("m")
if self.options.threadsafe:
self.cpp_info.system_libs.append("pthread")
if self.options.shared and self.settings.compiler == "Visual Studio":
self.cpp_info.defines.append("PROJ_MSVC_DLL_IMPORT")
self.env_info.PROJ_LIB.append(os.path.join(self.package_folder, "res"))
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
21 changes: 21 additions & 0 deletions recipes/proj/6.x.x/patches/conanize-cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--- a/src/lib_proj.cmake
+++ b/src/lib_proj.cmake
@@ -311,7 +311,7 @@ source_group("Source Files\\Transformations"
source_group("Source Files\\ISO19111"
FILES ${SRC_LIBPROJ_ISO19111})

-include_directories(${CMAKE_SOURCE_DIR}/include)
+include_directories(${PROJ4_SOURCE_DIR}/include)

include_directories(${CMAKE_CURRENT_BINARY_DIR})
source_group("CMake Files" FILES CMakeLists.txt)
@@ -440,8 +440,7 @@ if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
target_link_libraries(${PROJ_CORE_TARGET} ${CMAKE_THREAD_LIBS_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}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
cmake_minimum_required(VERSION 3.1.3)
cmake_minimum_required(VERSION 2.8.11)
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})
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
set_property(TARGET ${PROJECT_NAME} PROPERTY LINKER_LANGUAGE CXX)
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from conans import ConanFile, CMake, tools
import os

Expand Down
11 changes: 0 additions & 11 deletions recipes/proj/all/conandata.yml

This file was deleted.

25 changes: 0 additions & 25 deletions recipes/proj/all/patches/0001-Include-libdl-for-sqlite.patch

This file was deleted.

49 changes: 0 additions & 49 deletions recipes/proj/all/patches/0002-Use-python-instead-of-sqlite.patch

This file was deleted.

7 changes: 0 additions & 7 deletions recipes/proj/all/sqlite_init.py

This file was deleted.

2 changes: 1 addition & 1 deletion recipes/proj/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
versions:
"6.3.0":
folder: all
folder: "6.x.x"