1# This file was generated from BUILD using tools/make_cmakelists.py. 2 3cmake_minimum_required(VERSION 3.10...3.24) 4 5project(upb) 6set(CMAKE_C_STANDARD 99) 7 8# Prevent CMake from setting -rdynamic on Linux (!!). 9SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") 10SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") 11 12# Set default build type. 13if(NOT CMAKE_BUILD_TYPE) 14 message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.") 15 set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING 16 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." 17 FORCE) 18endif() 19 20# When using Ninja, compiler output won't be colorized without this. 21include(CheckCXXCompilerFlag) 22CHECK_CXX_COMPILER_FLAG(-fdiagnostics-color=always SUPPORTS_COLOR_ALWAYS) 23if(SUPPORTS_COLOR_ALWAYS) 24 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always") 25endif() 26 27# Implement ASAN/UBSAN options 28if(UPB_ENABLE_ASAN) 29 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") 30 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") 31 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") 32 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address") 33endif() 34 35if(UPB_ENABLE_UBSAN) 36 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined") 37 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") 38 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") 39 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address") 40endif() 41 42if(NOT TARGET utf8_range) 43 if(EXISTS ../../third_party/utf8_range) 44 # utf8_range is already installed 45 include_directories(../../third_party/utf8_range) 46 else() 47 include(FetchContent) 48 FetchContent_Declare( 49 utf8_range 50 GIT_REPOSITORY "https://github.com/protocolbuffers/utf8_range.git" 51 GIT_TAG "d863bc33e15cba6d873c878dcca9e6fe52b2f8cb" 52 ) 53 FetchContent_GetProperties(utf8_range) 54 if(NOT utf8_range_POPULATED) 55 FetchContent_Populate(utf8_range) 56 include_directories(${utf8_range_SOURCE_DIR}) 57 endif() 58 endif() 59endif() 60 61if(APPLE) 62 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup -flat_namespace") 63elseif(UNIX) 64 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id") 65endif() 66 67enable_testing() 68 69 70add_library(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE 71 72) 73target_include_directories(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE 74 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..> 75 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../cmake> 76 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> 77) 78target_link_libraries(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE 79 base 80 mem 81 message 82 mini_descriptor 83 mini_table 84 wire 85 /upb/message:internal) 86 87add_library(generated_cpp_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE 88 89) 90target_include_directories(generated_cpp_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE 91 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..> 92 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../cmake> 93 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> 94) 95 96 97