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