-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
71 lines (59 loc) · 2.57 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
cmake_minimum_required(VERSION 3.14)
include(git.cmake)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_C_STANDARD 99)
set( CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS 1 )
set(WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(USING_ZITI_SHARED ON)
set(BUILDING_ZITI_SHARED ON)
set(ZITI_SDK_C_BRANCH_DEFAULT "0.35.0")
if ("$ENV{ZITI_SDK_C_BRANCH}" STREQUAL "")
#allow using a different branch of the CSDK easily
set(ZITI_SDK_C_BRANCH "${ZITI_SDK_C_BRANCH_DEFAULT}")
message("using default ZITI_SDK_C_BRANCH: ${ZITI_SDK_C_BRANCH}")
else()
set(ZITI_SDK_C_BRANCH "$ENV{ZITI_SDK_C_BRANCH}")
endif()
message("CSDK SELECTED: ${ZITI_SDK_C_BRANCH}")
file (STRINGS "../version" BUILD_NUMBER)
project(ziti4dotnet VERSION ${BUILD_NUMBER} LANGUAGES C CXX)
message("project version: ${PROJECT_VERSION} (BUILD_NUMBER ${BUILD_NUMBER})")
message("cross-compiling: ${CMAKE_CROSSCOMPILING}")
#uncomment to see cmake variables
#get_cmake_property(_variableNames VARIABLES)
#list (SORT _variableNames)
#foreach (_variableName ${_variableNames})
# message(STATUS "CMAKE_ENV: ${_variableName}=${${_variableName}}")
#endforeach()
include(FetchContent)
add_subdirectory(cmake_deps)
add_subdirectory(library)
#add_subdirectory(programs)
string(TOLOWER "${GENERATE_ZITI_STATUS}" generate_csharp_enum)
FetchContent_MakeAvailable(ziti-sdk-c)
if("${generate_csharp_enum}" STREQUAL "yes")
set(SourceErrorsFile "${ziti-sdk-c_SOURCE_DIR}/includes/ziti/errors.h")
set(OUTPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../OpenZiti.NET/src/OpenZiti/ZitiStatus.cs")
execute_process(
COMMAND powershell -File "${CMAKE_CURRENT_SOURCE_DIR}/generateDotnetStatus.ps1" -SourceFile "${SourceErrorsFile}" -OutputPath ${OUTPUT_FILE}
)
message("sharp-errors output to: ${OUTPUT_FILE}")
endif()
string(TOLOWER "${ZITI_RUN_DEFGEN}" ziti_run_defgen)
if("${ziti_run_defgen}" STREQUAL "yes")
FetchContent_Declare(
ziti-sdk-c-archive
URL "https://github.com/openziti/ziti-sdk-c/releases/download/${ZITI_SDK_C_BRANCH}/ziti-sdk-${ZITI_SDK_C_BRANCH}-Windows-AMD64.zip"
DOWNLOAD_NO_EXTRACT false
DOWNLOAD_EXTRACT_TIMESTAMP true
)
FetchContent_MakeAvailable(ziti-sdk-c-archive)
message("Generating .def file from downloaded archive at: ${ziti-sdk-c-archive_SOURCE_DIR}/lib/ziti.dll")
# Specify the path to your .bat file
set(batch_file_path "defgen.bat")
execute_process(
COMMAND "defgen.bat" "64" "${ziti-sdk-c-archive_SOURCE_DIR}/lib/ziti.dll"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE result
)
endif()