From d9c1f06ec61a3c2692e0851a33de595d84b31413 Mon Sep 17 00:00:00 2001 From: AndreasV Date: Tue, 14 Feb 2023 21:40:18 +0100 Subject: [PATCH 01/16] wip --- CMakeLists.txt | 33 +++++++++++++++++++++++++++++++++ src/mbox.c | 1 + src/random.c | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..b29205c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.15) +project(libfutils VERSION 1.0) + +set(DEFS "_FILE_OFFSET_BITS=64") + +set(LIB_SOURCES + src/dynmbox.c + src/hash.c + src/mbox.c + src/systimetools.c + src/timetools.c + src/random.c + src/varint.c +) + +add_library(futils ${LIB_SOURCES}) +add_library(futils_compiler_flags INTERFACE) +target_compile_features(futils_compiler_flags INTERFACE cxx_std_11) + +option(BUILD_SHARED_LIBS "Build using shared libraries" ON) + +target_include_directories(futils PUBLIC + $ + $ +) + +target_compile_definitions(futils PRIVATE ${DEFS}) + +if(WIN32) + target_link_libraries(futils ws2_32) +endif() + +target_link_libraries(futils ulog futils_compiler_flags) \ No newline at end of file diff --git a/src/mbox.c b/src/mbox.c index 4f709cc..46c4c20 100644 --- a/src/mbox.c +++ b/src/mbox.c @@ -29,6 +29,7 @@ * ******************************************************************************/ +#include #include #include #include diff --git a/src/random.c b/src/random.c index 4ec48e6..7f56c0a 100644 --- a/src/random.c +++ b/src/random.c @@ -64,7 +64,7 @@ ULOG_DECLARE_TAG(futils_random); #elif defined(__GNUC__) && defined(__GLIBC__) # define thread_local __thread # define HAVE_THREAD_LOCAL 1 -#elif defined(_WIN32) +#elif defined(_WIN32) && (!defined(__GNUC__)) # define thread_local __declspec(thread) # define HAVE_THREAD_LOCAL 1 #else From 75a5cb8526bc7c5ded321b26fb2b6ad3a2bb4019 Mon Sep 17 00:00:00 2001 From: Andreas Viborg Date: Thu, 16 Feb 2023 19:24:57 +0100 Subject: [PATCH 02/16] wip --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b29205c..1f65733 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,4 +30,7 @@ if(WIN32) target_link_libraries(futils ws2_32) endif() -target_link_libraries(futils ulog futils_compiler_flags) \ No newline at end of file +target_link_libraries(futils + ulog + futils_compiler_flags +) \ No newline at end of file From bdaa9c524a5de13995961f5f10ba2406a61bb96c Mon Sep 17 00:00:00 2001 From: Andreas Viborg Date: Sun, 26 Feb 2023 12:56:39 +0100 Subject: [PATCH 03/16] wip --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f65733..234b2ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,9 @@ add_library(futils_compiler_flags INTERFACE) target_compile_features(futils_compiler_flags INTERFACE cxx_std_11) option(BUILD_SHARED_LIBS "Build using shared libraries" ON) +set_target_properties(h264 PROPERTIES + POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} +) target_include_directories(futils PUBLIC $ From 83dda2b95a55c708e0792acfc46a7d6878671283 Mon Sep 17 00:00:00 2001 From: Andreas Viborg Date: Sun, 26 Feb 2023 20:26:22 +0100 Subject: [PATCH 04/16] wip --- CMakeLists.txt | 15 +++++++++++++-- src/string.c | 1 + src/systimetools.c | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 234b2ba..0471daa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,21 +4,32 @@ project(libfutils VERSION 1.0) set(DEFS "_FILE_OFFSET_BITS=64") set(LIB_SOURCES - src/dynmbox.c src/hash.c src/mbox.c src/systimetools.c src/timetools.c src/random.c src/varint.c + src/dynmbox.c ) +if(UNIX) + set(LIB_SOURCES + ${LIB_SOURCES} + src/fdutils.c + src/fs.c + src/safew.c + src/synctools.c + src/inotify.c + src/string.c + ) +endif() add_library(futils ${LIB_SOURCES}) add_library(futils_compiler_flags INTERFACE) target_compile_features(futils_compiler_flags INTERFACE cxx_std_11) option(BUILD_SHARED_LIBS "Build using shared libraries" ON) -set_target_properties(h264 PROPERTIES +set_target_properties(futils PROPERTIES POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} ) diff --git a/src/string.c b/src/string.c index 404a6d8..0033c8a 100644 --- a/src/string.c +++ b/src/string.c @@ -31,6 +31,7 @@ #include "futils/string.h" +#include #include #include #include diff --git a/src/systimetools.c b/src/systimetools.c index df0bd10..25150d0 100644 --- a/src/systimetools.c +++ b/src/systimetools.c @@ -36,6 +36,7 @@ #endif #include +#include #include #include #include "futils/systimetools.h" From ea6c1ae888f8bf105c08b334716c39ce97b57769 Mon Sep 17 00:00:00 2001 From: Oscar Sjoberg Date: Tue, 28 Feb 2023 09:39:22 +0100 Subject: [PATCH 05/16] updating the local CMakeLists.txt file --- CMakeLists.txt | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f65733..be3e214 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.15) -project(libfutils VERSION 1.0) +project(futils VERSION 1.0) set(DEFS "_FILE_OFFSET_BITS=64") @@ -11,26 +11,33 @@ set(LIB_SOURCES src/timetools.c src/random.c src/varint.c + src/fdutils.c ) -add_library(futils ${LIB_SOURCES}) -add_library(futils_compiler_flags INTERFACE) -target_compile_features(futils_compiler_flags INTERFACE cxx_std_11) +add_library(${PROJECT_NAME} ${LIB_SOURCES}) +target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_11) option(BUILD_SHARED_LIBS "Build using shared libraries" ON) -target_include_directories(futils PUBLIC +target_include_directories(${PROJECT_NAME} PUBLIC $ $ ) -target_compile_definitions(futils PRIVATE ${DEFS}) +target_compile_definitions(${PROJECT_NAME} PRIVATE ${DEFS}) if(WIN32) - target_link_libraries(futils ws2_32) + target_link_libraries(${PROJECT_NAME} ws2_32) endif() -target_link_libraries(futils - ulog - futils_compiler_flags -) \ No newline at end of file +target_link_libraries(${PROJECT_NAME} + ulog +) + +install(TARGETS ${PROJECT_NAME} + EXPORT ${PROJECT_NAME}-targets + PUBLIC_HEADER DESTINATION include + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin +) From 59b8f7f2f3a0dc2b48637bd9b2122c7c8ab1b9c6 Mon Sep 17 00:00:00 2001 From: Oscar Sjoberg Date: Tue, 28 Feb 2023 10:05:35 +0100 Subject: [PATCH 06/16] updating the local CMakeLists.txt file From 5f2bb39a05c0b6bac68f0b103b450255913ba088 Mon Sep 17 00:00:00 2001 From: Oscar Sjoberg Date: Wed, 1 Mar 2023 17:33:37 +0100 Subject: [PATCH 07/16] able to do correct install --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index be3e214..4c8d975 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,14 @@ cmake_minimum_required(VERSION 3.15) project(futils VERSION 1.0) + +# checks if set up rpath exists for install +if(COMMAND set_up_rpath) + set_up_rpath() +else() + message("Set up rpath not defined!") +endif() + set(DEFS "_FILE_OFFSET_BITS=64") set(LIB_SOURCES @@ -31,6 +39,7 @@ if(WIN32) endif() target_link_libraries(${PROJECT_NAME} + PRIVATE ulog ) From 7265476a179394b9e2ab796a159242a6118fd3bf Mon Sep 17 00:00:00 2001 From: Oscar Sjoberg Date: Wed, 1 Mar 2023 17:34:49 +0100 Subject: [PATCH 08/16] wip From 2f1b23dc75b9366a584bbb347f9920932b261a4a Mon Sep 17 00:00:00 2001 From: Oscar Sjoberg Date: Thu, 2 Mar 2023 08:13:33 +0100 Subject: [PATCH 09/16] updating windows cmake --- CMakeLists.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c8d975..28135d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,13 +35,17 @@ target_include_directories(${PROJECT_NAME} PUBLIC target_compile_definitions(${PROJECT_NAME} PRIVATE ${DEFS}) if(WIN32) - target_link_libraries(${PROJECT_NAME} ws2_32) -endif() - target_link_libraries(${PROJECT_NAME} PRIVATE + ws2_32 + ulog + ) +else() +target_link_libraries(${PROJECT_NAME} + PRIVATE ulog -) + ) +endif() install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets From 0c5928f7f049a81e7ff77a4d78ae37f16d9ebc60 Mon Sep 17 00:00:00 2001 From: Oscar Sjoberg Date: Thu, 2 Mar 2023 08:28:40 +0100 Subject: [PATCH 10/16] adding windows defines --- src/fdutils.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/fdutils.c b/src/fdutils.c index 3ebea93..6b303f1 100644 --- a/src/fdutils.c +++ b/src/fdutils.c @@ -35,6 +35,14 @@ #include "futils/fdutils.h" +#ifdef _WIN32 +#define FD_CLOEXEC 1 +#define F_GETFD 1 /**< Get file descriptor flags */ +#define F_SETFD 2 /**< Set file descriptor flags */ +#define F_GETFL 3 /**< Get file status flags */ +#define F_SETFL 4 /**< Set file status flags */ +#endif + int fd_set_close_on_exec(int fd) { int old, ret; From 8f0484c91997b7281a21dac745ba8b35969ded8b Mon Sep 17 00:00:00 2001 From: Oscar Sjoberg Date: Thu, 2 Mar 2023 15:57:57 +0100 Subject: [PATCH 11/16] moving rpath --- CMakeLists.txt | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 597be89..9d8ecc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,8 @@ cmake_minimum_required(VERSION 3.15) project(futils VERSION 1.0) - -# checks if set up rpath exists for install -if(COMMAND set_up_rpath) - set_up_rpath() -else() - message("Set up rpath not defined!") -endif() - set(DEFS "_FILE_OFFSET_BITS=64") - list(APPEND LIB_SOURCES src/hash.c src/mbox.c @@ -33,6 +24,10 @@ if(UNIX) list(APPEND LIB_SOURCES src/string.c ) + else() + list(APPEND LIB_SOURCES + src/dynmbox.c + ) endif() else() @@ -61,6 +56,13 @@ endif() add_library(${PROJECT_NAME} ${LIB_SOURCES}) target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_11) +# checks if set up rpath exists for install +if(COMMAND set_up_rpath) + set_up_rpath() +else() + message("Set up rpath not defined!") +endif() + option(BUILD_SHARED_LIBS "Build using shared libraries" ON) set_target_properties(futils PROPERTIES POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} From dbef76c316b96a31eba84e2b96d569259af95450 Mon Sep 17 00:00:00 2001 From: Oscar Sjoberg Date: Thu, 2 Mar 2023 16:05:30 +0100 Subject: [PATCH 12/16] correcting cmake From e9dfc9a785948185892be6dbe5c799a6b200d60d Mon Sep 17 00:00:00 2001 From: Andreas Viborg Date: Thu, 2 Mar 2023 18:07:44 +0100 Subject: [PATCH 13/16] wip --- CMakeLists.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 28135d4..cf96ef9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,15 +12,25 @@ endif() set(DEFS "_FILE_OFFSET_BITS=64") set(LIB_SOURCES - src/dynmbox.c src/hash.c src/mbox.c src/systimetools.c src/timetools.c src/random.c src/varint.c - src/fdutils.c + src/dynmbox.c ) +if(UNIX) + set(LIB_SOURCES + ${LIB_SOURCES} + src/fdutils.c + src/fs.c + src/safew.c + src/synctools.c + src/inotify.c + src/string.c + ) +endif() add_library(${PROJECT_NAME} ${LIB_SOURCES}) target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_11) From 806204e2a5552d455c8ccc9fab3106c6bad854a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20Sj=C3=B6berg?= Date: Fri, 3 Mar 2023 11:22:35 +0100 Subject: [PATCH 14/16] pulling correct dll when installing windows From 790ba2547e8bcb4497768d3314388756442f2ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20Sj=C3=B6berg?= Date: Fri, 3 Mar 2023 11:59:47 +0100 Subject: [PATCH 15/16] pulling correct dll when installing windows From 341ba8ae3130a8f0b73fbd4941a0d0a940d61cc9 Mon Sep 17 00:00:00 2001 From: Andreas Viborg Date: Tue, 14 Mar 2023 09:27:39 +0100 Subject: [PATCH 16/16] use shared libs --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d8ecc1..1b78cea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,7 @@ else() ) endif() -add_library(${PROJECT_NAME} ${LIB_SOURCES}) +add_library(${PROJECT_NAME} SHARED ${LIB_SOURCES}) target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_11) # checks if set up rpath exists for install @@ -64,7 +64,7 @@ else() endif() option(BUILD_SHARED_LIBS "Build using shared libraries" ON) -set_target_properties(futils PROPERTIES +set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} )