blob: 66b4dffe5752402adc67024146a234671998e7a2 [file] [log] [blame]
Damjan Marion4553c952018-08-26 11:04:40 +02001# Copyright (c) 2018 Cisco and/or its affiliates.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at:
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14macro(add_vpp_library lib)
15 cmake_parse_arguments(ARG
16 ""
17 ""
18 "SOURCES;MULTIARCH_SOURCES;API_FILES;LINK_LIBRARIES;INSTALL_HEADERS;DEPENDS"
19 ${ARGN}
20 )
21
22 add_library(${lib} SHARED ${ARG_SOURCES})
Damjan Marion64627422018-08-28 12:33:52 +020023 target_compile_options(${lib} PRIVATE -Wall)
Damjan Marion4553c952018-08-26 11:04:40 +020024
25 # library deps
26 if(ARG_LINK_LIBRARIES)
27 target_link_libraries(${lib} ${ARG_LINK_LIBRARIES})
28 endif()
29 # install .so
Damjan Marionc2617602018-08-27 11:40:58 +020030 install(TARGETS ${lib} DESTINATION ${VPP_LIB_DIR_NAME})
Damjan Marion4553c952018-08-26 11:04:40 +020031
32 if(ARG_MULTIARCH_SOURCES)
33 vpp_library_set_multiarch_sources(${lib} ${ARG_MULTIARCH_SOURCES})
34 endif()
35
36 if(ARG_API_FILES)
Damjan Marion4c64b6e2018-08-26 18:14:46 +020037 vpp_add_api_files(${lib} ${ARG_API_FILES})
Damjan Marion4553c952018-08-26 11:04:40 +020038 foreach(file ${ARG_API_FILES})
39 get_filename_component(dir ${file} DIRECTORY)
40 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}.h DESTINATION include/${lib}/${dir})
41 endforeach()
42 endif()
43
44 if(ARG_DEPENDS)
45 add_dependencies(${lib} ${ARG_DEPENDS})
46 endif()
47
48 # install headers
49 if(ARG_INSTALL_HEADERS)
50 foreach(file ${ARG_INSTALL_HEADERS})
51 get_filename_component(dir ${file} DIRECTORY)
52 install(FILES ${file} DESTINATION include/${lib}/${dir})
53 endforeach()
54 endif()
55endmacro()
56
57##############################################################################
58# header files
59##############################################################################
60function (add_vpp_headers path)
61 foreach(file ${ARGN})
62 get_filename_component(dir ${file} DIRECTORY)
63 install(FILES ${file} DESTINATION include/${path}/${dir})
64 endforeach()
65endfunction()