From bac3da61644515f05663789b122554dc77549286 Mon Sep 17 00:00:00 2001 From: Luca Muscariello Date: Thu, 17 Jan 2019 13:47:57 +0100 Subject: This is the first commit of the hicn project Change-Id: I6f2544ad9b9f8891c88cc4bcce3cf19bd3cc863f Signed-off-by: Luca Muscariello --- cmake/Modules/BuildMacros.cmake | 146 ++++++++++++++++++++++++++++++++++ cmake/Modules/FindAsio.cmake | 41 ++++++++++ cmake/Modules/FindGFlags.cmake | 36 +++++++++ cmake/Modules/FindGlog.cmake | 36 +++++++++ cmake/Modules/FindHicnBinaryApi.cmake | 31 ++++++++ cmake/Modules/FindLibEvent.cmake | 55 +++++++++++++ cmake/Modules/FindLibhicn.cmake | 49 ++++++++++++ cmake/Modules/FindLibmemif.cmake | 47 +++++++++++ cmake/Modules/FindLibparc.cmake | 50 ++++++++++++ cmake/Modules/FindLibtransport.cmake | 48 +++++++++++ cmake/Modules/FindLongBow.cmake | 55 +++++++++++++ cmake/Modules/FindUncrustify.cmake | 21 +++++ cmake/Modules/FindVpp.cmake | 67 ++++++++++++++++ cmake/Modules/IosMacros.cmake | 24 ++++++ cmake/Modules/Packager.cmake | 105 ++++++++++++++++++++++++ cmake/Modules/detectCacheSize.cmake | 21 +++++ 16 files changed, 832 insertions(+) create mode 100755 cmake/Modules/BuildMacros.cmake create mode 100755 cmake/Modules/FindAsio.cmake create mode 100755 cmake/Modules/FindGFlags.cmake create mode 100755 cmake/Modules/FindGlog.cmake create mode 100755 cmake/Modules/FindHicnBinaryApi.cmake create mode 100755 cmake/Modules/FindLibEvent.cmake create mode 100755 cmake/Modules/FindLibhicn.cmake create mode 100755 cmake/Modules/FindLibmemif.cmake create mode 100755 cmake/Modules/FindLibparc.cmake create mode 100755 cmake/Modules/FindLibtransport.cmake create mode 100755 cmake/Modules/FindLongBow.cmake create mode 100755 cmake/Modules/FindUncrustify.cmake create mode 100755 cmake/Modules/FindVpp.cmake create mode 100755 cmake/Modules/IosMacros.cmake create mode 100755 cmake/Modules/Packager.cmake create mode 100755 cmake/Modules/detectCacheSize.cmake (limited to 'cmake') diff --git a/cmake/Modules/BuildMacros.cmake b/cmake/Modules/BuildMacros.cmake new file mode 100755 index 000000000..14a82fab7 --- /dev/null +++ b/cmake/Modules/BuildMacros.cmake @@ -0,0 +1,146 @@ +# Copyright (c) 2017-2019 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. + +############################## +# Utils for building libraries and executables +# + +macro(build_executable exec) + cmake_parse_arguments(ARG + "NO_INSTALL" + "COMPONENT" + "SOURCES;LINK_LIBRARIES;DEPENDS;DEFINITIONS" + ${ARGN} + ) + + add_executable(${exec} ${ARG_SOURCES}) + if(ARG_LINK_LIBRARIES) + target_link_libraries(${exec} ${ARG_LINK_LIBRARIES}) + endif() + + if(ARG_DEPENDS) + add_dependencies(${exec} ${ARG_DEPENDS}) + endif() + + if(ARG_DEFINITIONS) + target_compile_definitions(${exec} PRIVATE ${ARG_DEFINITIONS}) + endif() + + if(NOT ARG_NO_INSTALL) + install(TARGETS ${exec} DESTINATION bin COMPONENT ${ARG_COMPONENT}) + endif() +endmacro() + +macro(build_library lib) + cmake_parse_arguments(ARG + "SHARED;STATIC" + "COMPONENT" + "SOURCES;LINK_LIBRARIES;INSTALL_HEADERS;DEPENDS;INCLUDE_DIRS;DEFINITIONS;INSTALL_ROOT_DIR" + ${ARGN} + ) + + if (ARG_SHARED) + list(APPEND TARGET_LIBS + ${lib}.shared + ) + add_library(${lib}.shared SHARED ${ARG_SOURCES}) + endif() + + if(ARG_STATIC) + list(APPEND TARGET_LIBS + ${lib} + ) + add_library(${lib} STATIC ${ARG_SOURCES}) + endif() + + foreach(library ${TARGET_LIBS}) + target_compile_options(${library} PRIVATE -Wall) + + if(HICN_VERSION) + set_target_properties(${library} + PROPERTIES + SOVERSION ${HICN_VERSION} + ) + endif() + + set_target_properties(${library} + PROPERTIES + OUTPUT_NAME ${lib} + ) + + # library deps + if(ARG_LINK_LIBRARIES) + target_link_libraries(${library} ${ARG_LINK_LIBRARIES}) + endif() + + if(ARG_DEFINITIONS) + target_compile_definitions(${library} PRIVATE ${ARG_DEFINITIONS}) + endif() + + if(ARG_INCLUDE_DIRS) + target_include_directories(${library} BEFORE PUBLIC + ${ARG_INCLUDE_DIRS} + ${PROJECT_BINARY_DIR} + ) + endif() + + # install .so + if(NOT ARG_COMPONENT) + set(ARG_COMPONENT hicn) + endif() + install( + TARGETS ${library} + DESTINATION lib + COMPONENT ${ARG_COMPONENT} + ) + + if(ARG_DEPENDS) + add_dependencies(${library} ${ARG_DEPENDS}) + endif() + endforeach() + + # install headers + if(ARG_INSTALL_HEADERS) + + if (NOT ARG_INSTALL_ROOT_DIR) + set(ARG_INSTALL_ROOT_DIR "hicn") + endif() + + foreach(file ${ARG_INSTALL_HEADERS}) + get_filename_component(_dir ${file} DIRECTORY) + get_filename_component(dir ${_dir} NAME) + if (${dir} STREQUAL src) + set(dir "") + endif() + install( + FILES ${file} + DESTINATION include/${ARG_INSTALL_ROOT_DIR}/${dir} + COMPONENT ${ARG_COMPONENT}-dev + ) + endforeach() + endif() +endmacro() + +add_custom_target(${PROJECT_NAME}_cleanup_profiling_data + "find" "." "-name" "*.gcda" "-delete" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Cleanup previous profiling data." +) + +macro(AddTest testFile) + add_executable(${ARGV0} ${ARGV0}.cc) + target_link_libraries(${ARGV0} ${TARGET_TRANSPORT_STATIC} ${GTEST_LIBRARIES}) + add_test(${ARGV0} ${ARGV0}) + set_target_properties(${ARGV0} PROPERTIES FOLDER Test) + add_dependencies(${ARGV0} ${PROJECT_NAME}_cleanup_profiling_data) +endmacro(AddTest) \ No newline at end of file diff --git a/cmake/Modules/FindAsio.cmake b/cmake/Modules/FindAsio.cmake new file mode 100755 index 000000000..73888e519 --- /dev/null +++ b/cmake/Modules/FindAsio.cmake @@ -0,0 +1,41 @@ +# Copyright (c) 2017-2019 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. + +######################################## +# +# Find the hcin libraries and includes +# This module sets: +# ASIO_FOUND: True if asio was found +# ASIO_INCLUDE_DIR: The asio include dir +# + +set(ASIO_SEARCH_PATH_LIST + ${ASIO_HOME} + $ENV{ASIO_HOME} + /usr/local + /opt + /usr +) + +find_path(ASIO_INCLUDE_DIR asio.hpp + HINTS ${ASIO_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the asio includes" +) + +set(ASIO_INCLUDE_DIRS ${ASIO_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Asio + REQUIRED_VARS ASIO_INCLUDE_DIRS +) \ No newline at end of file diff --git a/cmake/Modules/FindGFlags.cmake b/cmake/Modules/FindGFlags.cmake new file mode 100755 index 000000000..804bfebdc --- /dev/null +++ b/cmake/Modules/FindGFlags.cmake @@ -0,0 +1,36 @@ +# Copyright (c) 2017-2019 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. + +# +# Find libgflags +# +# LIBGFLAGS_INCLUDE_DIR - where to find gflags/gflags.h, etc. +# LIBGFLAGS_LIBRARY - List of libraries when using libgflags. +# LIBGFLAGS_FOUND - True if libgflags found. + + +IF (LIBGFLAGS_INCLUDE_DIR) + # Already in cache, be silent + SET(LIBGFLAGS_FIND_QUIETLY TRUE) +ENDIF () + +FIND_PATH(LIBGFLAGS_INCLUDE_DIR gflags/gflags.h) + +FIND_LIBRARY(LIBGFLAGS_LIBRARY NAMES gflags gflags_static) + +# handle the QUIETLY and REQUIRED arguments and set LIBGFLAGS_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBGFLAGS DEFAULT_MSG LIBGFLAGS_LIBRARY LIBGFLAGS_INCLUDE_DIR) + +MARK_AS_ADVANCED(LIBGFLAGS_LIBRARY LIBGFLAGS_INCLUDE_DIR) \ No newline at end of file diff --git a/cmake/Modules/FindGlog.cmake b/cmake/Modules/FindGlog.cmake new file mode 100755 index 000000000..10023a187 --- /dev/null +++ b/cmake/Modules/FindGlog.cmake @@ -0,0 +1,36 @@ +# Copyright (c) 2017-2019 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. + +# +# Find libglog +# +# LIBGLOG_INCLUDE_DIR - where to find glog/logging.h, etc. +# LIBGLOG_LIBRARY - List of libraries when using libglog. +# LIBGLOG_FOUND - True if libglog found. + + +IF (LIBGLOG_INCLUDE_DIR) + # Already in cache, be silent + SET(LIBGLOG_FIND_QUIETLY TRUE) +ENDIF () + +FIND_PATH(LIBGLOG_INCLUDE_DIR glog/logging.h) + +FIND_LIBRARY(LIBGLOG_LIBRARY glog) + +# handle the QUIETLY and REQUIRED arguments and set LIBGLOG_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBGLOG DEFAULT_MSG LIBGLOG_LIBRARY LIBGLOG_INCLUDE_DIR) + +MARK_AS_ADVANCED(LIBGLOG_LIBRARY LIBGLOG_INCLUDE_DIR) \ No newline at end of file diff --git a/cmake/Modules/FindHicnBinaryApi.cmake b/cmake/Modules/FindHicnBinaryApi.cmake new file mode 100755 index 000000000..86a96ea19 --- /dev/null +++ b/cmake/Modules/FindHicnBinaryApi.cmake @@ -0,0 +1,31 @@ +# Copyright (c) 2017-2019 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. + +set(HICN_BINARY_API_SEARCH_PATH_LIST + ${HICN_BINARY_API_HOME} + $ENV{HICN_BINARY_API_HOME} + /usr/local + /opt + /usr +) + +find_path(HICN_BINARY_API_INCLUDE_DIR vpp_plugins/hicn/hicn_api.h + HINTS ${VPP_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the VPP includes" +) + +set(HICN_BINARY_API_INCLUDE_DIRS ${VPP_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(HicnBinaryApi DEFAULT_MSG VPP_LIBRARIES VPP_INCLUDE_DIRS) \ No newline at end of file diff --git a/cmake/Modules/FindLibEvent.cmake b/cmake/Modules/FindLibEvent.cmake new file mode 100755 index 000000000..5e4113716 --- /dev/null +++ b/cmake/Modules/FindLibEvent.cmake @@ -0,0 +1,55 @@ +# Copyright (c) 2017-2019 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. + +######################################## +# +# Find the LibEvent libraries and includes +# This module sets: +# LIBEVENT_FOUND: True if LibEvent was found +# LIBEVENT_LIBRARY: The LibEvent library +# LIBEVENT_LIBRARIES: The LibEvent library and dependencies +# LIBEVENT_INCLUDE_DIR: The LibEvent include dir +# +# This module will look for the libraries in various locations +# See the LIBEVENT_SEARCH_PATH_LIST for a full list. +# +# The caller can hint at locations using the following variables: +# +# LIBEVENT_HOME (passed as -D to cmake) +# LIBEVENT_HOME (in environment) +# + +set(LIBEVENT_SEARCH_PATH_LIST + ${LIBEVENT_HOME} + $ENV{DEPENDENCIES} + $ENV{LIBEVENT_HOME} + /usr/local + /opt + /usr + ) + +find_path(LIBEVENT_INCLUDE_DIR event2/event.h + HINTS ${LIBEVENT_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the LibEvent includes" ) + +find_library(LIBEVENT_LIBRARY NAMES event + HINTS ${LIBEVENT_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the LibEvent libraries" ) + +set(LIBEVENT_LIBRARIES ${LIBEVENT_LIBRARY}) +set(LIBEVENT_INCLUDE_DIRS ${LIBEVENT_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibEvent DEFAULT_MSG LIBEVENT_LIBRARY LIBEVENT_INCLUDE_DIR) diff --git a/cmake/Modules/FindLibhicn.cmake b/cmake/Modules/FindLibhicn.cmake new file mode 100755 index 000000000..7cfaaa5e5 --- /dev/null +++ b/cmake/Modules/FindLibhicn.cmake @@ -0,0 +1,49 @@ +# Copyright (c) 2017-2019 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. + +######################################## +# +# Find the hcin libraries and includes +# This module sets: +# HICN_FOUND: True if hicn was found +# HICN_LIBRARY: The hicn library +# HICN_LIBRARIES: The hicn library and dependencies +# HCIN_INCLUDE_DIR: The hicn include dir +# + +set(HICN_SEARCH_PATH_LIST + ${HICN_HOME} + $ENV{HICN_HOME} + $ENV{FOUNDATION_HOME} + /usr/local + /opt + /usr +) + +find_path(HICN_INCLUDE_DIR hicn/hicn.h + HINTS ${HICN_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the hicn includes" +) + +find_library(HICN_LIBRARY NAMES hicn + HINTS ${HICN_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the hicn libraries" +) + +set(HICN_LIBRARIES ${HICN_LIBRARY}) +set(HICN_INCLUDE_DIRS ${HICN_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(hicn DEFAULT_MSG HICN_LIBRARY HICN_INCLUDE_DIR) diff --git a/cmake/Modules/FindLibmemif.cmake b/cmake/Modules/FindLibmemif.cmake new file mode 100755 index 000000000..48460eecd --- /dev/null +++ b/cmake/Modules/FindLibmemif.cmake @@ -0,0 +1,47 @@ +# Copyright (c) 2017-2019 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. + +######################################## +# +# Find the hcin libraries and includes +# This module sets: +# LIBMEMIF_FOUND: True if core was found +# LIBMEMIF_LIBRARY: The core library +# LIBMEMIF_INCLUDE_DIR: The core include dir +# + +set(LIBMEMIF_SEARCH_PATH_LIST + ${LIBMEMIF_HOME} + $ENV{LIBMEMIF_HOME} + /usr/local + /opt + /usr +) + +find_path(LIBMEMIF_INCLUDE_DIR memif/libmemif.h + HINTS ${LIBMEMIF_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the libmemif includes" +) + +find_library(LIBMEMIF_LIBRARY NAMES memif + HINTS ${LIBMEMIF_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the libmemif libraries" +) + +set(LIBMEMIF_LIBRARIES ${LIBMEMIF_LIBRARY}) +set(LIBMEMIF_INCLUDE_DIRS ${LIBMEMIF_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libmemif DEFAULT_MSG LIBMEMIF_LIBRARY LIBMEMIF_INCLUDE_DIR) diff --git a/cmake/Modules/FindLibparc.cmake b/cmake/Modules/FindLibparc.cmake new file mode 100755 index 000000000..c5c99af15 --- /dev/null +++ b/cmake/Modules/FindLibparc.cmake @@ -0,0 +1,50 @@ +# Copyright (c) 2017-2019 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. + +######################################## +# +# Find the Libparc libraries and includes +# This module sets: +# LIBPARC_FOUND: True if Libparc was found +# LIBPARC_LIBRARY: The Libparc library +# LIBPARC_LIBRARIES: The Libparc library and dependencies +# LIBPARC_INCLUDE_DIR: The Libparc include dir +# + +set(LIBPARC_SEARCH_PATH_LIST + ${LIBPARC_HOME} + $ENV{LIBPARC_HOME} + /usr/local + /opt + /usr +) + +find_path(LIBPARC_INCLUDE_DIR parc/libparc_About.h + HINTS ${LIBPARC_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the Libparc includes" +) + +find_library(LIBPARC_LIBRARY NAMES parc + HINTS ${LIBPARC_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the Libparc libraries" +) + +set(LIBPARC_LIBRARIES ${LIBPARC_LIBRARY}) +set(LIBPARC_INCLUDE_DIRS ${LIBPARC_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libparc DEFAULT_MSG LIBPARC_LIBRARY LIBPARC_INCLUDE_DIR) + +mark_as_advanced(LIBPARC_LIBRARY LIBPARC_INCLUDE_DIR) diff --git a/cmake/Modules/FindLibtransport.cmake b/cmake/Modules/FindLibtransport.cmake new file mode 100755 index 000000000..5910a64da --- /dev/null +++ b/cmake/Modules/FindLibtransport.cmake @@ -0,0 +1,48 @@ +# Copyright (c) 2017-2019 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. + +######################################## +# +# Find the LibTRANSPORT libraries and includes +# This module sets: +# LIBTRANSPORT_FOUND: True if Libconsumer-producer was found +# LIBTRANSPORTR_LIBRARY: The Libconsumer-producer library +# LIBTRANSPORT_LIBRARIES: The Libconsumer-producer library and dependencies +# LIBTRANSPORT_INCLUDE_DIR: The Libconsumer-producer include dir +# + +set(LIBTRANSPORT_SEARCH_PATH_LIST + ${LIBTRANSPORT_HOME} + $ENV{LIBTRANSPORTHOME} + /usr/local + /opt + /usr +) + +find_path(LIBTRANSPORT_INCLUDE_DIR hicn/transport/config.h + HINTS ${LIBTRANSPORT_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the libtransport includes" +) + +find_library(LIBTRANSPORT_LIBRARY NAMES transport + HINTS ${LIBTRANSPORT_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the libtransport libraries" +) + +set(LIBTRANSPORT_LIBRARIES ${LIBTRANSPORT_LIBRARY}) +set(LIBTRANSPORT_INCLUDE_DIRS ${LIBTRANSPORT_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libtransport DEFAULT_MSG LIBTRANSPORT_LIBRARIES LIBTRANSPORT_INCLUDE_DIRS) \ No newline at end of file diff --git a/cmake/Modules/FindLongBow.cmake b/cmake/Modules/FindLongBow.cmake new file mode 100755 index 000000000..4a05d7fdf --- /dev/null +++ b/cmake/Modules/FindLongBow.cmake @@ -0,0 +1,55 @@ +# Copyright (c) 2017-2019 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. + +######################################## +# +# Find the LongBow libraries and includes +# This module sets: +# LONGBOW_FOUND: True if LongBow was found +# LONGBOW_LIBRARY: The LongBow library +# LONGBOW_LIBRARIES: The LongBow library and dependencies +# LONGBOW_INCLUDE_DIR: The LongBow include dir +# + +set(LONGBOW_SEARCH_PATH_LIST + ${LONGBOW_HOME} + $ENV{LONGBOW_HOME} + $ENV{PARC_HOME} + $ENV{FOUNDATION_HOME} + /usr/local/parc + /usr/local/ccn + /usr/local + /opt + /usr + ) + +find_path(LONGBOW_INCLUDE_DIR LongBow/longBow_About.h + HINTS ${LONGBOW_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the LongBow includes" ) + +find_library(LONGBOW_LIBRARY NAMES longbow + HINTS ${LONGBOW_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the LongBow libraries" ) + +find_library(LONGBOW_REPORT_LIBRARY NAMES longbow-textplain longbow-ansiterm + HINTS ${LONGBOW_SEARCH_PATH_LIST} + PATH_SUFFIXES lib + DOC "Find the LongBow report libraries" ) + +set(LONGBOW_LIBRARIES ${LONGBOW_LIBRARY} ${LONGBOW_REPORT_LIBRARY}) +set(LONGBOW_INCLUDE_DIRS ${LONGBOW_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LongBow DEFAULT_MSG LONGBOW_LIBRARY LONGBOW_INCLUDE_DIR) diff --git a/cmake/Modules/FindUncrustify.cmake b/cmake/Modules/FindUncrustify.cmake new file mode 100755 index 000000000..f8f6b00b8 --- /dev/null +++ b/cmake/Modules/FindUncrustify.cmake @@ -0,0 +1,21 @@ +# Copyright (c) 2017-2019 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. + +# Find uncrustify program +# +find_program( UNCRUSTIFY_BIN uncrustify + PATHS + $ENV{UNCRUSTIFY_HOME} + ) + +message( "-- UNCRUSTIFY found in ${UNCRUSTIFY_BIN}" ) diff --git a/cmake/Modules/FindVpp.cmake b/cmake/Modules/FindVpp.cmake new file mode 100755 index 000000000..ae11c8019 --- /dev/null +++ b/cmake/Modules/FindVpp.cmake @@ -0,0 +1,67 @@ +# Copyright (c) 2017-2019 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. + +set(VPP_SEARCH_PATH_LIST + ${VPP_HOME} + $ENV{VPP_HOME} + /usr/local + /opt + /usr +) + +find_path(VPP_INCLUDE_DIR vnet/vnet.h + HINTS ${VPP_SEARCH_PATH_LIST} + PATH_SUFFIXES include + DOC "Find the VPP includes" +) + +find_library(VPP_LIBRARY_MEMORYCLIENT + NAMES vlibmemoryclient + HINTS ${VPP_SEARCH_PATH_LIST} + PATH_SUFFIXES lib lib64 + DOC "Find the Vpp Memoryclient library" +) + +find_library(VPP_LIBRARY_SVM + NAMES svm + HINTS ${VPP_SEARCH_PATH_LIST} + PATH_SUFFIXES lib lib64 + DOC "Find the Vpp svm library" +) + +find_library(VPP_LIBRARY_INFRA + NAMES vppinfra + HINTS ${VPP_SEARCH_PATH_LIST} + PATH_SUFFIXES lib lib64 + DOC "Find the Vpp infra library" +) + +find_library(VPP_LIBRARY_VATPLUGIN + NAMES vatplugin + HINTS ${VPP_SEARCH_PATH_LIST} + PATH_SUFFIXES lib lib64 + DOC "Find the Vpp vatplugin library" +) + +find_library(VPP_LIBRARY_VLIB + NAMES vlib + HINTS ${VPP_SEARCH_PATH_LIST} + PATH_SUFFIXES lib lib64 + DOC "Find the Vpp vlib library" +) + +set(VPP_LIBRARIES ${VPP_LIBRARY_MEMORYCLIENT} ${VPP_LIBRARY_SVM} ${VPP_LIBRARY_INFRA} ${VPP_LIBRARY_VATPLUGIN} ${VPP_LIBRARY_VLIB}) +set(VPP_INCLUDE_DIRS ${VPP_INCLUDE_DIR} ${VPP_INCLUDE_DIR}/vpp_plugins) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Vpp DEFAULT_MSG VPP_LIBRARIES VPP_INCLUDE_DIRS) \ No newline at end of file diff --git a/cmake/Modules/IosMacros.cmake b/cmake/Modules/IosMacros.cmake new file mode 100755 index 000000000..b1e5cc438 --- /dev/null +++ b/cmake/Modules/IosMacros.cmake @@ -0,0 +1,24 @@ +# Copyright (c) 2017-2019 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. + +if(COMPILE_FOR_IOS) + include_directories(iOS) +endif() + +macro(find_package_wrapper) + if(COMPILE_FOR_IOS) + find_host_package(${ARGN}) + else() + find_package(${ARGN}) + endif() +endmacro() \ No newline at end of file diff --git a/cmake/Modules/Packager.cmake b/cmake/Modules/Packager.cmake new file mode 100755 index 000000000..58530fa72 --- /dev/null +++ b/cmake/Modules/Packager.cmake @@ -0,0 +1,105 @@ +# Copyright (c) 2017-2019 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. + +############# +# RPM/DEB/TGZ Packaging utils +# + +set(CONTACT "hicn-dev@lists.fd.io" CACHE STRING "Contact") +set(PACKAGE_MAINTAINER "ICN Team" CACHE STRING "Maintainer") +set(PACKAGE_VENDOR "fd.io" CACHE STRING "Vendor") + +macro(add_package name) + cmake_parse_arguments(ARG + "" + "NAME;DESCRIPION;DEPENDENCIES" + "" + ${ARGN} + ) + + if (0) + # parse /etc/os-release + file(READ "/etc/os-release" os_version) + string(REPLACE "\n" ";" os_version ${os_version}) + foreach(_ver ${os_version}) + string(REPLACE "=" ";" _ver ${_ver}) + list(GET _ver 0 _name) + list(GET _ver 1 _value) + set(OS_${_name} ${_value}) + endforeach() + + # extract version from git + execute_process( + COMMAND git describe --long --match v* + OUTPUT_VARIABLE VER + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if (NOT VER) + set(VER 1.0) + endif() + + string(REGEX REPLACE "v(.*)-([0-9]+)-(g[0-9a-f]+)" "\\1;\\2;\\3" VER ${VER}) + list(GET VER 0 tag) + string(REPLACE "-" "~" tag ${tag}) + list(GET VER 1 commit_num) + list(GET VER 2 commit_name) + + #define DEB and RPM version numbers + if(${commit_num} EQUAL 0) + set(deb_ver "${tag}") + set(rpm_ver "${tag}") + else() + set(deb_ver "${tag}~${commit_num}~${commit_name}") + set(rpm_ver "${tag}~${commit_num}_${commit_name}") + endif() + + get_cmake_property(components COMPONENTS) + + if(OS_ID_LIKE MATCHES "debian") + set(CPACK_GENERATOR "DEB") + set(type "DEBIAN") + set(CPACK_PACKAGE_VERSION "${deb_ver}") + set(CPACK_DEBIAN_PACKAGE_MAINTAINER "VPP Team") + set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) + foreach(lc ${components}) + string(TOUPPER ${lc} uc) + set(CPACK_DEBIAN_${uc}_PACKAGE_NAME "${lc}") + endforeach() + elseif(OS_ID_LIKE MATCHES "rhel") + set(CPACK_GENERATOR "RPM") + set(type "RPM") + set(CPACK_PACKAGE_VERSION "${rpm_ver}") + set(CPACK_RPM_FILE_NAME RPM-DEFAULT) + foreach(lc ${components}) + string(TOUPPER ${lc} uc) + if(${lc} MATCHES ".*-dev") + set(CPACK_RPM_${uc}_DEBUGINFO_PACKAGE ON) + set(lc ${lc}el) + endif() + set(CPACK_RPM_${uc}_PACKAGE_NAME "${lc}") + endforeach() + endif() + + if(CPACK_GENERATOR) + set(CPACK_PACKAGE_NAME ${ARG_NAME}) + set(CPACK_STRIP_FILES OFF) + set(CPACK_PACKAGE_VENDOR "${ARG_VENDOR}") + set(CPACK_COMPONENTS_IGNORE_GROUPS 1) + set(CPACK_${CPACK_GENERATOR}_COMPONENT_INSTALL ON) + set(CPACK_${type}_PACKAGE_DESCRIPTION "${ARG_DESCRIPTION}") + set(CPACK_${type}_PACKAGE_RELEASE 1) + include(CPack) + endif() + endif() +endmacro() \ No newline at end of file diff --git a/cmake/Modules/detectCacheSize.cmake b/cmake/Modules/detectCacheSize.cmake new file mode 100755 index 000000000..a8209bb27 --- /dev/null +++ b/cmake/Modules/detectCacheSize.cmake @@ -0,0 +1,21 @@ +# Detect the cache size +# +# XXX: TODO: This is a bug when cross compiling. We are detecting the local +# Cache Line size and not the target cache line size. We should provide some +# way to define this + +set(LEVEL1_DCACHE_LINESIZE 32) + +if( APPLE ) + execute_process(COMMAND sysctl -n hw.cachelinesize + OUTPUT_VARIABLE LEVEL1_DCACHE_LINESIZE + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif( APPLE ) + +if( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" ) + execute_process(COMMAND getconf LEVEL1_DCACHE_LINESIZE + OUTPUT_VARIABLE LEVEL1_DCACHE_LINESIZE + OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + +message(STATUS "Cache line size: ${LEVEL1_DCACHE_LINESIZE}") -- cgit 1.2.3-korg