Skip to content

Commit cb009b2

Browse files
authored
Merge pull request #12301 from mkruskal-google/cmake-fix
Only include utf8_range if it hasn't been included already
2 parents 777df3d + c4005f2 commit cb009b2

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

cmake/libprotobuf-lite.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,4 @@ set_target_properties(libprotobuf-lite PROPERTIES
4040
)
4141
add_library(protobuf::libprotobuf-lite ALIAS libprotobuf-lite)
4242

43-
target_include_directories(libprotobuf-lite PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range)
4443
target_link_libraries(libprotobuf-lite PRIVATE utf8_validity)

cmake/libprotobuf.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,4 @@ set_target_properties(libprotobuf PROPERTIES
4343
)
4444
add_library(protobuf::libprotobuf ALIAS libprotobuf)
4545

46-
target_include_directories(libprotobuf PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range)
4746
target_link_libraries(libprotobuf PRIVATE utf8_validity)

cmake/utf8_range.cmake

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
set(utf8_range_ENABLE_TESTS OFF CACHE BOOL "Disable utf8_range tests")
1+
if (NOT TARGET utf8_range)
2+
set(utf8_range_ENABLE_TESTS OFF CACHE BOOL "Disable utf8_range tests")
23

3-
if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/utf8_range/CMakeLists.txt")
4-
message(FATAL_ERROR
5-
"Cannot find third_party/utf8_range directory that's needed for "
6-
"the protobuf runtime.\n")
7-
endif()
4+
if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/utf8_range/CMakeLists.txt")
5+
message(FATAL_ERROR
6+
"Cannot find third_party/utf8_range directory that's needed for "
7+
"the protobuf runtime.\n")
8+
endif()
89

9-
set(utf8_range_ENABLE_INSTALL ${protobuf_INSTALL} CACHE BOOL "Set install")
10-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range third_party/utf8_range)
10+
set(utf8_range_ENABLE_INSTALL ${protobuf_INSTALL} CACHE BOOL "Set install")
11+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range third_party/utf8_range)
12+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range)
13+
endif ()
1114

1215
set(_protobuf_FIND_UTF8_RANGE "if(NOT TARGET utf8_range)\n find_package(utf8_range CONFIG)\nendif()")

0 commit comments

Comments
 (0)