Skip to content

Commit

Permalink
Add cmake/CMakeLists.txt for compatibility (#9596)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arfrever authored and acozzette committed Mar 9, 2022
1 parent 14cab5b commit def70d7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ endif()
# Project
project(protobuf C CXX)

if(protobuf_DEPRECATED_CMAKE_SUBDIRECTORY_USAGE)
if(CMAKE_PROJECT_NAME STREQUAL "protobuf")
get_filename_component(CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR} DIRECTORY)
endif()
get_filename_component(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
get_filename_component(PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR} DIRECTORY)
get_filename_component(protobuf_SOURCE_DIR ${protobuf_SOURCE_DIR} DIRECTORY)
endif()

# Add c++11 flags
if (CYGWIN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
Expand Down
9 changes: 9 additions & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.5)

message(WARNING "Calling of cmake with source directory set to \"cmake\" subdirectory of Protocol Buffers project is deprecated. Top-level directory of Protocol Buffers project should be used instead.")

project(protobuf C CXX)

set(protobuf_DEPRECATED_CMAKE_SUBDIRECTORY_USAGE TRUE)

include(../CMakeLists.txt)

0 comments on commit def70d7

Please sign in to comment.