diff --git a/cmake/modules/Findre2.cmake b/cmake/modules/Findre2.cmake index 35d0382b8871..d4af18f13e34 100644 --- a/cmake/modules/Findre2.cmake +++ b/cmake/modules/Findre2.cmake @@ -17,3 +17,7 @@ _userver_module_find_library( ) _userver_module_end() + +if(NOT TARGET re2::re2) + add_library(re2::re2 ALIAS re2) +endif() diff --git a/universal/CMakeLists.txt b/universal/CMakeLists.txt index e1f703f5f153..ef2e305f91cc 100644 --- a/universal/CMakeLists.txt +++ b/universal/CMakeLists.txt @@ -187,11 +187,10 @@ option(USERVER_FEATURE_RE2 "Build userver with re2 support" OFF) if(USERVER_FEATURE_RE2) if(USERVER_CONAN) find_package(re2 REQUIRED CONFIG) - target_link_libraries(${PROJECT_NAME} PRIVATE re2::re2) else() find_package(re2 REQUIRED) - target_link_libraries(${PROJECT_NAME} PRIVATE re2) endif() + target_link_libraries(${PROJECT_NAME} PRIVATE re2::re2) else() target_compile_definitions(${PROJECT_NAME} PUBLIC USERVER_NO_RE2_SUPPORT=1) endif()