Skip to content

Commit

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

Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Aug 20, 2021
1 parent 5244b47 commit 739bc50
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 @@ -16,6 +16,7 @@ dwarves_reorganize.c
dwarves_reorganize.h
cmake/modules/FindDWARF.cmake
cmake/modules/Findargp.cmake
cmake/modules/Findobstack.cmake
CMakeLists.txt
codiff.c
ctracer.c
Expand Down
41 changes: 41 additions & 0 deletions cmake/modules/Findobstack.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# - Find obstack
# Figure out if obstack is in glibc or if it musl-obstack or elsewhere
#
# OBSTACK_LIBRARY - Library to use obstack
# OBSTACK_FOUND - True if found.

message(STATUS "Checking availability of obstack library")

INCLUDE(CheckLibraryExists)

if (OBSTACK_LIBRARY)
# Already in cache, be silent
set(OBSTACK_FIND_QUIETLY TRUE)
endif (OBSTACK_LIBRARY)

find_library(OBSTACK_LIBRARY
NAMES obstack
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64 ~/usr/local/lib ~/usr/local/lib64
)

if (OBSTACK_LIBRARY)
set(OBSTACK_FOUND TRUE)
set(OBSTACK_LIBRARY ${OBSTACK_LIBRARY})
set(CMAKE_REQUIRED_LIBRARIES ${OBSTACK_LIBRARY})
else (OBSTACK_LIBRARY)
set(OBSTACK_LIBRARY "")
endif (OBSTACK_LIBRARY)

if (OBSTACK_FOUND)
if (NOT OBSTACK_FIND_QUIETLY)
message(STATUS "Found obstack library: ${OBSTACK_LIBRARY}")
endif (NOT OBSTACK_FIND_QUIETLY)
else (OBSTACK_FOUND)
set(OBSTACK_FOUND TRUE)
message(STATUS "Assuming obstack is in libc")
endif (OBSTACK_FOUND)

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

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

0 comments on commit 739bc50

Please sign in to comment.