Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
19 changes: 19 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,22 @@ if(${LINKS_PLATFORM_BENCHMARKS})
target_link_libraries(${PROJECT_NAME}.Benchmarks PRIVATE benchmark::benchmark)
target_link_libraries(${PROJECT_NAME}.Benchmarks PRIVATE ${PROJECT_NAME}.Library)
endif()

# Install targets for Conan packaging
install(TARGETS ${PROJECT_NAME}.Library
EXPORT ${PROJECT_NAME}Targets
INCLUDES DESTINATION include
)

# Install headers
install(DIRECTORY ${PROJECT_NAME}/
DESTINATION include/${PROJECT_NAME}
FILES_MATCHING PATTERN "*.h"
)

# Install export
install(EXPORT ${PROJECT_NAME}Targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION lib/cmake/${PROJECT_NAME}
)
74 changes: 74 additions & 0 deletions cpp/CONAN_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Platform.Data.Doublets Conan Package

This directory contains the Conan package configuration for Platform.Data.Doublets.

## Package Information

- **Name**: `platform.data.doublets`
- **Version**: `0.1.0`
- **Type**: Header-only C++ library

## Dependencies

The package depends on the following Platform libraries:
- platform.interfaces (0.3.41)
- platform.collections.methods (0.3.0)
- platform.collections (0.2.1)
- platform.numbers (0.1.0)
- platform.memory (0.1.0)
- platform.exceptions (0.3.2)
- platform.data (0.1.1)
- platform.setters (0.1.0)
- platform.ranges (0.2.0)
- mio (cci.20201220)

## Building the Package

### Prerequisites
1. Install Conan: `pip install conan`
2. Set up a Conan profile for your compiler

### Creating the Package
```bash
# From the cpp directory
conan create . platform.data.doublets/0.1.0@
```

### Using the Package

Add to your `conanfile.txt`:
```ini
[requires]
platform.data.doublets/0.1.0

[generators]
CMakeDeps
CMakeToolchain
```

Or in `conanfile.py`:
```python
requires = "platform.data.doublets/0.1.0"
```

### CMake Integration

```cmake
find_package(Platform.Data.Doublets REQUIRED)
target_link_libraries(your_target Platform.Data.Doublets::Platform.Data.Doublets.Library)
```

## Package Options

- `tests`: Build tests (default: False)
- `benchmarks`: Build benchmarks (default: False)
- `shared`: Build shared library (default: False)
- `fPIC`: Position independent code (default: True)

## Files Structure

- `conanfile.py`: Main Conan recipe
- `CMakeLists.txt`: CMake build configuration
- `Platform.Data.Doublets/`: Header files
- `Platform.Data.Doublets.Tests/`: Test files
- `Platform.Data.Doublets.Benchmarks/`: Benchmark files
89 changes: 89 additions & 0 deletions cpp/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout, CMakeDeps, CMakeToolchain
from conan.tools.files import copy
import os

class PlatformDataDoubletsConan(ConanFile):
name = "platform.data.doublets"
version = "0.1.0" # Will be updated from git tag or version file

# Binary configuration
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"tests": [True, False],
"benchmarks": [True, False]
}
default_options = {
"shared": False,
"fPIC": True,
"tests": False,
"benchmarks": False
}

# Sources are located in the same place as this recipe, copy them to the recipe
exports_sources = "CMakeLists.txt", "Platform.Data.Doublets/*", "Platform.Data.Doublets.Tests/*", "Platform.Data.Doublets.Benchmarks/*"

# Dependencies
requires = (
"platform.interfaces/0.3.41",
"platform.collections.methods/0.3.0",
"platform.collections/0.2.1",
"platform.numbers/0.1.0",
"platform.memory/0.1.0",
"platform.exceptions/0.3.2",
"platform.data/0.1.1",
"platform.setters/0.1.0",
"platform.ranges/0.2.0",
"mio/cci.20201220"
)

def build_requirements(self):
if self.options.tests:
self.test_requires("gtest/cci.20210126")
if self.options.benchmarks:
self.test_requires("benchmark/1.6.0")

def configure(self):
if self.settings.compiler.cppstd:
self.settings.compiler.cppstd = "20"

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

def layout(self):
cmake_layout(self)

def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
tc.variables["LINKS_PLATFORM_TESTS"] = self.options.tests
tc.variables["LINKS_PLATFORM_BENCHMARKS"] = self.options.benchmarks
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
if self.options.tests:
cmake.test()

def package(self):
copy(self, "*.h", dst=os.path.join(self.package_folder, "include"), src=self.source_folder)
copy(self, "*.hpp", dst=os.path.join(self.package_folder, "include"), src=self.source_folder)
cmake = CMake(self)
cmake.install()

def package_info(self):
self.cpp_info.libs = [] # Header-only library
self.cpp_info.includedirs = ["include"]

# Set the target name to match CMake target
self.cpp_info.set_property("cmake_target_name", "Platform.Data.Doublets::Platform.Data.Doublets.Library")

# Add system libs if needed
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("dl")
1 change: 1 addition & 0 deletions cpp/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ platform.random/0.2.0
platform.interfaces/0.3.41
platform.ranges/0.2.0
platform.numbers/0.1.0
platform.setters/0.1.0
mio/cci.20201220

[generators]
Expand Down
123 changes: 123 additions & 0 deletions examples/validate_conan_package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/usr/bin/env python3
"""
Validation script for Platform.Data.Doublets Conan package
This script validates the structure without requiring Conan to be installed
"""

import os
import sys

def validate_conanfile():
"""Validate conanfile.py structure"""
conanfile_path = "cpp/conanfile.py"

if not os.path.exists(conanfile_path):
print("❌ conanfile.py not found")
return False

with open(conanfile_path, 'r') as f:
content = f.read()

required_elements = [
"class PlatformDataDoubletsConan",
"name = \"platform.data.doublets\"",
"def build(",
"def package(",
"def package_info(",
"platform.interfaces",
"platform.collections",
"platform.memory",
"platform.data",
"platform.exceptions",
"platform.setters",
"platform.ranges"
]

missing = []
for element in required_elements:
if element not in content:
missing.append(element)

if missing:
print(f"❌ Missing required elements: {missing}")
return False

print("βœ… conanfile.py structure is valid")
return True

def validate_cmake():
"""Validate CMakeLists.txt has required elements for Conan"""
cmake_path = "cpp/CMakeLists.txt"

if not os.path.exists(cmake_path):
print("❌ CMakeLists.txt not found")
return False

with open(cmake_path, 'r') as f:
content = f.read()

required_elements = [
"find_package(Platform.Interfaces)",
"find_package(Platform.Setters)",
"install(TARGETS",
"install(DIRECTORY",
"install(EXPORT"
]

missing = []
for element in required_elements:
if element not in content:
missing.append(element)

if missing:
print(f"❌ CMakeLists.txt missing required elements: {missing}")
return False

print("βœ… CMakeLists.txt has required Conan elements")
return True

def validate_headers():
"""Validate that header files exist"""
headers_dir = "cpp/Platform.Data.Doublets"

if not os.path.exists(headers_dir):
print("❌ Platform.Data.Doublets directory not found")
return False

header_files = []
for root, dirs, files in os.walk(headers_dir):
for file in files:
if file.endswith('.h'):
header_files.append(os.path.join(root, file))

if not header_files:
print("❌ No header files found")
return False

print(f"βœ… Found {len(header_files)} header files")
return True

def main():
print("πŸ” Validating Platform.Data.Doublets Conan package...")

# Change to repository root
script_dir = os.path.dirname(os.path.abspath(__file__))
repo_root = os.path.dirname(script_dir)
os.chdir(repo_root)

print(f"πŸ“ Working directory: {os.getcwd()}")

all_valid = True
all_valid &= validate_conanfile()
all_valid &= validate_cmake()
all_valid &= validate_headers()

if all_valid:
print("\nπŸŽ‰ All validations passed! Conan package structure is ready.")
return 0
else:
print("\n❌ Some validations failed. Please fix the issues above.")
return 1

if __name__ == "__main__":
sys.exit(main())
Loading