-
Notifications
You must be signed in to change notification settings - Fork 14
/
CMakeLists.txt
108 lines (87 loc) · 3.3 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.22)
include(cmake/version.cmake)
get_version(${CMAKE_CURRENT_LIST_DIR}/version.txt GIT_VERSION GIT_BRANCH GIT_COMMIT_HASH)
project(ziti-sdk
DESCRIPTION "OpenZiti C SDK"
HOMEPAGE_URL "https://github.com/openziti/ziti-sdk-c"
LANGUAGES C CXX
)
set(PROJECT_VERSION ${GIT_VERSION})
include(cmake/variables.cmake)
set(tlsuv_DIR "" CACHE FILEPATH "developer option: use local tlsuv checkout")
message("project version: ${PROJECT_VERSION}")
message("git info:")
message(" branch : ${GIT_BRANCH}")
message(" hash : ${GIT_COMMIT_HASH}")
message("")
message("using ${CMAKE_GENERATOR}")
if (WIN32)
if(MINGW)
#on server 2016 msvcrt.dll does not process %z formatting
#that can lead to a crash if the string format is something like: %zd(%s)
add_compile_definitions(__USE_MINGW_ANSI_STDIO=1)
endif()
set(CMAKE_INSTALL_LIBDIR lib)
set(CMAKE_INSTALL_INCLUDEDIR include)
if(NOT CMAKE_INSTALL_PREFIX)
message("WIN32 build. Creating: ${CMAKE_BINARY_DIR}/cmake_install")
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/cmake_install)
message("WIN32 build. Creating: ${CMAKE_BINARY_DIR}/cmake_install/ziti-sdk-${PROJECT_VERSION}")
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/cmake_install/ziti-sdk-${PROJECT_VERSION})
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/cmake_install/ziti-sdk-${PROJECT_VERSION})
endif()
else()
set(CMAKE_INSTALL_PREFIX /opt/openziti/ziti-sdk-${PROJECT_VERSION})
endif()
message("cross-compiling ${CMAKE_CROSSCOMPILING}")
if (DEFINED ENV{BUILD_NUMBER})
set(ZITI_BUILDNUM $ENV{BUILD_NUMBER})
endif ()
link_directories(${CMAKE_BINARY_DIR}/lib)
add_subdirectory(deps)
set(CPACK_INSTALL_CMAKE_PROJECTS
"${CMAKE_CURRENT_BINARY_DIR};${PROJECT_NAME};ziti-sdk;/"
)
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_OUTPUT_FILE_PREFIX ${CMAKE_BINARY_DIR}/package)
set(CPACK_GENERATOR "ZIP")
set(archive_sfx "zip")
find_program(ZIP NAMES 7z)
if (ZIP)
set(ZIP_OPTS a -tzip)
else ()
find_program(ZIP NAMES zip)
if (ZIP)
set(ZIP_OPTS "-jv")
else ()
message("zip program not found")
endif ()
endif ()
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
if(NOT CPack_CMake_INCLUDED)
include(CPack)
endif()
# use prefix length to trim path for logging, see utils.c
if (CMAKE_GENERATOR STREQUAL "Ninja" AND CMAKE_BINARY_DIR MATCHES "${CMAKE_SOURCE_DIR}")
# if CMAKE_BINARY_DIR is inside CMAKE_SOURCE_DIR Ninja uses relative paths which screws logging of the filename
# so we just leave it be -- it shows enough information to find the source
set(SOURCE_PATH_SIZE 0)
else()
string(LENGTH "${CMAKE_SOURCE_DIR}/" SOURCE_PATH_SIZE)
endif()
add_subdirectory(library)
if (PROJECT_IS_TOP_LEVEL)
option(BUILD_EXAMPLES "Build examples tree." "${ziti_DEVELOPER_MODE}")
if (BUILD_EXAMPLES)
add_subdirectory(programs)
endif ()
endif ()
if (ziti_DEVELOPER_MODE AND NOT CMAKE_CROSSCOMPILING)
ENABLE_TESTING()
add_subdirectory(tests)
endif ()
if (ziti-sdk_IS_TOP_LEVEL AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/local.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/local.cmake")
endif ()