Skip to content

Commit 7cb389a

Browse files
committed
Delete and regenerate C samples
1 parent 543952e commit 7cb389a

17 files changed

+136
-745
lines changed

samples/client/petstore/c-useJsonUnformatted/unit-test/test_user.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ user_t* instantiate_user(int include_optional) {
2929
"0",
3030
"0",
3131
"0",
32-
56
32+
56,
33+
list_createList(),
34+
openapi_petstore_user__cats
3335
);
3436
} else {
3537
user = user_create(
@@ -40,7 +42,9 @@ user_t* instantiate_user(int include_optional) {
4042
"0",
4143
"0",
4244
"0",
43-
56
45+
56,
46+
list_createList(),
47+
openapi_petstore_user__cats
4448
);
4549
}
4650

samples/client/petstore/c/.openapi-generator-ignore

-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@
2121
#docs/*.md
2222
# Then explicitly reverse the ignore rule for a single file:
2323
#!docs/README.md
24-
CMakeLists.txt

samples/client/petstore/c/.openapi-generator/FILES

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
CMakeLists.txt
12
Config.cmake.in
23
Packing.cmake
34
README.md

samples/client/petstore/c/CMakeLists.txt

+119-18
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,66 @@
1-
cmake_minimum_required (VERSION 2.6)
2-
project (CGenerator)
1+
cmake_minimum_required (VERSION 2.6...3.10.2)
2+
project (CGenerator C)
33

44
cmake_policy(SET CMP0063 NEW)
55

66
set(CMAKE_C_VISIBILITY_PRESET default)
7-
set(CMAKE_CXX_VISIBILITY_PRESET default)
87
set(CMAKE_VISIBILITY_INLINES_HIDDEN OFF)
9-
set(CMAKE_BUILD_TYPE Debug)
8+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
9+
10+
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
11+
12+
find_package(OpenSSL)
13+
14+
if (OPENSSL_FOUND)
15+
message (STATUS "OPENSSL found")
16+
17+
set(CMAKE_C_FLAGS "-DOPENSSL")
18+
if(CMAKE_VERSION VERSION_LESS 3.4)
19+
include_directories(${OPENSSL_INCLUDE_DIR})
20+
include_directories(${OPENSSL_INCLUDE_DIRS})
21+
link_directories(${OPENSSL_LIBRARIES})
22+
endif()
23+
24+
message(STATUS "Using OpenSSL ${OPENSSL_VERSION}")
25+
else()
26+
message (STATUS "OpenSSL Not found.")
27+
endif()
1028

1129
set(pkgName "openapi_petstore")
1230

13-
find_package(CURL 7.58.0 REQUIRED)
14-
if(CURL_FOUND)
15-
include_directories(${CURL_INCLUDE_DIR})
16-
set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} ${CURL_LIBRARIES} )
17-
else(CURL_FOUND)
18-
message(FATAL_ERROR "Could not find the CURL library and development files.")
31+
# this default version can be overridden in PreTarget.cmake
32+
set(PROJECT_VERSION_MAJOR 0)
33+
set(PROJECT_VERSION_MINOR 0)
34+
set(PROJECT_VERSION_PATCH 1)
35+
36+
if( (DEFINED CURL_INCLUDE_DIR) AND (DEFINED CURL_LIBRARIES))
37+
include_directories(${CURL_INCLUDE_DIR})
38+
set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} ${CURL_LIBRARIES} )
39+
else()
40+
find_package(CURL 7.58.0 REQUIRED)
41+
if(CURL_FOUND)
42+
include_directories(${CURL_INCLUDE_DIR})
43+
set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} ${CURL_LIBRARIES} )
44+
else(CURL_FOUND)
45+
message(FATAL_ERROR "Could not find the CURL library and development files.")
46+
endif()
1947
endif()
2048

2149
set(SRCS
2250
src/list.c
2351
src/apiKey.c
2452
src/apiClient.c
53+
src/binary.c
2554
external/cJSON.c
2655
model/object.c
56+
model/mapped_model.c
2757
model/api_response.c
58+
model/bit.c
2859
model/category.c
60+
model/model_with_set_propertes.c
2961
model/order.c
3062
model/pet.c
63+
model/preference.c
3164
model/tag.c
3265
model/user.c
3366
api/PetAPI.c
@@ -39,13 +72,19 @@ set(SRCS
3972
set(HDRS
4073
include/apiClient.h
4174
include/list.h
75+
include/binary.h
4276
include/keyValuePair.h
4377
external/cJSON.h
4478
model/object.h
79+
model/any_type.h
80+
model/mapped_model.h
4581
model/api_response.h
82+
model/bit.h
4683
model/category.h
84+
model/model_with_set_propertes.h
4785
model/order.h
4886
model/pet.h
87+
model/preference.h
4988
model/tag.h
5089
model/user.h
5190
api/PetAPI.h
@@ -54,12 +93,75 @@ set(HDRS
5493

5594
)
5695

57-
# Add library with project file with projectname as library name
58-
add_library(${pkgName} SHARED ${SRCS} ${HDRS})
96+
include(PreTarget.cmake OPTIONAL)
97+
98+
set(PROJECT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
99+
100+
# Add library with project file with project name as library name
101+
add_library(${pkgName} ${SRCS} ${HDRS})
59102
# Link dependent libraries
60-
target_link_libraries(${pkgName} ${CURL_LIBRARIES} )
61-
#install library to destination
62-
install(TARGETS ${pkgName} DESTINATION ${CMAKE_INSTALL_PREFIX})
103+
if(NOT CMAKE_VERSION VERSION_LESS 3.4)
104+
target_link_libraries(${pkgName} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
105+
endif()
106+
target_link_libraries(${pkgName} PUBLIC ${CURL_LIBRARIES} )
107+
target_include_directories(
108+
${pkgName} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
109+
$<INSTALL_INTERFACE:include>
110+
)
111+
112+
include(PostTarget.cmake OPTIONAL)
113+
114+
# installation of libraries, headers, and config files
115+
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in)
116+
install(TARGETS ${pkgName} DESTINATION lib)
117+
else()
118+
include(GNUInstallDirs)
119+
install(TARGETS ${pkgName} DESTINATION lib EXPORT ${pkgName}Targets)
120+
121+
foreach(HDR_FILE ${HDRS})
122+
get_filename_component(HDR_DIRECTORY ${HDR_FILE} DIRECTORY)
123+
get_filename_component(ABSOLUTE_HDR_DIRECTORY ${HDR_DIRECTORY} ABSOLUTE)
124+
file(RELATIVE_PATH RELATIVE_HDR_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${ABSOLUTE_HDR_DIRECTORY})
125+
install(FILES ${HDR_FILE} DESTINATION include/${pkgName}/${RELATIVE_HDR_PATH})
126+
endforeach()
127+
128+
include(CMakePackageConfigHelpers)
129+
write_basic_package_version_file(
130+
"${CMAKE_CURRENT_BINARY_DIR}/${pkgName}/${pkgName}ConfigVersion.cmake"
131+
VERSION "${PROJECT_VERSION_STRING}"
132+
COMPATIBILITY AnyNewerVersion
133+
)
134+
135+
export(EXPORT ${pkgName}Targets
136+
FILE "${CMAKE_CURRENT_BINARY_DIR}/${pkgName}/${pkgName}Targets.cmake"
137+
NAMESPACE ${pkgName}::
138+
)
139+
140+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
141+
"${CMAKE_CURRENT_BINARY_DIR}/${pkgName}/${pkgName}Config.cmake"
142+
@ONLY
143+
)
144+
145+
set(ConfigPackageLocation lib/cmake/${pkgName})
146+
install(EXPORT ${pkgName}Targets
147+
FILE
148+
${pkgName}Targets.cmake
149+
NAMESPACE
150+
${pkgName}::
151+
DESTINATION
152+
${ConfigPackageLocation}
153+
)
154+
install(
155+
FILES
156+
"${CMAKE_CURRENT_BINARY_DIR}/${pkgName}/${pkgName}Config.cmake"
157+
"${CMAKE_CURRENT_BINARY_DIR}/${pkgName}/${pkgName}ConfigVersion.cmake"
158+
DESTINATION
159+
${ConfigPackageLocation}
160+
)
161+
endif()
162+
163+
# make installation packages
164+
include(Packing.cmake OPTIONAL)
63165

64166
# Setting file variables to null
65167
set(SRCS "")
@@ -72,16 +174,15 @@ set(HDRS "")
72174
# unit-tests/manual-PetAPI.c
73175
# unit-tests/manual-StoreAPI.c
74176
# unit-tests/manual-UserAPI.c
75-
# unit-tests/manual-order.c
76-
# unit-tests/manual-user.c)
177+
#)
77178

78179
##set header files
79180
#set(HDRS
80181
#)
81182

82183
## loop over all files in SRCS variable
83184
#foreach(SOURCE_FILE ${SRCS})
84-
# # Get only the file name from the file as add_executable doesn't support executable with slash("/")
185+
# # Get only the file name from the file as add_executable does not support executable with slash("/")
85186
# get_filename_component(FILE_NAME_ONLY ${SOURCE_FILE} NAME_WE)
86187
# # Remove .c from the file name and set it as executable name
87188
# string( REPLACE ".c" "" EXECUTABLE_FILE ${FILE_NAME_ONLY})

samples/client/petstore/c/build-and-test.bash

-22
This file was deleted.

samples/client/petstore/c/docs/another_model.md

-11
This file was deleted.

samples/client/petstore/c/model/another_model.c

-93
This file was deleted.

samples/client/petstore/c/model/another_model.h

-39
This file was deleted.

0 commit comments

Comments
 (0)