Skip to content

Commit

Permalink
Added library to example
Browse files Browse the repository at this point in the history
  • Loading branch information
George Constantine authored and George Constantine committed Jul 12, 2021
1 parent fd06824 commit 6f3a138
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 12 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ cmake_minimum_required(VERSION 3.13)

project(cmake-issue VERSION 1.0 DESCRIPTION "Static target issue" LANGUAGES C)

add_subdirectory(lib)


add_executable(main-dynamic main.c)
target_link_libraries(main-dynamic uuid)
target_link_libraries(main-dynamic uuid libcmake.a)
add_dependencies(main-dynamic libcmake)

add_executable(main-static main.c)
target_link_libraries(main-static uuid -static)
target_link_libraries(main-static uuid libcmake.a -static)
add_dependencies(main-static libcmake)
5 changes: 5 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.13)

project(libcmake VERSION 1.0 DESCRIPTION "Static target issue - Library" LANGUAGES C)

add_library(libcmake lib.c)
13 changes: 13 additions & 0 deletions lib/lib.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <uuid/uuid.h>
#include <stdio.h>

void PrintUUID(){

uuid_t some_uuid;
char uuid_str[40];

uuid_generate(some_uuid);
uuid_unparse(some_uuid, uuid_str);

printf("UUID: %s\n", uuid_str);
}
6 changes: 6 additions & 0 deletions lib/lib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef LIB_H
#define LIB_H

void PrintUUID();

#endif //LIB_H
12 changes: 2 additions & 10 deletions main.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
#include <uuid/uuid.h>
#include <stdio.h>

#include "lib/lib.h"

int main(){
uuid_t some_uuid;
char uuid_str[40];

uuid_generate(some_uuid);
uuid_unparse(some_uuid, uuid_str);

printf("UUID: %s\n", uuid_str);
PrintUUID();
return 0;
}

0 comments on commit 6f3a138

Please sign in to comment.