From 8f237bde1508b86cb3469901b534933bb4bbd6b5 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Mon, 12 Dec 2022 15:00:23 +0100 Subject: [PATCH] cmake: Check for Argp also on Linux to fix alpine build This adjusts also usage of ARGP_LIBRARY to use ARGP_LIBRARIES which is defined by the FindArgp module, unlike the former one in case it is provided by libc directly. Fixes: #167 Signed-off-by: Jakub Jelen Reviewed-by: Norbert Pocs --- CMakeLists.txt | 4 +--- cmake/Modules/FindArgp.cmake | 4 ++++ examples/CMakeLists.txt | 20 ++++++++++---------- tests/CMakeLists.txt | 4 ++-- tests/server/test_server/CMakeLists.txt | 2 +- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 741dc610..e6931db4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,9 +103,7 @@ if (WITH_NACL) endif (NOT NACL_FOUND) endif (WITH_NACL) -if (BSD OR SOLARIS OR OSX OR CYGWIN) - find_package(Argp) -endif (BSD OR SOLARIS OR OSX OR CYGWIN) +find_package(Argp) # Disable symbol versioning in non UNIX platforms if (UNIX) diff --git a/cmake/Modules/FindArgp.cmake b/cmake/Modules/FindArgp.cmake index b2d91562..13d74637 100644 --- a/cmake/Modules/FindArgp.cmake +++ b/cmake/Modules/FindArgp.cmake @@ -1,4 +1,8 @@ # - Try to find ARGP +# +# The argp can be either shipped as part of libc (ex. glibc) or as a separate +# library that requires additional linking (ex. Windows, Mac, musl libc, ...) +# # Once done this will define # # ARGP_ROOT_DIR - Set this variable to the root installation of ARGP diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 466865f7..72ceed2f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -39,34 +39,34 @@ if (UNIX AND NOT WIN32) target_compile_options(ssh-X11-client PRIVATE ${DEFAULT_C_COMPILE_FLAGS}) target_link_libraries(ssh-X11-client ssh::ssh) - if (WITH_SERVER AND (ARGP_LIBRARY OR HAVE_ARGP_H)) + if (WITH_SERVER AND (ARGP_LIBRARIES OR HAVE_ARGP_H)) if (HAVE_LIBUTIL) add_executable(ssh_server_fork ssh_server.c) target_compile_options(ssh_server_fork PRIVATE ${DEFAULT_C_COMPILE_FLAGS} -DWITH_FORK) - target_link_libraries(ssh_server_fork ssh::ssh ${ARGP_LIBRARY} util) + target_link_libraries(ssh_server_fork ssh::ssh ${ARGP_LIBRARIES} util) add_executable(ssh_server_pthread ssh_server.c) target_compile_options(ssh_server_pthread PRIVATE ${DEFAULT_C_COMPILE_FLAGS}) - target_link_libraries(ssh_server_pthread ssh::ssh ${ARGP_LIBRARY} pthread util) + target_link_libraries(ssh_server_pthread ssh::ssh ${ARGP_LIBRARIES} pthread util) endif (HAVE_LIBUTIL) if (WITH_GSSAPI AND GSSAPI_FOUND) add_executable(proxy proxy.c) target_compile_options(proxy PRIVATE ${DEFAULT_C_COMPILE_FLAGS}) - target_link_libraries(proxy ssh::ssh ${ARGP_LIBRARY}) + target_link_libraries(proxy ssh::ssh ${ARGP_LIBRARIES}) add_executable(sshd_direct-tcpip sshd_direct-tcpip.c) target_compile_options(sshd_direct-tcpip PRIVATE ${DEFAULT_C_COMPILE_FLAGS}) - target_link_libraries(sshd_direct-tcpip ssh::ssh ${ARGP_LIBRARY}) + target_link_libraries(sshd_direct-tcpip ssh::ssh ${ARGP_LIBRARIES}) endif (WITH_GSSAPI AND GSSAPI_FOUND) add_executable(samplesshd-kbdint samplesshd-kbdint.c) target_compile_options(samplesshd-kbdint PRIVATE ${DEFAULT_C_COMPILE_FLAGS}) - target_link_libraries(samplesshd-kbdint ssh::ssh ${ARGP_LIBRARY}) + target_link_libraries(samplesshd-kbdint ssh::ssh ${ARGP_LIBRARIES}) add_executable(keygen2 keygen2.c ${examples_SRCS}) target_compile_options(keygen2 PRIVATE ${DEFAULT_C_COMPILE_FLAGS}) - target_link_libraries(keygen2 ssh::ssh ${ARGP_LIBRARY}) + target_link_libraries(keygen2 ssh::ssh ${ARGP_LIBRARIES}) endif() endif (UNIX AND NOT WIN32) @@ -75,9 +75,9 @@ if (WITH_SERVER) add_executable(samplesshd-cb samplesshd-cb.c) target_compile_options(samplesshd-cb PRIVATE ${DEFAULT_C_COMPILE_FLAGS}) target_link_libraries(samplesshd-cb ssh::ssh) - if (ARGP_LIBRARY OR HAVE_ARGP_H) - target_link_libraries(samplesshd-cb ${ARGP_LIBRARY}) - endif(ARGP_LIBRARY OR HAVE_ARGP_H) + if (ARGP_LIBRARIES OR HAVE_ARGP_H) + target_link_libraries(samplesshd-cb ${ARGP_LIBRARIES}) + endif(ARGP_LIBRARIES OR HAVE_ARGP_H) endif() add_executable(exec exec.c ${examples_SRCS}) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d472dc06..f5c30061 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -73,9 +73,9 @@ if (CLIENT_TESTING) ) endif () -if (ARGP_LIBRARY) +if (ARGP_LIBRARIES) target_link_libraries(${TORTURE_LIBRARY} - ${ARGP_LIBRARY} + ${ARGP_LIBRARIES} ) endif() diff --git a/tests/server/test_server/CMakeLists.txt b/tests/server/test_server/CMakeLists.txt index fe5e7d09..2f5a128d 100644 --- a/tests/server/test_server/CMakeLists.txt +++ b/tests/server/test_server/CMakeLists.txt @@ -30,7 +30,7 @@ if (UNIX AND NOT WIN32) target_link_libraries(test_server testserver ssh::ssh - ${ARGP_LIBRARY} + ${ARGP_LIBRARIES} util) endif ()