From 69dbcba069db62393f2aa2868662a7fd2073d31b Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 28 Dec 2021 11:45:32 +0000 Subject: Allow specifying multiple dependency libraries like foo|bar. --- cmake/Anope.cmake | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'cmake') diff --git a/cmake/Anope.cmake b/cmake/Anope.cmake index 44b4ea3ba..488d0f4f1 100644 --- a/cmake/Anope.cmake +++ b/cmake/Anope.cmake @@ -445,12 +445,18 @@ macro(calculate_libraries SRC SRC_LDFLAGS EXTRA_DEPENDS) string(REGEX REPLACE "," ";" REQUIRED_LIBRARY ${REQUIRED_LIBRARY}) # Iterate through the libraries given foreach(LIBRARY ${REQUIRED_LIBRARY}) + # If the library has multiple names extract the alternate. + unset(LIBRARY_ALT) + if (${LIBRARY} MATCHES "^.+\\|.+$") + string(REGEX REPLACE ".+\\|(.*)" "\\1" LIBRARY_ALT ${LIBRARY}) + string(REGEX REPLACE "(.+)\\|.*" "\\1" LIBRARY ${LIBRARY}) + endif(${LIBRARY} MATCHES "^.+\\|.+$") # Locate the library to see if it exists if(DEFAULT_LIBRARY_DIRS OR WSDK_PATH OR DEFINED $ENV{VCINSTALLDIR}) - find_library(FOUND_${LIBRARY}_LIBRARY NAMES ${LIBRARY} PATHS ${DEFAULT_LIBRARY_DIRS} ${WSDK_PATH}/lib $ENV{VCINSTALLDIR}/lib ${EXTRA_INCLUDE} ${EXTRA_LIBS}) + find_library(FOUND_${LIBRARY}_LIBRARY NAMES ${LIBRARY} ${LIBRARY_ALT} PATHS ${DEFAULT_LIBRARY_DIRS} ${WSDK_PATH}/lib $ENV{VCINSTALLDIR}/lib ${EXTRA_INCLUDE} ${EXTRA_LIBS}) else(DEFAULT_LIBRARY_DIRS OR WSDK_PATH OR DEFINED $ENV{VCINSTALLDIR}) - find_library(FOUND_${LIBRARY}_LIBRARY NAMES ${LIBRARY} PATHS ${EXTRA_INCLUDE} ${EXTRA_LIBS} NO_DEFAULT_PATH) - find_library(FOUND_${LIBRARY}_LIBRARY NAMES ${LIBRARY} PATHS ${EXTRA_INCLUDE} ${EXTRA_LIBS}) + find_library(FOUND_${LIBRARY}_LIBRARY NAMES ${LIBRARY} ${LIBRARY_ALT} PATHS ${EXTRA_INCLUDE} ${EXTRA_LIBS} NO_DEFAULT_PATH) + find_library(FOUND_${LIBRARY}_LIBRARY NAMES ${LIBRARY} ${LIBRARY_ALT} PATHS ${EXTRA_INCLUDE} ${EXTRA_LIBS}) endif(DEFAULT_LIBRARY_DIRS OR WSDK_PATH OR DEFINED $ENV{VCINSTALLDIR}) # If the library was found, we will add it to the linker flags if(FOUND_${LIBRARY}_LIBRARY) -- cgit From 2c18601d8f3a3b5ab8ddb3ecdd90a2c69c7fbc88 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 28 Dec 2021 21:18:22 +0000 Subject: Fix linking against libraries by their alternate name. --- cmake/Anope.cmake | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'cmake') diff --git a/cmake/Anope.cmake b/cmake/Anope.cmake index 488d0f4f1..1b924bc5d 100644 --- a/cmake/Anope.cmake +++ b/cmake/Anope.cmake @@ -460,15 +460,17 @@ macro(calculate_libraries SRC SRC_LDFLAGS EXTRA_DEPENDS) endif(DEFAULT_LIBRARY_DIRS OR WSDK_PATH OR DEFINED $ENV{VCINSTALLDIR}) # If the library was found, we will add it to the linker flags if(FOUND_${LIBRARY}_LIBRARY) - # Get the path only of the library, to add it to linker flags - get_filename_component(LIBRARY_PATH ${FOUND_${LIBRARY}_LIBRARY} PATH) if(MSVC) # For Visual Studio, instead of editing the linker flags, we'll add the library to a separate list of extra dependencies append_to_list(EXTRA_DEPENDENCIES "${FOUND_${LIBRARY}_LIBRARY}") else(MSVC) - # For all others, add the library paths and libraries + # Get the path only of the library, to add it to library paths. + get_filename_component(LIBRARY_PATH ${FOUND_${LIBRARY}_LIBRARY} PATH) append_to_list(LIBRARY_PATHS "${LIBRARY_PATH}") - append_to_list(LIBRARIES "${LIBRARY}") + # Extract the library short name, add it to the library path + get_filename_component(LIBRARY_NAME ${FOUND_${LIBRARY}_LIBRARY} NAME_WE) + string(REGEX REPLACE "^lib" "" LIBRARY_NAME ${LIBRARY_NAME}) + append_to_list(LIBRARIES ${LIBRARY_NAME}) endif(MSVC) else(FOUND_${LIBRARY}_LIBRARY) # In the case of the library not being found, we fatally error so CMake stops trying to generate -- cgit