From 29e40f5f0f84ca854cb10ce4d709925c7faa8f18 Mon Sep 17 00:00:00 2001 From: Christoph Erhardt Date: Thu, 12 Dec 2024 23:53:58 +0100 Subject: [PATCH] Extract CMake helper function `add_library_and_alias()` --- googletest/cmake/internal_utils.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index 7ca256a7..ab47f872 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -157,13 +157,17 @@ macro(config_compiler_and_linker) set(cxx_strict "${cxx_default} ${cxx_strict_flags}") endmacro() +function(add_library_and_alias name type) + add_library(${name} ${type} ${ARGN}) + add_library(${cmake_package_name}::${name} ALIAS ${name}) +endfunction() + # Defines the gtest & gtest_main libraries. User tests should link # with one of them. function(cxx_library_with_type name type cxx_flags) # type can be either STATIC or SHARED to denote a static or shared library. # ARGN refers to additional arguments after 'cxx_flags'. - add_library(${name} ${type} ${ARGN}) - add_library(${cmake_package_name}::${name} ALIAS ${name}) + add_library_and_alias(${name} ${type} ${ARGN}) set_target_properties(${name} PROPERTIES COMPILE_FLAGS "${cxx_flags}")