Skip to content

Commit 54b3d3f

Browse files
author
Ahmed Yarub Hani Al Nuaimi
committed
Update README and CMakeLists.txt
Add package name to examples
1 parent 776dfae commit 54b3d3f

File tree

3 files changed

+36
-46
lines changed

3 files changed

+36
-46
lines changed

examples/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
set(pkgName "kubernetes")
2+
13
add_subdirectory(list_pod)

kubernetes/CMakeLists.txt

Lines changed: 31 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,46 @@
1-
cmake_minimum_required (VERSION 2.6)
1+
cmake_minimum_required (VERSION 2.6...3.10.2)
22
project (CGenerator)
33

44
cmake_policy(SET CMP0063 NEW)
55

66
set(CMAKE_C_VISIBILITY_PRESET default)
77
set(CMAKE_CXX_VISIBILITY_PRESET default)
88
set(CMAKE_VISIBILITY_INLINES_HIDDEN OFF)
9-
set(CMAKE_BUILD_TYPE Debug)
9+
10+
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
1011

1112
find_package(OpenSSL)
1213

1314
if (OPENSSL_FOUND)
14-
message (STATUS "OPENSSL found")
15-
set (CMAKE_C_FLAGS "-DOPENSSL")
16-
include_directories(${OPENSSL_INCLUDE_DIR})
17-
include_directories(${OPENSSL_INCLUDE_DIRS})
18-
link_directories(${OPENSSL_LIBRARIES})
19-
message(STATUS "Using OpenSSL ${OPENSSL_VERSION}")
20-
else()
21-
message (STATUS "OpenSSL Not 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.")
2227
endif()
2328

2429
set(pkgName "kubernetes")
2530

2631
find_package(CURL 7.58.0 REQUIRED)
2732
if(CURL_FOUND)
28-
include_directories(${CURL_INCLUDE_DIR})
29-
set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} ${CURL_LIBRARIES} )
33+
include_directories(${CURL_INCLUDE_DIR})
34+
set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} ${CURL_LIBRARIES} )
3035
else(CURL_FOUND)
31-
message(FATAL_ERROR "Could not find the CURL library and development files.")
36+
message(FATAL_ERROR "Could not find the CURL library and development files.")
3237
endif()
3338

3439
set(SRCS
35-
config/kube_config_model.c
36-
config/kube_config_yaml.c
37-
config/kube_config_util.c
38-
config/kube_config.c
39-
config/incluster_config.c
40-
config/exec_provider.c
41-
config/authn_plugin/authn_plugin_util.c
42-
config/authn_plugin/authn_plugin.c
43-
watch/watch_util.c
44-
websocket/wsclient.c
45-
websocket/kube_exec.c
4640
src/list.c
4741
src/apiKey.c
4842
src/apiClient.c
4943
src/binary.c
50-
src/generic.c
5144
external/cJSON.c
5245
model/object.c
5346
model/admissionregistration_v1_service_reference.c
@@ -796,23 +789,10 @@ set(SRCS
796789
)
797790

798791
set(HDRS
799-
config/kube_config_common.h
800-
config/kube_config_model.h
801-
config/kube_config_yaml.h
802-
config/kube_config_util.h
803-
config/kube_config.h
804-
config/incluster_config.h
805-
config/exec_provider.h
806-
config/authn_plugin/authn_plugin_util.h
807-
config/authn_plugin/authn_plugin.h
808-
watch/watch_util.h
809-
websocket/wsclient.h
810-
websocket/kube_exec.h
811792
include/apiClient.h
812793
include/list.h
813794
include/binary.h
814795
include/keyValuePair.h
815-
include/generic.h
816796
external/cJSON.h
817797
model/object.h
818798
model/admissionregistration_v1_service_reference.h
@@ -1560,10 +1540,18 @@ set(HDRS
15601540

15611541
)
15621542

1563-
# Add library with project file with projectname as library name
1564-
add_library(${pkgName} SHARED ${SRCS} ${HDRS})
1543+
include(PreTarget OPTIONAL)
1544+
1545+
# Add library with project file with project name as library name
1546+
add_library(${pkgName} ${SRCS} ${HDRS})
15651547
# Link dependent libraries
1548+
if(NOT CMAKE_VERSION VERSION_LESS 3.4)
1549+
target_link_libraries(${pkgName} OpenSSL::SSL OpenSSL::Crypto)
1550+
endif()
15661551
target_link_libraries(${pkgName} ${CURL_LIBRARIES} )
1552+
1553+
include(PostTarget OPTIONAL)
1554+
15671555
#install library to destination
15681556
install(TARGETS ${pkgName} DESTINATION ${CMAKE_INSTALL_PREFIX})
15691557

@@ -1572,7 +1560,7 @@ set(SRCS "")
15721560
set(HDRS "")
15731561

15741562

1575-
## This section shows how to use the above compiled libary to compile the source files
1563+
## This section shows how to use the above compiled library to compile the source files
15761564
## set source files
15771565
#set(SRCS
15781566
# unit-tests/manual-AdmissionregistrationAPI.c
@@ -1653,12 +1641,12 @@ set(HDRS "")
16531641

16541642
## loop over all files in SRCS variable
16551643
#foreach(SOURCE_FILE ${SRCS})
1656-
# # Get only the file name from the file as add_executable doesnot support executable with slash("/")
1644+
# # Get only the file name from the file as add_executable does not support executable with slash("/")
16571645
# get_filename_component(FILE_NAME_ONLY ${SOURCE_FILE} NAME_WE)
16581646
# # Remove .c from the file name and set it as executable name
16591647
# string( REPLACE ".c" "" EXECUTABLE_FILE ${FILE_NAME_ONLY})
16601648
# # Add executable for every source file in SRCS
16611649
# add_executable(unit-${EXECUTABLE_FILE} ${SOURCE_FILE})
1662-
# # Link above created libary to executable and dependent libary curl
1650+
# # Link above created library to executable and dependent library curl
16631651
# target_link_libraries(unit-${EXECUTABLE_FILE} ${CURL_LIBRARIES} ${pkgName} )
16641652
#endforeach(SOURCE_FILE ${SRCS})

kubernetes/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ This will compile the generated code and create a library in the build folder wh
3939
mkdir build
4040
cd build
4141
// To install library to specific location, use following commands
42-
cmake -DCMAKE_INSTALL_PREFIX=/pathtolocaiton ..
42+
cmake -DCMAKE_INSTALL_PREFIX=/pathtolocation ..
4343
// for normal install use following command
4444
cmake ..
4545
make
@@ -49,14 +49,14 @@ sudo make install
4949
Considering the test/source code which uses the API is written in main.c(respective api include is written and all objects necessary are defined and created)
5050

5151
To compile main.c(considering the file is present in build folder) use following command
52-
-L - locaiton of the library(not required if cmake with normal installation is performed)
52+
-L - location of the library(not required if cmake with normal installation is performed)
5353
-l library name
5454
```bash
5555
gcc main.c -L. -lkubernetes -o main
5656
```
5757
Once compiled, you can run it with ``` ./main ```
5858

59-
Note: You don't need to specify includes for models and include folder seperately as they are path linked. You just have to import the api.h file in your code, the include linking will work.
59+
Note: You don't need to specify includes for models and include folder separately as they are path linked. You just have to import the api.h file in your code, the include linking will work.
6060

6161
## Documentation for API Endpoints
6262

0 commit comments

Comments
 (0)