Skip to content

Conversation

@LinusHenke1701
Copy link

I was looking for a nice C/C++ arg parser, where I stumbled upon your repository. I however like to build my projects with CMake and manage my external dependencies with the FetchContent command. I added the necessarry files to do that and build and install it locally by downloading cloning the repo. For local installation a user just has to run

$ mkdir build && cd build
$ cmake ..
$ sudo make install

if the user wants to run tests they have to run

$ mkdir build && cd build
$ cmake -DBUILD_TESTS ..
$ ctest

Similarly you can also build the examples like that. Now if you want to use the library after installation in a project you just have to follow this simple example:

cmake_minimum_required(VERSION 3.16)
project(test)

find_package(args REQUIRED)

add_executable(test main.c)
target_link_libraries(test PRIVATE args)

Or if the library should not be installed globally but only for building a binary one can use FetchContent:

cmake_minimum_required(VERSION 3.16)
project(test)
include(FetchContent)

FetchContent_Declare(
    args
    GIT_REPOSITORY https://github.com/nmulholl/args.git
    GIT_TAG 3.3.1 # This is just a preliminary tag. If you change it, note that you have to change the version info in CMakeLists.txt
)
FetchContent_MakeAvailable(args)

add_executable(test main.c)
target_link_libraries(test args)

Cheers
Linus

The libary can now be built and installed using CMake.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant