mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-14 18:26:47 +02:00
Package cgltf as header-only library.
This way we can continue to override CGLTF_ATOF to fix floating point conversion issues on systems with `,` decimal separators.
This commit is contained in:
parent
0da14ad34d
commit
d52da5d5fe
2 changed files with 14 additions and 83 deletions
|
@ -1,23 +0,0 @@
|
|||
cmake_minimum_required(VERSION 3.4)
|
||||
project(cgltf C)
|
||||
|
||||
set(SOURCES_DIR ${CMAKE_CURRENT_LIST_DIR}/src)
|
||||
|
||||
set(SRC_FILES
|
||||
${SOURCES_DIR}/cgltf.c
|
||||
${SOURCES_DIR}/cgltf_write.c
|
||||
)
|
||||
set(HEADER_FILES
|
||||
${SOURCES_DIR}/cgltf.h
|
||||
${SOURCES_DIR}/cgltf_write.h
|
||||
)
|
||||
|
||||
add_library(${PROJECT_NAME} ${SRC_FILES})
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 99)
|
||||
if(MSVC AND BUILD_SHARED_LIBS)
|
||||
set_property(TARGET ${PROJECT_NAME} PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
endif()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(TARGETS ${PROJECT_NAME})
|
||||
install(FILES ${HEADER_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
@ -15,74 +15,28 @@ class CgltfConan(ConanFile):
|
|||
homepage = "https://github.com/jkuhlmann/cgltf"
|
||||
topics = ("gltf", "header-only")
|
||||
|
||||
package_type = "library"
|
||||
package_type = "header-library"
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
}
|
||||
|
||||
def export_sources(self):
|
||||
copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder)
|
||||
export_conandata_patches(self)
|
||||
|
||||
def config_options(self):
|
||||
if self.settings.os == "Windows":
|
||||
del self.options.fPIC
|
||||
|
||||
def configure(self):
|
||||
if self.options.shared:
|
||||
self.options.rm_safe("fPIC")
|
||||
self.settings.rm_safe("compiler.libcxx")
|
||||
self.settings.rm_safe("compiler.cppstd")
|
||||
no_copy_source = True
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self, src_folder="src")
|
||||
|
||||
def package_id(self):
|
||||
self.info.clear()
|
||||
|
||||
def source(self):
|
||||
get(self, **self.conan_data["sources"][self.version], strip_root=True)
|
||||
|
||||
def _create_source_files(self):
|
||||
cgltf_c = '#define CGLTF_IMPLEMENTATION\n#include "cgltf.h"\n'
|
||||
cgltf_write_c = '#define CGLTF_WRITE_IMPLEMENTATION\n#include "cgltf_write.h"\n'
|
||||
save(self, os.path.join(self.build_folder, self.source_folder, "cgltf.c"), cgltf_c)
|
||||
save(self, os.path.join(self.build_folder, self.source_folder, "cgltf_write.c"), cgltf_write_c)
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
tc.generate()
|
||||
|
||||
def build(self):
|
||||
self._create_source_files()
|
||||
cmake = CMake(self)
|
||||
cmake.configure(build_script_folder=self.source_path.parent)
|
||||
cmake.build()
|
||||
|
||||
def _remove_implementation(self, header_fullpath):
|
||||
header_content = load(self, header_fullpath)
|
||||
begin = header_content.find("/*\n *\n * Stop now, if you are only interested in the API.")
|
||||
end = header_content.find("/* cgltf is distributed under MIT license:", begin)
|
||||
implementation = header_content[begin:end]
|
||||
replace_in_file(
|
||||
self,
|
||||
header_fullpath,
|
||||
implementation,
|
||||
"/**\n * Implementation removed by conan during packaging.\n * Don't forget to link libs provided in this package.\n */\n\n",
|
||||
)
|
||||
|
||||
def package(self):
|
||||
copy(self, "LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
|
||||
cmake = CMake(self)
|
||||
cmake.install()
|
||||
for header_file in ["cgltf.h", "cgltf_write.h"]:
|
||||
header_fullpath = os.path.join(self.package_folder, "include", header_file)
|
||||
self._remove_implementation(header_fullpath)
|
||||
for dll in (self.package_path / "lib").glob("*.dll"):
|
||||
rename(self, dll, self.package_path / "bin" / dll.name)
|
||||
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses"))
|
||||
for header in ["cgltf.h", "cgltf_write.h"]:
|
||||
copy(self, header, self.source_folder, os.path.join(self.package_folder, "include"))
|
||||
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.libs = ["cgltf"]
|
||||
self.cpp_info.set_property("cmake_file_name", "cgltf")
|
||||
self.cpp_info.set_property("cmake_target_name", "cgltf::cgltf")
|
||||
|
||||
self.cpp_info.bindirs = []
|
||||
self.cpp_info.libdirs = []
|
||||
|
|
Loading…
Reference in a new issue