forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(conan-io#15069) crowcpp-crow: add version 1.0+5, support conan v2, u…
…pdate dependencies * crowcpp-crow: add version 1.0+5, support conan v2, update dependencies * remove cmake_verbose_makefile * fix patch description name * fix patch_source * fix urls of 0.2, 0.3 * use `dependencies` Co-authored-by: Uilian Ries <uilianries@gmail.com> Co-authored-by: Uilian Ries <uilianries@gmail.com>
- Loading branch information
1 parent
b886e31
commit 27ab96e
Showing
7 changed files
with
159 additions
and
66 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
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 |
---|---|---|
@@ -1,82 +1,135 @@ | ||
from conans import ConanFile, tools, CMake | ||
from conan import ConanFile | ||
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout | ||
from conan.tools.scm import Version | ||
import os | ||
|
||
required_conan_version = ">=1.33.0" | ||
|
||
required_conan_version = ">=1.52.0" | ||
|
||
class CrowConan(ConanFile): | ||
name = "crowcpp-crow" | ||
homepage = "http://crowcpp.org/" | ||
description = "Crow is a C++ microframework for running web services." | ||
topics = ("web", "microframework", "header-only") | ||
license = "BSD-3-Clause" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "http://crowcpp.org/" | ||
topics = ("web", "microframework", "header-only") | ||
settings = "os", "compiler", "arch", "build_type" | ||
license = "BSD-3-Clause" | ||
|
||
provides = "crow" | ||
|
||
options = { | ||
"amalgamation": [True, False], | ||
"with_ssl": [True, False], | ||
"with_compression": [True, False], | ||
} | ||
default_options = { | ||
"amalgamation": False, | ||
"with_ssl": False, | ||
"with_compression": False, | ||
} | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
def _min_cppstd(self): | ||
return 11 | ||
|
||
def export_sources(self): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
self.copy(patch["patch_file"]) | ||
export_conandata_patches(self) | ||
|
||
def configure(self): | ||
if Version(self.version) < "1.0": | ||
del self.options.with_ssl | ||
del self.options.with_compression | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def requirements(self): | ||
self.requires("boost/1.77.0") | ||
self.requires("boost/1.81.0") | ||
if self.version == "0.2": | ||
self.requires("openssl/1.1.1l") | ||
self.requires("openssl/1.1.1s") | ||
if Version(self.version) >= "1.0": | ||
if self.options.with_ssl: | ||
self.requires("openssl/1.1.1s") | ||
if self.options.with_compression: | ||
self.requires("zlib/1.2.13") | ||
|
||
def package_id(self): | ||
self.info.settings.clear() | ||
|
||
def validate(self): | ||
if self.settings.compiler.cppstd: | ||
check_min_cppstd(self, self._min_cppstd) | ||
|
||
def source(self): | ||
tools.get( | ||
**self.conan_data["sources"][self.version], | ||
strip_root=True, | ||
destination=self._source_subfolder | ||
) | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
if self.options.amalgamation: | ||
tc = CMakeToolchain(self) | ||
if Version(self.version) < "1.0": | ||
tc.variables["BUILD_EXAMPLES"] = False | ||
tc.variables["BUILD_TESTING"] = False | ||
else: | ||
tc.variables["CROW_BUILD_EXAMPLES"] = False | ||
tc.variables["CROW_BUILD_TESTS"] = False | ||
tc.variables["CROW_AMALGAMATE"] = True | ||
tc.generate() | ||
|
||
def build(self): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
tools.patch(**patch) | ||
apply_conandata_patches(self) | ||
|
||
if self.options.amalgamation: | ||
cmake = CMake(self) | ||
cmake.definitions["BUILD_EXAMPLES"] = False | ||
cmake.definitions["BUILD_TESTING"] = False | ||
cmake.configure(source_folder=self._source_subfolder) | ||
cmake.build(target="amalgamation") | ||
cmake.configure() | ||
if Version(self.version) < "1.0": | ||
cmake.build(target="amalgamation") | ||
else: | ||
cmake.build(target="crow_amalgamated") | ||
|
||
|
||
def package(self): | ||
self.copy(pattern="LICENSE*", dst="licenses", src=self._source_subfolder) | ||
copy(self, pattern="LICENSE*", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) | ||
|
||
if self.options.amalgamation: | ||
self.copy("crow_all.h", dst="include") | ||
copy( | ||
self, | ||
pattern="crow_all.h", | ||
dst=os.path.join(self.package_folder, "include"), | ||
src=self.build_folder, | ||
) | ||
else: | ||
self.copy( | ||
"*.h", | ||
dst=os.path.join("include"), | ||
src=os.path.join(self._source_subfolder, "include"), | ||
copy( | ||
self, | ||
pattern="*.h", | ||
dst=os.path.join(self.package_folder, "include"), | ||
src=os.path.join(self.source_folder, "include"), | ||
) | ||
self.copy( | ||
"*.hpp", | ||
dst=os.path.join("include"), | ||
src=os.path.join(self._source_subfolder, "include"), | ||
copy( | ||
self, | ||
pattern="*.hpp", | ||
dst=os.path.join(self.package_folder, "include"), | ||
src=os.path.join(self.source_folder, "include"), | ||
) | ||
|
||
def package_id(self): | ||
self.info.settings.clear() | ||
|
||
def package_info(self): | ||
# These are not official targets, this is just the name (without fork prefix) | ||
self.cpp_info.names["cmake_find_package"] = "crow" | ||
self.cpp_info.names["cmake_find_package_multi"] = "crow" | ||
self.cpp_info.bindirs = [] | ||
self.cpp_info.libdirs = [] | ||
|
||
self.cpp_info.requires.append("boost::headers") | ||
|
||
if self.settings.os in ("FreeBSD", "Linux"): | ||
self.cpp_info.system_libs = ["pthread"] | ||
|
||
self.cpp_info.set_property("cmake_file_name", "Crow") | ||
self.cpp_info.set_property("cmake_target_name", "Crow::Crow") | ||
|
||
if Version(self.version) >= "1.0": | ||
if self.options.with_ssl: | ||
self.cpp_info.defines.append("CROW_ENABLE_SSL") | ||
self.cpp_info.requires.append("OpenSSL::ssl") | ||
if self.options.with_compression: | ||
self.cpp_info.defines.append("CROW_ENABLE_COMPRESSION") | ||
self.cpp_info.requires.append("zlib::zlib") | ||
|
||
# TODO: to remove in conan v2 once cmake_find_package_* generators removed | ||
self.cpp_info.names["cmake_find_package"] = "Crow" | ||
self.cpp_info.names["cmake_find_package_multi"] = "Crow" | ||
|
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 |
---|---|---|
@@ -1,19 +1,16 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package) | ||
cmake_minimum_required(VERSION 3.8) | ||
project(test_package LANGUAGES CXX) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
find_package(crow REQUIRED) | ||
find_package(Crow REQUIRED) | ||
|
||
option(CROW_AMALGAMATION "CROW IS DEPLOYED AS AMALGAMATION" ON) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} crow::crow) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE Crow::Crow) | ||
|
||
if(CROW_AMALGAMATION) | ||
target_compile_definitions(${PROJECT_NAME} PRIVATE CROW_AMALGAMATION) | ||
endif(CROW_AMALGAMATION) | ||
unset(CROW_AMALGAMATION CACHE) | ||
|
||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) | ||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) |
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 |
---|---|---|
@@ -1,18 +1,31 @@ | ||
from conans import ConanFile, CMake, tools | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake", "cmake_find_package" | ||
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 generate(self): | ||
tc = CMakeToolchain(self) | ||
tc.variables["CROW_AMALGAMATION"] = self.dependencies["crowcpp-crow"].options.amalgamation | ||
tc.generate() | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.definitions["CROW_AMALGAMATION"] = self.options["crowcpp-crow"].amalgamation | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) | ||
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,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,19 @@ | ||
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.definitions["CROW_AMALGAMATION"] = self.options["crowcpp-crow"].amalgamation | ||
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
versions: | ||
"1.0+5": | ||
folder: all | ||
"1.0+3": | ||
folder: all | ||
"1.0+1": | ||
|