catchorg / Clara

A simple to use, composable, command line parser for C++ 11 and beyond
Boost Software License 1.0
648 stars 67 forks source link

added cmake target #92

Open jasonbeach opened 5 years ago

jasonbeach commented 5 years ago

I made two simple changes to make including clara in some cmake projects easier:

1) defined an interface library that other targets could reference. This doesn't go all out and export targets,etc. as I primarily develop on linux and am not sure how to do that in a windows friendly way. But at least it reduces basic cmake (version > 3.11) inclusion to something like:

FetchContent_Declare(
  clara_fc
  GIT_REPOSITORY https://github.com/catchorg/Clara.git
  GIT_TAG v1.1.5
  GIT_SHALLOW TRUE
)

FetchContent_MakeAvailable(clara_fc )

add_executable(main main.cpp)

target_link_libraries(main clara)

2) added an option to skip building the tests if clara is not the top level project.