X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2FCMakeLists.txt;h=eefc2ad72031711cc2bf79987901041ebba2e35b;hb=99ddcc3f8b5549252fcf834e2a25aa39ba0b880e;hp=13ae93d6e240bfd90c6e75321ae2d81bf02c4309;hpb=612dd6a955e44d2c0fed1801fb8de585ca695c63;p=vpp.git diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 13ae93d6e24..eefc2ad7203 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,6 +17,29 @@ project(vpp C) include(CheckCCompilerFlag) +############################################################################## +# Highlight WARNING and ERROR messages +############################################################################## +function(message) + list(GET ARGV 0 type) + string(ASCII 27 esc) + set(red "${esc}[1;31m") + set(yellow "${esc}[1;33m") + set(reset "${esc}[m") + if(type STREQUAL FATAL_ERROR OR type STREQUAL SEND_ERROR) + list(REMOVE_AT ARGV 0) + _message(${type} "${red}${ARGV}${reset}") + elseif(type STREQUAL WARNING) + list(REMOVE_AT ARGV 0) + _message(STATUS "${yellow}${ARGV}${reset}") + elseif(type STREQUAL STATUS) + list(REMOVE_AT ARGV 0) + _message(STATUS "${ARGV}") + else() + _message(${ARGV}) + endif() +endfunction() + ############################################################################## # CPU optimizations and multiarch support ############################################################################## @@ -95,12 +118,23 @@ find_package(Threads REQUIRED) find_package(OpenSSL REQUIRED) include_directories(${OPENSSL_INCLUDE_DIR}) -add_definitions(-DHAVE_MEMFD_CREATE -DVPP_API_TEST_BUILTIN=1) +############################################################################## +# Check for memfd_create headers and libs +############################################################################## +check_c_source_compiles(" + #define _GNU_SOURCE + #include + int main() { return memfd_create (\"/dev/false\", 0); } +" HAVE_MEMFD_CREATE) + +if (HAVE_MEMFD_CREATE) + add_definitions(-DHAVE_MEMFD_CREATE) +endif() ############################################################################## # API ############################################################################## -function(vpp_generate_api_header file) +function(vpp_generate_api_c_header file) set (output_name ${CMAKE_CURRENT_BINARY_DIR}/${file}.h) get_filename_component(output_dir ${output_name} DIRECTORY) add_custom_command (OUTPUT ${output_name} @@ -108,15 +142,39 @@ function(vpp_generate_api_header file) COMMAND ${CMAKE_SOURCE_DIR}/tools/vppapigen/vppapigen ARGS --includedir ${CMAKE_SOURCE_DIR} --input ${CMAKE_CURRENT_SOURCE_DIR}/${file} --output ${output_name} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} - COMMENT "Generating API header ${file}.h" + COMMENT "Generating API header ${output_name}" + ) +endfunction() + +function(vpp_generate_api_json_header file dir) + set (output_name ${CMAKE_CURRENT_BINARY_DIR}/${file}.json) + get_filename_component(output_dir ${output_name} DIRECTORY) + add_custom_command (OUTPUT ${output_name} + COMMAND mkdir -p ${output_dir} + COMMAND ${CMAKE_SOURCE_DIR}/tools/vppapigen/vppapigen + ARGS --includedir ${CMAKE_SOURCE_DIR} --input ${CMAKE_CURRENT_SOURCE_DIR}/${file} JSON --output ${output_name} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} + COMMENT "Generating API header ${output_name}" ) + install(FILES ${output_name} DESTINATION share/vpp/api/${dir}/) +endfunction() + +############################################################################## +# generate the .h and .json files for a .api file +# @param file - the name of the .api +# @param dir - the install directory under ROOT/share/vpp/api to place the +# generated .json file +############################################################################## +function(vpp_generate_api_header file dir) + vpp_generate_api_c_header (${file}) + vpp_generate_api_json_header (${file} ${dir}) endfunction() function(vpp_add_api_files target) unset(header_files) foreach(file ${ARGN}) - vpp_generate_api_header (${file}) - list (APPEND header_files ${file}.h) + vpp_generate_api_header (${file} core) + list (APPEND header_files ${file}.h ${file}.json) endforeach() add_custom_target(${target} DEPENDS ${header_files}) endfunction() @@ -138,7 +196,7 @@ endfunction() ############################################################################## # subdirs ############################################################################## -foreach (DIR vppinfra svm vlib vlibmemory vnet vpp vcl plugins) +foreach (DIR vppinfra svm vlib vlibmemory vnet vpp vpp-api vat vcl plugins) add_subdirectory(${DIR}) endforeach ()