Skip to content

Commit 58e5ede

Browse files
committed
proj: several improvements
- 6.x.x folder instead of all, since v7 add options and change cmake target - use exe in sqlite3 package in order to create proj.db during build process, instead of a python script - add threadsafe option - rename conan class - bump sqlite3 version in requirements - remove dl from system_libs - define PROJ_MSVC_DLL_IMPORT if shared and Visual Studio - add generated execs folder to env PATH - install proj.db in res folder - define PROJ4 as CMake exported target
1 parent de0f732 commit 58e5ede

12 files changed

+61
-112
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8.11)
1+
cmake_minimum_required(VERSION 3.1.2)
22
project(cmake_wrapper)
33

44
include(conanbuildinfo.cmake)

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.0":
3+
url: "https://github.com/OSGeo/PROJ/releases/download/6.3.0/proj-6.3.0.tar.gz"
4+
sha256: "68ce9ba0005d442c2c1d238a3b9bc6654c358159b4af467b91e8d5b407c79c77"
5+
patches:
6+
"6.3.0":
7+
- patch_file: "patches/conanize-cmake.patch"
8+
base_path: "source_subfolder"

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

+28-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from conans import ConanFile, CMake, tools
2+
import glob
23
import os
34

45

5-
class LibaecConan(ConanFile):
6+
class ProjConan(ConanFile):
67
name = "proj"
78
license = "MIT"
89
url = "https://github.com/conan-io/conan-center-index"
@@ -13,14 +14,16 @@ class LibaecConan(ConanFile):
1314
options = {
1415
"shared": [True, False],
1516
"fPIC": [True, False],
17+
"threadsafe": [True, False]
1618
}
1719
default_options = {
1820
"shared": False,
1921
"fPIC": True,
22+
"threadsafe": True
2023
}
2124

2225
generators = "cmake"
23-
exports_sources = ["CMakeLists.txt", "sqlite_init.py", "patches/*"]
26+
exports_sources = ["CMakeLists.txt", "patches/*"]
2427

2528
_cmake = None
2629

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

3942
def requirements(self):
40-
self.requires("sqlite3/3.31.0")
43+
self.requires.add("sqlite3/3.31.1")
4144

4245
def source(self):
4346
tools.get(**self.conan_data["sources"][self.version])
@@ -50,30 +53,44 @@ def _configure_cmake(self):
5053
self._cmake = CMake(self)
5154
self._cmake.definitions["PROJ_TESTS"] = False
5255
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"
5366
self._cmake.configure(build_folder=self._build_subfolder)
5467
return self._cmake
5568

5669
def build(self):
5770
for patch in self.conan_data["patches"][self.version]:
5871
tools.patch(**patch)
59-
tools.replace_in_file(os.path.join(self._source_subfolder, "src", "lib_proj.cmake"),
60-
"include_directories(${CMAKE_SOURCE_DIR}/include)",
61-
"include_directories(${PROJ4_SOURCE_DIR}/include)")
6272
cmake = self._configure_cmake()
6373
cmake.build()
6474

6575
def package(self):
6676
self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder)
6777
cmake = self._configure_cmake()
6878
cmake.install()
69-
self.copy("*.db",
70-
src=os.path.join(self.package_folder, "share", "proj"),
71-
dst=os.path.join(self.package_folder, "lib", "proj"))
7279
tools.rmdir(os.path.join(self.package_folder, "share"))
7380
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)
7484

7585
def package_info(self):
86+
self.cpp_info.names["cmake_find_package"] = "PROJ4"
87+
self.cpp_info.names["cmake_find_package_multi"] = "PROJ4"
7688
self.cpp_info.libs = tools.collect_libs(self)
7789
if self.settings.os == "Linux":
78-
self.cpp_info.system_libs = ["pthread", "dl", "m"]
79-
self.env_info.PROJ_LIB.append(os.path.join(self.package_folder, "lib", "proj"))
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
@@ -1,11 +1,9 @@
1-
cmake_minimum_required(VERSION 3.1.3)
1+
cmake_minimum_required(VERSION 2.8.11)
22
project(test_package)
33

4-
set(CMAKE_VERBOSE_MAKEFILE TRUE)
5-
64
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
75
conan_basic_setup()
86

97
add_executable(${PROJECT_NAME} test_package.c)
108
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
11-
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
9+
set_property(TARGET ${PROJECT_NAME} PROPERTY LINKER_LANGUAGE CXX)

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

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
3-
41
from conans import ConanFile, CMake, tools
52
import os
63

recipes/proj/all/conandata.yml

-11
This file was deleted.

recipes/proj/all/patches/0001-Include-libdl-for-sqlite.patch

-25
This file was deleted.

recipes/proj/all/patches/0002-Use-python-instead-of-sqlite.patch

-49
This file was deleted.

recipes/proj/all/sqlite_init.py

-7
This file was deleted.

recipes/proj/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
versions:
22
"6.3.0":
3-
folder: all
3+
folder: "6.x.x"

0 commit comments

Comments
 (0)