Skip to content

Commit a9b9568

Browse files
committed
Allow using system-wide installed args library
1 parent 168928e commit a9b9568

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ find_package(PkgConfig)
9191
pkg_check_modules(libgcrypt REQUIRED IMPORTED_TARGET libgcrypt)
9292

9393
option(USE_SYSTEM_CPR OFF "Use system-wide installed CPR")
94+
option(USE_SYSTEM_ARGS OFF "Use system-wide installed args")
9495

9596
# makes linking to static libraries easier
9697
option(CMAKE_POSITION_INDEPENDENT_CODE ON)
@@ -100,6 +101,13 @@ if(USE_SYSTEM_CPR)
100101
add_library(cpr ALIAS cpr::cpr)
101102
endif()
102103

104+
if(USE_SYSTEM_ARGS)
105+
find_package(args REQUIRED)
106+
107+
# need to create an alias target to ease linking
108+
add_library(args ALIAS taywee::args)
109+
endif()
110+
103111
# add libraries shipped along with the project
104112
add_subdirectory(lib)
105113

lib/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ if(NOT USE_SYSTEM_CPR)
3131
set_property(TARGET cpr PROPERTY POSITION_INDEPENDENT_CODE ON)
3232
endif()
3333

34-
# it's quite simple dealing with the args library directly from CMake
35-
add_library(args INTERFACE)
36-
target_sources(args INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/args/args.hxx")
37-
target_include_directories(args INTERFACE args)
34+
if(NOT USE_SYSTEM_ARGS)
35+
# it's quite simple dealing with the args library directly from CMake
36+
add_library(args INTERFACE)
37+
target_sources(args INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/args/args.hxx")
38+
target_include_directories(args INTERFACE args)
39+
endif()
3840

3941
# Google Test framework
4042
if(BUILD_TESTING AND NOT TARGET gtest)

0 commit comments

Comments
 (0)