Commit abc21143 authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

fbcode_builder: update ThriftCppLibrary to use fb_cmake_parse_args()

Summary:
Change ThriftCppLibrary to use `fb_cmake_parse_args()`

This code doesn't really care much about handling empty arguments, so we could
use the standard `cmake_parse_arguments()` function here instead of
`fb_cmake_parse_args()`.  However, it is slightly more convenient that
`fb_cmake_parse_args()` automatically errors out on unhandled arguments, so
that we don't have to check for this ourselves.

Reviewed By: wez

Differential Revision: D16738445

fbshipit-source-id: 67b9761f2ceaf7665bd336290bb44af32fec6f4a
parent 4c502a7f
main v2022.02.14.00 v2022.02.07.00 v2022.01.31.00 v2022.01.24.00 v2022.01.17.00 v2022.01.10.00 v2022.01.03.00 v2021.12.27.00 v2021.12.20.00 v2021.12.13.00 v2021.12.06.00 v2021.11.29.00 v2021.11.15.00 v2021.11.08.00 v2021.11.01.00 v2021.10.25.00 v2021.10.18.00 v2021.10.11.00 v2021.10.04.00 v2021.09.27.00 v2021.09.20.00 v2021.09.13.00 v2021.09.06.00 v2021.08.30.00 v2021.08.23.00 v2021.08.02.00 v2021.07.22.00 v2021.07.20.01 v2021.07.20.00 v2021.06.28.00 v2021.06.14.00 v2021.06.07.00 v2021.05.31.00 v2021.05.24.00 v2021.05.17.00 v2021.05.10.00 v2021.05.03.00 v2021.04.26.00 v2021.04.19.00 v2021.04.12.00 v2021.04.05.00 v2021.03.29.00 v2021.03.22.00 v2021.03.15.00 v2021.03.08.00 v2021.03.01.00 v2021.02.22.00 v2021.02.15.00 v2021.02.08.00 v2021.02.01.00 v2021.01.25.00 v2021.01.18.01 v2021.01.18.00 v2021.01.11.00 v2021.01.04.00 v2020.12.28.00 v2020.12.21.00 v2020.12.14.00 v2020.12.07.00 v2020.11.30.00 v2020.11.23.00 v2020.11.16.00 v2020.11.09.00 v2020.11.02.00 v2020.10.26.00 v2020.10.19.00 v2020.10.12.00 v2020.10.05.00 v2020.09.28.00 v2020.09.21.00 v2020.09.14.00 v2020.09.07.00 v2020.08.31.00 v2020.08.24.00 v2020.08.17.00 v2020.08.10.00 v2020.08.03.00 v2020.07.27.00 v2020.07.20.00 v2020.07.13.00 v2020.07.06.00 v2020.06.29.00 v2020.06.15.00 v2020.06.08.00 v2020.06.01.00 v2020.05.25.00 v2020.05.18.00 v2020.05.11.00 v2020.05.04.00 v2020.04.27.00 v2020.04.20.00 v2020.04.13.00 v2020.04.06.00 v2020.03.30.00 v2020.03.23.00 v2020.03.16.00 v2020.03.09.00 v2020.03.02.00 v2020.02.24.00 v2020.02.17.00 v2020.02.10.00 v2020.02.03.00 v2020.01.27.00 v2020.01.20.00 v2020.01.13.00 v2020.01.06.00 v2019.12.30.00 v2019.12.23.00 v2019.12.16.00 v2019.12.09.00 v2019.12.06.00 v2019.12.02.00 v2019.11.11.00 v2019.11.04.00 v2019.10.28.00 v2019.10.21.00 v2019.10.14.00 v2019.10.07.00 v2019.09.30.00 v2019.09.23.00 v2019.09.16.00 v2019.09.09.00 v2019.09.02.00 v2019.08.26.00
No related merge requests found
# Copyright (c) Facebook, Inc. and its affiliates.
# NOTE: If you change this file, fbcode/fboss/github/ThriftCppLibrary.cmake also
# needs to be changed. TODO: this should be handled via shipit.
include(FBCMakeParseArgs)
function(add_thrift_cpp2_library LIB_NAME THRIFT_FILE)
# Parse the arguments
set(SERVICES)
set(DEPENDS)
set(GEN_ARGS)
set(mode "UNSET")
foreach(arg IN LISTS ARGN)
if("${arg}" STREQUAL "SERVICES")
set(mode "SERVICES")
elseif("${arg}" STREQUAL "DEPENDS")
set(mode "DEPENDS")
elseif("${arg}" STREQUAL "OPTIONS")
set(mode "OPTIONS")
else()
if("${mode}" STREQUAL "SERVICES")
list(APPEND SERVICES "${arg}")
elseif("${mode}" STREQUAL "DEPENDS")
list(APPEND DEPENDS "${arg}")
elseif("${mode}" STREQUAL "OPTIONS")
list(APPEND GEN_ARGS "${arg}")
else()
message(
FATAL_ERROR
"expected SERVICES, DEPENDS, or OPTIONS argument, found ${arg}"
)
endif()
endif()
endforeach()
set(multi_value_args SERVICES DEPENDS OPTIONS)
fb_cmake_parse_args(ARG "" "" "${multi_value_args}" "${ARGN}")
get_filename_component(base ${THRIFT_FILE} NAME_WE)
get_filename_component(
......@@ -42,11 +21,11 @@ function(add_thrift_cpp2_library LIB_NAME THRIFT_FILE)
get_filename_component(include_prefix ${include_prefix} DIRECTORY)
if (NOT "${include_prefix}" STREQUAL "")
list(APPEND GEN_ARGS "include_prefix=${include_prefix}")
list(APPEND ARG_OPTIONS "include_prefix=${include_prefix}")
endif()
# CMake 3.12 is finally getting a list(JOIN) function, but until then
# treating the list as a string and replacing the semicolons is good enough.
string(REPLACE ";" "," GEN_ARG_STR "${GEN_ARGS}")
string(REPLACE ";" "," GEN_ARG_STR "${ARG_OPTIONS}")
# Compute the list of generated files
list(APPEND generated_headers
......@@ -61,7 +40,7 @@ function(add_thrift_cpp2_library LIB_NAME THRIFT_FILE)
${output_dir}/gen-cpp2/${base}_data.cpp
${output_dir}/gen-cpp2/${base}_types.cpp
)
foreach(service IN LISTS SERVICES)
foreach(service IN LISTS ARG_SERVICES)
list(APPEND generated_headers
${output_dir}/gen-cpp2/${service}.h
${output_dir}/gen-cpp2/${service}.tcc
......@@ -77,7 +56,7 @@ function(add_thrift_cpp2_library LIB_NAME THRIFT_FILE)
endforeach()
list(APPEND thrift_include_options -I ${CMAKE_SOURCE_DIR})
foreach(depends IN LISTS DEPENDS)
foreach(depends IN LISTS ARG_DEPENDS)
get_property(thrift_include_directory
TARGET ${depends}
PROPERTY THRIFT_INCLUDE_DIRECTORY)
......@@ -114,7 +93,7 @@ function(add_thrift_cpp2_library LIB_NAME THRIFT_FILE)
MAIN_DEPENDENCY
${THRIFT_FILE}
DEPENDS
${DEPENDS}
${ARG_DEPENDS}
)
# Now emit the library rule to compile the sources
......@@ -139,7 +118,7 @@ function(add_thrift_cpp2_library LIB_NAME THRIFT_FILE)
target_link_libraries(
${LIB_NAME}
PUBLIC
${DEPENDS}
${ARG_DEPENDS}
FBThrift::thriftcpp2
Folly::folly
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment