-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* kplot: add recipe * drop support msvc
- Loading branch information
Showing
9 changed files
with
218 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(kplot LANGUAGES C) | ||
|
||
find_package(cairo REQUIRED CONFIG) | ||
|
||
set(kplot_src | ||
${KPLOT_SRC_DIR}/colours.c | ||
${KPLOT_SRC_DIR}/array.c | ||
${KPLOT_SRC_DIR}/border.c | ||
${KPLOT_SRC_DIR}/bucket.c | ||
${KPLOT_SRC_DIR}/buffer.c | ||
${KPLOT_SRC_DIR}/draw.c | ||
${KPLOT_SRC_DIR}/grid.c | ||
${KPLOT_SRC_DIR}/hist.c | ||
${KPLOT_SRC_DIR}/label.c | ||
${KPLOT_SRC_DIR}/kdata.c | ||
${KPLOT_SRC_DIR}/kplot.c | ||
${KPLOT_SRC_DIR}/margin.c | ||
${KPLOT_SRC_DIR}/mean.c | ||
${KPLOT_SRC_DIR}/plotctx.c | ||
${KPLOT_SRC_DIR}/reallocarray.c | ||
${KPLOT_SRC_DIR}/stddev.c | ||
${KPLOT_SRC_DIR}/tic.c | ||
${KPLOT_SRC_DIR}/vector.c | ||
) | ||
|
||
set(kplot_inc | ||
${KPLOT_SRC_DIR}/compat.h | ||
${KPLOT_SRC_DIR}/extern.h | ||
${KPLOT_SRC_DIR}/kplot.h | ||
) | ||
|
||
include_directories(KPLOT_SRC_DIR) | ||
|
||
try_run(HAVE_reallocarray COMPIE_reallocarray ${CMAKE_BINARY_DIR} ${KPLOT_SRC_DIR}/test-reallocarray.c) | ||
|
||
file(READ "${KPLOT_SRC_DIR}/compat.pre.h" COMPAT_CONTENTS) | ||
file(WRITE "${KPLOT_SRC_DIR}/compat.h" "${COMPAT_CONTENTS}") | ||
if (${COMPIE_reallocarray} AND NOT ${HAVE_reallocarray}) | ||
file(APPEND "${KPLOT_SRC_DIR}/compat.h" "#define HAVE_REALLOCARRAY") | ||
endif() | ||
file(READ "${KPLOT_SRC_DIR}/compat.post.h" COMPAT_CONTENTS) | ||
file(APPEND "${KPLOT_SRC_DIR}/compat.h" "${COMPAT_CONTENTS}") | ||
|
||
add_library(kplot ${kplot_src}) | ||
|
||
target_compile_features(kplot PRIVATE c_std_99) | ||
set_target_properties(kplot PROPERTIES | ||
PUBLIC_HEADER "${kplot_inc}" | ||
WINDOWS_EXPORT_ALL_SYMBOLS ON | ||
C_EXTENSIONS OFF | ||
) | ||
target_compile_features(kplot PRIVATE c_std_99) | ||
target_link_libraries(kplot PRIVATE cairo::cairo) | ||
|
||
include(GNUInstallDirs) | ||
|
||
install( | ||
TARGETS kplot | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"0.1.15": | ||
url: "https://github.com/kristapsdz/kplot/archive/refs/tags/VERSION_0_1_15.tar.gz" | ||
sha256: "602ebaac9b67dc7c7e84d8112df887c95ba0a1c4ed71fbab6671f8c5ecf4ba2a" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
from conan import ConanFile | ||
from conan.tools.files import get, copy | ||
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout | ||
from conan.tools.microsoft import is_msvc | ||
from conan.errors import ConanInvalidConfiguration | ||
import os | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
class KplotConan(ConanFile): | ||
name = "kplot" | ||
description = "open source Cairo plotting library" | ||
license = "ISC" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/kristapsdz/kplot/" | ||
topics = ("plot", "cairo", "chart") # no "conan" and project name in topics | ||
settings = "os", "arch", "compiler", "build_type" # even for header only | ||
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) | ||
|
||
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") | ||
# for plain C projects only | ||
self.settings.rm_safe("compiler.libcxx") | ||
self.settings.rm_safe("compiler.cppstd") | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def validate(self): | ||
if is_msvc(self): | ||
raise ConanInvalidConfiguration(f"{self.ref} can not be built on Visual Studio and msvc.") | ||
|
||
def requirements(self): | ||
self.requires("cairo/1.17.4") | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
tc.variables["KPLOT_SRC_DIR"] = self.source_folder.replace("\\", "/") | ||
tc.generate() | ||
|
||
deps = CMakeDeps(self) | ||
deps.generate() | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) | ||
cmake.build() | ||
|
||
def package(self): | ||
copy(self, pattern="LICENSE.md", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) | ||
cmake = CMake(self) | ||
cmake.install() | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["kplot"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(test_package LANGUAGES C) | ||
|
||
find_package(kplot REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.c) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE kplot::kplot) | ||
target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") | ||
self.run(bin_path, env="conanrun") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
#include "cairo.h" | ||
#include "kplot.h" | ||
|
||
int main() { | ||
struct kpair points1[50]; | ||
struct kdata* d1 = kdata_array_alloc(points1, 50); | ||
|
||
kdata_destroy(d1); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ | ||
${CMAKE_CURRENT_BINARY_DIR}/test_package/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from conans import ConanFile, CMake | ||
from conan.tools.build import cross_building | ||
import os | ||
|
||
|
||
class TestPackageV1Conan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "cmake", "cmake_find_package_multi" | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not cross_building(self): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"0.1.15": | ||
folder: all |