aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src/CMakeLists.txt
blob: ef74127cc1d2193c546a39bd7c46093bb939194c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Copyright (c) 2021-2022 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.

##############################################################
# Source and Header files
##############################################################
list(APPEND LIBHICN_SOURCE_FILES
  common.c
  compat.c
  error.c
  face.c
  mapme.c
  name.c
  ops.c
  policy.c
  strategy.c
  protocol/ah.c
  protocol/icmp.c
  protocol/ipv4.c
  protocol/ipv6.c
  protocol/tcp.c
  protocol/udp.c
  protocol/new.c
  util/ip_address.c
  util/log.c
)

if (WIN32)
  list(APPEND LIBHICN_SOURCE_FILES
    util/windows/dlfcn.c
  )
endif ()

##############################################################
# Compiler definitions
##############################################################
set (COMPILER_DEFINITIONS
  PUBLIC "-DWITH_MAPME"
  PUBLIC "-DWITH_POLICY"
)

include(BuildMacros)
include(WindowsMacros)

##############################################################
# Build type
##############################################################
set (BUILD_TYPES "STATIC")

if (NOT DISABLE_SHARED_LIBRARIES)
  list(APPEND BUILD_TYPES
    "SHARED"
  )
endif()


##############################################################
# Compiler Options
##############################################################
set(COMPILER_OPTIONS
  ${DEFAULT_COMPILER_OPTIONS}
)


##############################################################
# Link libraries
##############################################################
if (WIN32)
  list(APPEND LIBRARIES
    PRIVATE ${WSOCK32_LIBRARY}
    PRIVATE ${WS2_32_LIBRARY}
  )
endif ()


##############################################################
# Build library
##############################################################
build_library(${LIBHICN}
  ${BUILD_TYPES}
  SOURCES ${LIBHICN_SOURCE_FILES}
  COMPONENT ${LIBHICN_COMPONENT}
  INCLUDE_DIRS
    PUBLIC
      $<BUILD_INTERFACE:${Libhicn_INCLUDE_DIRS}>
      $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
      $<BUILD_INTERFACE:${THIRD_PARTY_INCLUDE_DIRS}>
  DEFINITIONS ${COMPILER_DEFINITIONS}
  INSTALL_HEADERS ${LIBHICN_HEADER_FILES} ${LIBHICN_HEADER_FILES_PROTOCOL} ${LIBHICN_HEADER_FILES_UTIL}
  DEPENDS ${THIRD_PARTY_DEPENDENCIES}
  LINK_LIBRARIES
    PRIVATE ${WSOCK32_LIBRARY}
    PRIVATE ${WS2_32_LIBRARY}
    PUBLIC ${THIRD_PARTY_LIBRARIES}
  VERSION ${CURRENT_VERSION}
  EXPORT_NAME ${LIBHICN_COMPONENT}
  COMPILE_OPTIONS ${COMPILER_OPTIONS}
)

##############################################################
# Unit tests
##############################################################
if (${BUILD_TESTS})
  add_subdirectory(test)
endif()


##############################################################
# Cmake config files
##############################################################
create_cmake_config (
  ${LIBHICN_COMPONENT}
  INCLUDE_DIRS ${HICN_INCLUDE_DIRS}
  VERSION ${CURRENT_VERSION}
  COMPONENT ${LIBHICN_COMPONENT}
  NAMESPACE hicn
)