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}) |
BenoƮt Ganne | 47727c0 | 2019-02-12 13:35:08 +0100 | [diff] [blame] | 23 | target_compile_options(${lib} PRIVATE -Wall -fno-common) |
Damjan Marion | 958192d | 2018-09-13 18:43:19 +0200 | [diff] [blame] | 24 | if(VPP_LIB_VERSION) |
| 25 | set_target_properties(${lib} PROPERTIES SOVERSION ${VPP_LIB_VERSION}) |
| 26 | endif() |
Damjan Marion | 4553c95 | 2018-08-26 11:04:40 +0200 | [diff] [blame] | 27 | |
| 28 | # library deps |
| 29 | if(ARG_LINK_LIBRARIES) |
| 30 | target_link_libraries(${lib} ${ARG_LINK_LIBRARIES}) |
| 31 | endif() |
| 32 | # install .so |
Damjan Marion | 43b0606 | 2018-08-29 22:20:45 +0200 | [diff] [blame] | 33 | if(NOT ARG_COMPONENT) |
| 34 | set(ARG_COMPONENT vpp) |
| 35 | endif() |
| 36 | install( |
| 37 | TARGETS ${lib} |
Damjan Marion | 79dcbc7 | 2018-09-12 14:01:10 +0200 | [diff] [blame] | 38 | DESTINATION lib |
Damjan Marion | 43b0606 | 2018-08-29 22:20:45 +0200 | [diff] [blame] | 39 | COMPONENT ${ARG_COMPONENT} |
| 40 | ) |
Damjan Marion | 4553c95 | 2018-08-26 11:04:40 +0200 | [diff] [blame] | 41 | |
| 42 | if(ARG_MULTIARCH_SOURCES) |
| 43 | vpp_library_set_multiarch_sources(${lib} ${ARG_MULTIARCH_SOURCES}) |
| 44 | endif() |
| 45 | |
| 46 | if(ARG_API_FILES) |
Damjan Marion | 4c64b6e | 2018-08-26 18:14:46 +0200 | [diff] [blame] | 47 | vpp_add_api_files(${lib} ${ARG_API_FILES}) |
Damjan Marion | 4553c95 | 2018-08-26 11:04:40 +0200 | [diff] [blame] | 48 | foreach(file ${ARG_API_FILES}) |
| 49 | get_filename_component(dir ${file} DIRECTORY) |
Damjan Marion | 43b0606 | 2018-08-29 22:20:45 +0200 | [diff] [blame] | 50 | install( |
| 51 | FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}.h |
| 52 | DESTINATION include/${lib}/${dir} |
| 53 | COMPONENT vpp-dev |
| 54 | ) |
Damjan Marion | 4553c95 | 2018-08-26 11:04:40 +0200 | [diff] [blame] | 55 | endforeach() |
| 56 | endif() |
| 57 | |
| 58 | if(ARG_DEPENDS) |
| 59 | add_dependencies(${lib} ${ARG_DEPENDS}) |
| 60 | endif() |
| 61 | |
| 62 | # install headers |
| 63 | if(ARG_INSTALL_HEADERS) |
| 64 | foreach(file ${ARG_INSTALL_HEADERS}) |
| 65 | get_filename_component(dir ${file} DIRECTORY) |
Damjan Marion | 43b0606 | 2018-08-29 22:20:45 +0200 | [diff] [blame] | 66 | install( |
| 67 | FILES ${file} |
| 68 | DESTINATION include/${lib}/${dir} |
Damjan Marion | eeadc14 | 2018-09-13 20:02:12 +0200 | [diff] [blame] | 69 | COMPONENT ${ARG_COMPONENT}-dev |
Damjan Marion | 43b0606 | 2018-08-29 22:20:45 +0200 | [diff] [blame] | 70 | ) |
Damjan Marion | 4553c95 | 2018-08-26 11:04:40 +0200 | [diff] [blame] | 71 | endforeach() |
| 72 | endif() |
| 73 | endmacro() |
| 74 | |
| 75 | ############################################################################## |
| 76 | # header files |
| 77 | ############################################################################## |
| 78 | function (add_vpp_headers path) |
| 79 | foreach(file ${ARGN}) |
| 80 | get_filename_component(dir ${file} DIRECTORY) |
Damjan Marion | 833de8c | 2018-09-07 12:39:02 +0200 | [diff] [blame] | 81 | install( |
| 82 | FILES ${file} |
| 83 | DESTINATION include/${path}/${dir} |
| 84 | COMPONENT vpp-dev |
| 85 | ) |
Damjan Marion | 4553c95 | 2018-08-26 11:04:40 +0200 | [diff] [blame] | 86 | endforeach() |
| 87 | endfunction() |