From ce14270d6a876a2e6e7a23ff89466cee52fc7b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Val=C3=AD=C4=8Dek?= Date: Sat, 16 May 2020 23:32:17 +0200 Subject: [PATCH] Testing version --- .idea/.gitignore | 6 ++++++ .idea/.name | 1 + .idea/misc.xml | 4 ++++ .idea/modules.xml | 8 ++++++++ .idea/test-shared-library.iml | 2 ++ CMakeLists.txt | 24 ++++++++++++++++++++++++ test.c | 7 +++++++ test_shared_library.c | 9 +++++++++ test_shared_library.h | 6 ++++++ test_shared_library.pc.in | 12 ++++++++++++ 10 files changed, 79 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/.name create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/test-shared-library.iml create mode 100644 CMakeLists.txt create mode 100644 test.c create mode 100644 test_shared_library.c create mode 100644 test_shared_library.h create mode 100644 test_shared_library.pc.in diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..8bf4d45 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,6 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..9d49873 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +test_shared_library \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..79b3c94 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..cde05a3 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/test-shared-library.iml b/.idea/test-shared-library.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/.idea/test-shared-library.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..77c2d8a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.9) +project(test_shared_library LANGUAGES C VERSION 1.0.1 DESCRIPTION "Shared C Library for testin") +include(GNUInstallDirs) +add_library(test_shared_library SHARED test_shared_library.c test_shared_library.h) +set(CMAKE_C_STANDARD 99) + +set_target_properties(test_shared_library PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION 1 + PUBLIC_HEADER test_shared_library.h) + +configure_file(test_shared_library.pc.in test_shared_library.pc @ONLY) + +target_include_directories(test_shared_library PRIVATE .) + +install(TARGETS test_shared_library + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES ${CMAKE_BINARY_DIR}/test_shared_library.pc + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) + + +add_executable(test test.c) +target_link_libraries(test test_shared_library) \ No newline at end of file diff --git a/test.c b/test.c new file mode 100644 index 0000000..51a6c2e --- /dev/null +++ b/test.c @@ -0,0 +1,7 @@ +#include +#include "test_shared_library.h" + +int main(void){ + printf("Hello result: %d\n", hello(12)); + return 0; +} \ No newline at end of file diff --git a/test_shared_library.c b/test_shared_library.c new file mode 100644 index 0000000..e3b9e19 --- /dev/null +++ b/test_shared_library.c @@ -0,0 +1,9 @@ +#include "test_shared_library.h" + +#include +#include + +int hello(int param) { + printf("Hello, World!\n"); + return param; +} diff --git a/test_shared_library.h b/test_shared_library.h new file mode 100644 index 0000000..2d8e1da --- /dev/null +++ b/test_shared_library.h @@ -0,0 +1,6 @@ +#ifndef TEST_SHARED_LIBRARY_TEST_SHARED_LIBRARY_H +#define TEST_SHARED_LIBRARY_TEST_SHARED_LIBRARY_H + +int hello(int param); + +#endif //TEST_SHARED_LIBRARY_TEST_SHARED_LIBRARY_H diff --git a/test_shared_library.pc.in b/test_shared_library.pc.in new file mode 100644 index 0000000..5a62672 --- /dev/null +++ b/test_shared_library.pc.in @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ + +Name: @PROJECT_NAME@ +Description: @PROJECT_DESCRIPTION@ +Version: @PROJECT_VERSION@ + +Requires: +Libs: -L${libdir} -ltest_shared_library +Cflags: -I${includedir} \ No newline at end of file