Skip to content

Commit

Permalink
Merge pull request #70 from Shaheen47/port-to-conan2
Browse files Browse the repository at this point in the history
Files for building conan package
  • Loading branch information
ryanhaining authored Jan 18, 2020
2 parents 342e752 + 2547739 commit 6463d85
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
41 changes: 41 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 3.12)
project(cppitertools VERSION 2.0)
set(CMAKE_CXX_STANDARD 17)


# installation directories
set(cppitertools_INSTALL_INCLUDE_DIR "include" CACHE STRING "The installation include directory")
set(cppitertools_INSTALL_CMAKE_DIR "share/cppitertools/cmake" CACHE STRING "The installation cmake directory")


# define a header-only library
add_library(cppitertools INTERFACE)
add_library(cppitertools::cppitertools ALIAS cppitertools)

target_include_directories(cppitertools INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${cppitertools_INSTALL_CMAKE_DIR}/cppitertools>
)


# require C++17
target_compile_features(cppitertools INTERFACE cxx_std_17)

# Make package findable
configure_file(cmake/dummy-config.cmake.in cppitertools-config.cmake @ONLY)

# Enable version checks in find_package
include(CMakePackageConfigHelpers)
write_basic_package_version_file(cppitertools-config-version.cmake COMPATIBILITY SameMajorVersion)

# install and export target
install(TARGETS cppitertools EXPORT cppitertools-targets)

install(EXPORT cppitertools-targets
FILE cppitertools-config.cmake
NAMESPACE cppitertools::
DESTINATION ${cppitertools_INSTALL_CMAKE_DIR}/cppitertools
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cppitertools-config-version.cmake DESTINATION ${cppitertools_INSTALL_CMAKE_DIR})
install(DIRECTORY . DESTINATION ${cppitertools_INSTALL_INCLUDE_DIR}/cppitertools)
5 changes: 5 additions & 0 deletions cmake/dummy-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Dummy config file
# When a dependency is added with add_subdirectory, but searched with find_package

# Redirect to the directory added with add_subdirectory
add_subdirectory(@PROJECT_SOURCE_DIR@ @PROJECT_BINARY_DIR@)
35 changes: 35 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from conans import ConanFile, CMake

import os


class CppIterTools(ConanFile):
name = "cppitertools"
version = "2.0"
author = "Ryan Haining <[email protected]>"
homepage = "https://github.com/ryanhaining/cppitertools"
url = homepage
topics = ("conan", "itertools", "cppitertools")
license = 'BSD 2-Clause "Simplified" License'
description = "Range-based for loop add-ons inspired by the Python builtins and itertools library. " \
"Like itertools and the Python3 builtins, this library uses lazy evaluation wherever possible."
settings = "build_type", "compiler", "os", "arch"
generators = "cmake", "cmake_find_package", "cmake_paths"
exports = "LICENSE.md"

exports_sources = list()
for file in os.listdir("."):
if file.endswith(".hpp"):
exports_sources.append(str(file))
print("found files: " + str(exports_sources))
exports_sources = tuple(exports_sources) + \
("internal/*", "CMakeLists.txt", "cmake/dummy-config.cmake.in")
no_copy_source = True

def package(self):
cmake = CMake(self)
cmake.configure()
cmake.install()

def package_id(self):
self.info.header_only()

0 comments on commit 6463d85

Please sign in to comment.