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 mikktspace 20200325 #2899

Merged
Show file tree
Hide file tree
Changes from 4 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
22 changes: 22 additions & 0 deletions recipes/mikktspace/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.4)
project(mikktspace)

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

if(WIN32 AND BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()

add_library(mikktspace ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder/mikktspace.c)
target_include_directories(mikktspace PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder)
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux")
target_link_libraries(mikktspace PRIVATE m)
endif()

install(TARGETS mikktspace
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder/mikktspace.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
4 changes: 4 additions & 0 deletions recipes/mikktspace/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"cci.20200325":
url: "https://github.com/mmikk/MikkTSpace/archive/master.zip"
sha256: "c4377c330d929134b4990567c329302f9e00eb818fde4ff31967e206926536ff"
intelligide marked this conversation as resolved.
Show resolved Hide resolved
75 changes: 75 additions & 0 deletions recipes/mikktspace/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import os
import glob
from conans import ConanFile, CMake, tools


class MikkTSpaceConan(ConanFile):
name = "mikktspace"
description = " A common standard for tangent space used in baking tools to produce normal maps."
homepage = "https://github.com/mmikk/MikkTSpace"
url = "https://github.com/conan-io/conan-center-index"
license = "Zlib"
topics = ("conan", "tangent", "space", "normal")

settings = "os", "arch", "compiler", "build_type"
options = {
"fPIC": [True, False],
"shared": [True, False],
}
default_options = {
"fPIC": True,
"shared": False
}

generators = "cmake"
exports_sources = ['CMakeLists.txt', 'patches/*']
intelligide marked this conversation as resolved.
Show resolved Hide resolved

_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = glob.glob('MikkTSpace-*/')[0]
os.rename(extracted_dir, self._source_subfolder)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
del self.options.fPIC
del self.settings.compiler.cppstd
del self.settings.compiler.libcxx

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.configure()
return self._cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

@property
def _extracted_license(self):
content_lines = open(os.path.join(self.source_folder, self._source_subfolder, "mikktspace.h")).readlines()
license_content = []
for i in range(4, 21):
license_content.append(content_lines[i][4:-1])
return "\n".join(license_content)
Comment on lines +60 to +65
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the file changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's an unmaintained project. I don't think this will change in the future.


def package(self):
tools.save(os.path.join(self.package_folder, "licenses", "LICENSE"), self._extracted_license)
cmake = self._configure_cmake()
cmake.install()

def package_info(self):
self.cpp_info.libs = ["mikktspace"]
if self.settings.os == "Linux":
self.cpp_info.system_libs = ["m"]
9 changes: 9 additions & 0 deletions recipes/mikktspace/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

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

add_executable(${CMAKE_PROJECT_NAME} test_package.cpp)
target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS})

16 changes: 16 additions & 0 deletions recipes/mikktspace/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
from conans import ConanFile, CMake, tools


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

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

def test(self):
if not tools.cross_building(self.settings):
self.run(os.path.join("bin", "test_package"), run_environment=True)
26 changes: 26 additions & 0 deletions recipes/mikktspace/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>

#include <mikktspace.h>

static int GetNumFaces(const SMikkTSpaceContext *pContext)
{
return 0;
}

int main()
{
SMikkTSpaceInterface sInterface = {NULL};
sInterface.m_getNumFaces = GetNumFaces;

SMikkTSpaceContext sContext = {NULL};
sContext.m_pInterface = &sInterface;

genTangSpaceDefault(&sContext);

return 0;
}
3 changes: 3 additions & 0 deletions recipes/mikktspace/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"cci.20200325":
folder: all