Damjan Marion | 4553c95 | 2018-08-26 11:04:40 +0200 | [diff] [blame] | 1 | # 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 | |
| 14 | macro(add_vpp_library lib) |
| 15 | cmake_parse_arguments(ARG |
| 16 | "" |
Damjan Marion | 43b0606 | 2018-08-29 22:20:45 +0200 | [diff] [blame] | 17 | "COMPONENT" |
Damjan Marion | 4553c95 | 2018-08-26 11:04:40 +0200 | [diff] [blame] | 18 | "SOURCES;MULTIARCH_SOURCES;API_FILES;LINK_LIBRARIES;INSTALL_HEADERS;DEPENDS" |
| 19 | ${ARGN} |
| 20 | ) |
| 21 | |
| 22 | add_library(${lib} SHARED ${ARG_SOURCES}) |
Damjan Marion | 958192d | 2018-09-13 18:43:19 +0200 | [diff] [blame] | 23 | if(VPP_LIB_VERSION) |
| 24 | set_target_properties(${lib} PROPERTIES SOVERSION ${VPP_LIB_VERSION}) |
| 25 | endif() |
Damjan Marion | 4553c95 | 2018-08-26 11:04:40 +0200 | [diff] [blame] | 26 | |
| 27 | # library deps |
| 28 | if(ARG_LINK_LIBRARIES) |
| 29 | target_link_libraries(${lib} ${ARG_LINK_LIBRARIES}) |
| 30 | endif() |
| 31 | # install .so |
Damjan Marion | 43b0606 | 2018-08-29 22:20:45 +0200 | [diff] [blame] | 32 | if(NOT ARG_COMPONENT) |
| 33 | set(ARG_COMPONENT vpp) |
| 34 | endif() |
| 35 | install( |
| 36 | TARGETS ${lib} |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 37 | DESTINATION lib |
Damjan Marion | 43b0606 | 2018-08-29 22:20:45 +0200 | [diff] [blame] | 38 | COMPONENT ${ARG_COMPONENT} |
| 39 | ) |
Damjan Marion | 4553c95 | 2018-08-26 11:04:40 +0200 | [diff] [blame] | 40 | |
| 41 | if(ARG_MULTIARCH_SOURCES) |
| 42 | vpp_library_set_multiarch_sources(${lib} ${ARG_MULTIARCH_SOURCES}) |
| 43 | endif() |
| 44 | |
| 45 | if(ARG_API_FILES) |
Oliver Giles | dc20371 | 2019-12-05 23:37:36 +0200 | [diff] [blame] | 46 | vpp_add_api_files(${lib} core vpp ${ARG_API_FILES}) |
Damjan Marion | 4553c95 | 2018-08-26 11:04:40 +0200 | [diff] [blame] | 47 | foreach(file ${ARG_API_FILES}) |
| 48 | get_filename_component(dir ${file} DIRECTORY) |
Damjan Marion | 43b0606 | 2018-08-29 22:20:45 +0200 | [diff] [blame] | 49 | install( |
BenoƮt Ganne | 98438e4 | 2019-07-25 16:26:20 +0200 | [diff] [blame] | 50 | FILES ${file} ${CMAKE_CURRENT_BINARY_DIR}/${file}.h |
Ole Troan | 2a1ca78 | 2019-09-19 01:08:30 +0200 | [diff] [blame] | 51 | ${CMAKE_CURRENT_BINARY_DIR}/${file}_enum.h |
| 52 | ${CMAKE_CURRENT_BINARY_DIR}/${file}_types.h |
Damjan Marion | 43b0606 | 2018-08-29 22:20:45 +0200 | [diff] [blame] | 53 | DESTINATION include/${lib}/${dir} |
| 54 | COMPONENT vpp-dev |
| 55 | ) |
Damjan Marion | 4553c95 | 2018-08-26 11:04:40 +0200 | [diff] [blame] | 56 | endforeach() |
| 57 | endif() |
| 58 | |
| 59 | if(ARG_DEPENDS) |
| 60 | add_dependencies(${lib} ${ARG_DEPENDS}) |
| 61 | endif() |
| 62 | |
| 63 | # install headers |
| 64 | if(ARG_INSTALL_HEADERS) |
| 65 | foreach(file ${ARG_INSTALL_HEADERS}) |
| 66 | get_filename_component(dir ${file} DIRECTORY) |
Damjan Marion | 43b0606 | 2018-08-29 22:20:45 +0200 | [diff] [blame] | 67 | install( |
| 68 | FILES ${file} |
| 69 | DESTINATION include/${lib}/${dir} |
Damjan Marion | eeadc14 | 2018-09-13 20:02:12 +0200 | [diff] [blame] | 70 | COMPONENT ${ARG_COMPONENT}-dev |
Damjan Marion | 43b0606 | 2018-08-29 22:20:45 +0200 | [diff] [blame] | 71 | ) |
Damjan Marion | 4553c95 | 2018-08-26 11:04:40 +0200 | [diff] [blame] | 72 | endforeach() |
| 73 | endif() |
| 74 | endmacro() |
| 75 | |
| 76 | ############################################################################## |
| 77 | # header files |
| 78 | ############################################################################## |
| 79 | function (add_vpp_headers path) |
| 80 | foreach(file ${ARGN}) |
| 81 | get_filename_component(dir ${file} DIRECTORY) |
Damjan Marion | 833de8c | 2018-09-07 12:39:02 +0200 | [diff] [blame] | 82 | install( |
| 83 | FILES ${file} |
| 84 | DESTINATION include/${path}/${dir} |
| 85 | COMPONENT vpp-dev |
| 86 | ) |
Damjan Marion | 4553c95 | 2018-08-26 11:04:40 +0200 | [diff] [blame] | 87 | endforeach() |
| 88 | endfunction() |