Skip to content
Merged
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
20 changes: 15 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,24 @@ jobs:
msbuild getopt.sln /p:Configuration=Release /p:Platform=Win32
msbuild getopt.sln /p:Configuration=Release /p:Platform=x64

windows-clang:
windows-conan:
runs-on: windows-2025
strategy:
matrix:
profile: [ windows-clang, windows-msvc ]
steps:
- uses: actions/checkout@v4
- name: Install Conan
run: |
pip install conan==2.18.1
conan --version
- name: Build getopt
shell: cmd
run: |
mkdir build
cd build
cmake .. -G Ninja -DCMAKE_C_COMPILER="C:\Program Files\LLVM\bin\clang.exe" -DBUILD_SHARED_LIBS=YES
cmake --build .
conan create . --profile:a=${{ matrix.profile }}
- name: Upload Conan packages to Cloudsmith
run: |
conan remote add cloudsmith https://conan.cloudsmith.io/qmfrederik/gnustep/
conan remote login -p ${{ secrets.CLOUDSMITH_API_KEY }} cloudsmith ${{ secrets.CLOUDSMITH_USER }}
conan upload getopt/* --confirm -r cloudsmith
if: ${{ github.ref == 'refs/heads/master' }}
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
getopt port for Visual C++
==========================
getopt port for Windows
=======================

[![Build status](https://ci.appveyor.com/api/projects/status/reb7dt6x7jdn1700/branch/master?svg=true)](https://ci.appveyor.com/project/qmfrederik/getopt/branch/master)

This repository contains a port of getopt which can be used with Visual C++. It is intended to be used with vcpkg.
This repository contains a port of getopt which can be used with Visual C++ and clang on Windows. It is intended to be used with vcpkg and Conan.

The Visual C++ port was originally done by Ludvik Jerabek, and described in the [Full getopt Port for Unicode and Multibyte Microsoft Visual C, C++, or MFC Projects](https://www.codeproject.com/Articles/157001/Full-getopt-Port-for-Unicode-and-Multibyte-Microso/)
article. This repository contains a copy of that code and the article.
42 changes: 42 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps

class helloRecipe(ConanFile):
name = "getopt"
version = "0.1"

# Optional metadata
license = "LGPL-3.0"
author = "Frederik Carlier <frederik.carlier@keysight.com>"
url = "https://github.com/libimobiledevice-win32/getopt"
description = "getopt for vcpkg"

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

# Sources are located in the same place as this recipe, copy them to the recipe
exports_sources = "CMakeLists.txt", "getopt.*"

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.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
cmake = CMake(self)
cmake.install()
20 changes: 20 additions & 0 deletions windows-clang
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[buildenv]
PATH=+(path)C:\Program Files\LLVM\bin

[settings]
arch=x86_64
build_type=Release
os=Windows

compiler=clang
compiler.cppstd=17
compiler.runtime=dynamic
compiler.version=20
compiler.runtime_version=v144

[options]
*:shared=True

[conf]
tools.cmake.cmaketoolchain:generator=Ninja
tools.build:compiler_executables = {"c": "clang", "cpp": "clang++"}
17 changes: 17 additions & 0 deletions windows-msvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[settings]
arch=x86_64
build_type=Release
os=Windows

compiler=msvc
compiler.cppstd=14
compiler.runtime=msvc
compiler.version=194
compiler.runtime=dynamic
compiler.runtime_type=Release

[options]
*:shared=True

[conf]
tools.cmake.cmaketoolchain:generator=Ninja