Skip to content

Commit

Permalink
cmake: Add a module to find if argp is in a separate library
Browse files Browse the repository at this point in the history
The musl libc, used in Alpine Linux, doesn't have argp support, so check
if it is somewhere else, maybe in the argp-standalone package.

Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Aug 20, 2021
1 parent 9f9588d commit 3f70d31
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dwarves_fprintf.c
dwarves_reorganize.c
dwarves_reorganize.h
cmake/modules/FindDWARF.cmake
cmake/modules/Findargp.cmake
CMakeLists.txt
codiff.c
ctracer.c
Expand Down
41 changes: 41 additions & 0 deletions cmake/modules/Findargp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# - Find argp
# Figure out if argp is in glibc or if it argp-standalone
#
# ARGP_LIBRARY - Library to use argp
# ARGP_FOUND - True if found.

message(STATUS "Checking availability of argp library")

INCLUDE(CheckLibraryExists)

if (ARGP_LIBRARY)
# Already in cache, be silent
set(ARGP_FIND_QUIETLY TRUE)
endif (ARGP_LIBRARY)

find_library(ARGP_LIBRARY
NAMES argp
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 ~/usr/local/lib ~/usr/local/lib64
)

if (ARGP_LIBRARY)
set(ARGP_FOUND TRUE)
set(ARGP_LIBRARY ${ARGP_LIBRARY})
set(CMAKE_REQUIRED_LIBRARIES ${ARGP_LIBRARY})
else (ARGP_LIBRARY)
set(ARGP_LIBRARY "")
endif (ARGP_LIBRARY)

if (ARGP_FOUND)
if (NOT ARGP_FIND_QUIETLY)
message(STATUS "Found argp library: ${ARGP_LIBRARY}")
endif (NOT ARGP_FIND_QUIETLY)
else (ARGP_FOUND)
set(ARGP_FOUND TRUE)
message(STATUS "Assuming argp is in libc")
endif (ARGP_FOUND)

mark_as_advanced(ARGP_LIBRARY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h)

message(STATUS "Checking availability of argp library - done")

0 comments on commit 3f70d31

Please sign in to comment.