From f2554e9081636f4c200a3955f8a9bff601306dff Mon Sep 17 00:00:00 2001 From: Abdessattar Sassi <457645+abdes@users.noreply.github.com> Date: Fri, 26 Aug 2022 20:48:48 +0400 Subject: [PATCH] chore: add information about original code and its license --- cryptopp/cryptoppConfig.cmake | 95 +++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 42 deletions(-) diff --git a/cryptopp/cryptoppConfig.cmake b/cryptopp/cryptoppConfig.cmake index d982ed9..5532c4b 100644 --- a/cryptopp/cryptoppConfig.cmake +++ b/cryptopp/cryptoppConfig.cmake @@ -1,57 +1,68 @@ +# ===-----------------------------------------------------------------------===# +# Distributed under the MIT License (https://opensource.org/licenses/MIT). +# SPDX-License-Identifier: MIT +# +# See details at: +# https://alexreinking.com/blog/building-a-dual-shared-and-static-library-with-cmake.html +# and full source at https://github.com/alexreinking/SharedStaticStarter +# ===-----------------------------------------------------------------------===# + cmake_minimum_required(VERSION 3.19) set(cryptopp_known_comps static shared) set(cryptopp_comp_static NO) set(cryptopp_comp_shared NO) -foreach (cryptopp_comp IN LISTS ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS) - if (cryptopp_comp IN_LIST cryptopp_known_comps) - set(cryptopp_comp_${cryptopp_comp} YES) - else () - set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE - "cryptopp does not recognize component `${cryptopp_comp}`.") - set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) - return() - endif () -endforeach () - -if (cryptopp_comp_static AND cryptopp_comp_shared) +foreach(cryptopp_comp IN LISTS ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS) + if(cryptopp_comp IN_LIST cryptopp_known_comps) + set(cryptopp_comp_${cryptopp_comp} YES) + else() set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE - "cryptopp `static` and `shared` components are mutually exclusive.") + "cryptopp does not recognize component `${cryptopp_comp}`.") set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) return() -endif () + endif() +endforeach() + +if(cryptopp_comp_static AND cryptopp_comp_shared) + set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "cryptopp `static` and `shared` components are mutually exclusive.") + set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) + return() +endif() -set(cryptopp_static_targets "${CMAKE_CURRENT_LIST_DIR}/cryptopp-static-targets.cmake") -set(cryptopp_shared_targets "${CMAKE_CURRENT_LIST_DIR}/cryptopp-shared-targets.cmake") +set(cryptopp_static_targets + "${CMAKE_CURRENT_LIST_DIR}/cryptopp-static-targets.cmake") +set(cryptopp_shared_targets + "${CMAKE_CURRENT_LIST_DIR}/cryptopp-shared-targets.cmake") macro(cryptopp_load_targets type) - if (NOT EXISTS "${cryptopp_${type}_targets}") - set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE - "cryptopp `${type}` libraries were requested but not found.") - set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) - return() - endif () - include("${cryptopp_${type}_targets}") + if(NOT EXISTS "${cryptopp_${type}_targets}") + set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE + "cryptopp `${type}` libraries were requested but not found.") + set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE) + return() + endif() + include("${cryptopp_${type}_targets}") endmacro() -if (cryptopp_comp_static) - cryptopp_load_targets(static) -elseif (cryptopp_comp_shared) - cryptopp_load_targets(shared) -elseif (DEFINED cryptopp_SHARED_LIBS AND cryptopp_SHARED_LIBS) +if(cryptopp_comp_static) + cryptopp_load_targets(static) +elseif(cryptopp_comp_shared) + cryptopp_load_targets(shared) +elseif(DEFINED cryptopp_SHARED_LIBS AND cryptopp_SHARED_LIBS) + cryptopp_load_targets(shared) +elseif(DEFINED cryptopp_SHARED_LIBS AND NOT cryptopp_SHARED_LIBS) + cryptopp_load_targets(static) +elseif(BUILD_SHARED_LIBS) + if(EXISTS "${cryptopp_shared_targets}") cryptopp_load_targets(shared) -elseif (DEFINED cryptopp_SHARED_LIBS AND NOT cryptopp_SHARED_LIBS) + else() cryptopp_load_targets(static) -elseif (BUILD_SHARED_LIBS) - if (EXISTS "${cryptopp_shared_targets}") - cryptopp_load_targets(shared) - else () - cryptopp_load_targets(static) - endif () -else () - if (EXISTS "${cryptopp_static_targets}") - cryptopp_load_targets(static) - else () - cryptopp_load_targets(shared) - endif () -endif () \ No newline at end of file + endif() +else() + if(EXISTS "${cryptopp_static_targets}") + cryptopp_load_targets(static) + else() + cryptopp_load_targets(shared) + endif() +endif()