aboutsummaryrefslogtreecommitdiffstats
path: root/src/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmake')
-rw-r--r--src/cmake/CMakeLists.txt26
-rw-r--r--src/cmake/VPPConfig.cmake38
-rw-r--r--src/cmake/api.cmake10
-rw-r--r--src/cmake/plugin.cmake17
4 files changed, 83 insertions, 8 deletions
diff --git a/src/cmake/CMakeLists.txt b/src/cmake/CMakeLists.txt
new file mode 100644
index 00000000000..7eb1790f2e8
--- /dev/null
+++ b/src/cmake/CMakeLists.txt
@@ -0,0 +1,26 @@
+# Copyright (c) 2018 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+install(
+ FILES
+ api.cmake
+ cpu.cmake
+ library.cmake
+ plugin.cmake
+ VPPConfig.cmake
+
+ DESTINATION
+ lib/cmake/vpp
+
+ COMPONENT vpp-dev
+)
diff --git a/src/cmake/VPPConfig.cmake b/src/cmake/VPPConfig.cmake
new file mode 100644
index 00000000000..767fe34c189
--- /dev/null
+++ b/src/cmake/VPPConfig.cmake
@@ -0,0 +1,38 @@
+# Copyright (c) 2018 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+get_filename_component(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
+
+find_path(VPP_INCLUDE_DIR PATH_SUFFIXES NAMES vppinfra/clib.h)
+find_program(VPP_APIGEN vppapigen)
+
+if(VPP_INCLUDE_DIR AND VPP_APIGEN)
+ include_directories (${VPP_INCLUDE_DIR})
+else()
+ message(FATAL_ERROR "VPP headers, libraries and/or tools not found")
+endif()
+
+set(VPP_EXTERNAL_PROJECT 1)
+
+include(CheckCCompilerFlag)
+
+check_c_compiler_flag("-Wno-address-of-packed-member" compiler_flag_no_address_of_packed_member)
+if (compiler_flag_no_address_of_packed_member)
+ add_definitions(-Wno-address-of-packed-member)
+endif()
+
+include(CheckCCompilerFlag)
+include(${CMAKE_CURRENT_LIST_DIR}/cpu.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/api.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/library.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/plugin.cmake)
diff --git a/src/cmake/api.cmake b/src/cmake/api.cmake
index d799c54a0a6..415eb5e8c0c 100644
--- a/src/cmake/api.cmake
+++ b/src/cmake/api.cmake
@@ -17,9 +17,12 @@
function(vpp_generate_api_c_header file)
set (output_name ${CMAKE_CURRENT_BINARY_DIR}/${file}.h)
get_filename_component(output_dir ${output_name} DIRECTORY)
+ if(NOT VPP_APIGEN)
+ set(VPP_APIGEN ${CMAKE_SOURCE_DIR}/tools/vppapigen/vppapigen)
+ endif()
add_custom_command (OUTPUT ${output_name}
COMMAND mkdir -p ${output_dir}
- COMMAND ${CMAKE_SOURCE_DIR}/tools/vppapigen/vppapigen
+ COMMAND ${VPP_APIGEN}
ARGS --includedir ${CMAKE_SOURCE_DIR} --input ${CMAKE_CURRENT_SOURCE_DIR}/${file} --output ${output_name}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
COMMENT "Generating API header ${output_name}"
@@ -29,9 +32,12 @@ endfunction()
function(vpp_generate_api_json_header file dir component)
set (output_name ${CMAKE_CURRENT_BINARY_DIR}/${file}.json)
get_filename_component(output_dir ${output_name} DIRECTORY)
+ if(NOT VPP_APIGEN)
+ set(VPP_APIGEN ${CMAKE_SOURCE_DIR}/tools/vppapigen/vppapigen)
+ endif()
add_custom_command (OUTPUT ${output_name}
COMMAND mkdir -p ${output_dir}
- COMMAND ${CMAKE_SOURCE_DIR}/tools/vppapigen/vppapigen
+ COMMAND ${VPP_APIGEN}
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}"
diff --git a/src/cmake/plugin.cmake b/src/cmake/plugin.cmake
index 39c940daed4..f68c955f64f 100644
--- a/src/cmake/plugin.cmake
+++ b/src/cmake/plugin.cmake
@@ -19,7 +19,7 @@ macro(add_vpp_plugin name)
${ARGN}
)
set(plugin_name ${name}_plugin)
- set(api_headers)
+ set(api_includes)
if(NOT PLUGIN_COMPONENT)
set(PLUGIN_COMPONENT vpp-plugin-misc)
endif()
@@ -27,7 +27,7 @@ macro(add_vpp_plugin name)
foreach(f ${PLUGIN_API_FILES})
get_filename_component(dir ${f} DIRECTORY)
vpp_generate_api_header(${f} plugins ${PLUGIN_COMPONENT})
- list(APPEND api_headers ${f}.h ${f}.json)
+ list(APPEND api_includes ${f}.h ${f}.json)
set_property(GLOBAL APPEND PROPERTY VPP_API_FILES ${rpath}/${f})
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${f}.h
@@ -35,9 +35,11 @@ macro(add_vpp_plugin name)
COMPONENT vpp-dev
)
endforeach()
- add_library(${plugin_name} SHARED ${PLUGIN_SOURCES} ${api_headers})
+ add_library(${plugin_name} SHARED ${PLUGIN_SOURCES} ${api_includes})
target_compile_options(${plugin_name} PRIVATE -Wall)
- add_dependencies(${plugin_name} vpp_version_h api_headers)
+ if(NOT VPP_EXTERNAL_PROJECT)
+ add_dependencies(${plugin_name} vpp_version_h api_headers)
+ endif()
set_target_properties(${plugin_name} PROPERTIES
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/vpp_plugins)
@@ -62,8 +64,11 @@ macro(add_vpp_plugin name)
endif()
if(PLUGIN_API_TEST_SOURCES)
set(test_plugin_name ${name}_test_plugin)
- add_library(${test_plugin_name} SHARED ${PLUGIN_API_TEST_SOURCES} ${api_headers})
- add_dependencies(${test_plugin_name} api_headers)
+ add_library(${test_plugin_name} SHARED ${PLUGIN_API_TEST_SOURCES}
+ ${api_includes})
+ if(NOT VPP_EXTERNAL_PROJECT)
+ add_dependencies(${test_plugin_name} api_headers)
+ endif()
set_target_properties(${test_plugin_name} PROPERTIES
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/vpp_api_test_plugins)