-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from Shaheen47/port-to-conan2
Files for building conan package
- Loading branch information
Showing
3 changed files
with
81 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,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) |
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,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@) |
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,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() |