changeset 8:6e0eb3aa12ab

build: add files to build vec as an external library this is most definitely a double-edged sword, but you can do it now if you *really* want to
author Paper <paper@tflc.us>
date Wed, 23 Oct 2024 20:44:30 -0400
parents 945d410803f8
children d1d5d767004c
files .hgignore CMakeLists.txt include/vec/vec.h src/vec.c vec.pc.in
diffstat 5 files changed, 79 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Wed Oct 23 20:44:30 2024 -0400
@@ -0,0 +1,42 @@
+syntax: glob
+
+# stupid OS X things
+.DS_Store
+._*
+
+# Prerequisites
+*.d
+
+# Compiled Object files
+*.slo
+*.lo
+*.o
+*.obj
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Compiled Dynamic libraries
+*.so
+*.dylib
+*.dll
+
+# Fortran module files
+*.mod
+*.smod
+
+# Compiled Static libraries
+*.lai
+*.la
+*.a
+*.lib
+
+# Executables
+*.exe
+*.out
+
+syntax: regexp
+
+# Build dir
+^build/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CMakeLists.txt	Wed Oct 23 20:44:30 2024 -0400
@@ -0,0 +1,21 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(vec VERSION 1.0.0 DESCRIPTION "a tiny C99 SIMD vector library")
+
+add_library(vec SHARED src/vec.c)
+
+set_target_properties(vec PROPERTIES PUBLIC_HEADER include/vec/vec.h)
+
+target_include_directories(vec PRIVATE include)
+
+# Installing
+
+include(GNUInstallDirs)
+
+install(TARGETS vec
+    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+
+# pkg-config
+configure_file(vec.pc.in vec.pc @ONLY)
+install(FILES ${CMAKE_BINARY_DIR}/vec.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
\ No newline at end of file
--- a/include/vec/vec.h	Wed Oct 23 20:07:08 2024 -0400
+++ b/include/vec/vec.h	Wed Oct 23 20:44:30 2024 -0400
@@ -64,7 +64,7 @@
 #endif
 
 /* Allow users to define all of the symbols externally in
- * one translation unit. */
+ * one translation unit, or as a shared library. */
 #ifdef VEC_EXTERN
 # ifdef VEC_EXTERN_DEFINE
 #  define VEC_FUNC_KEYWORDS extern inline
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/vec.c	Wed Oct 23 20:44:30 2024 -0400
@@ -0,0 +1,3 @@
+#define VEC_EXTERN
+#define VEC_EXTERN_DEFINE
+#include "vec/vec.h"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vec.pc.in	Wed Oct 23 20:44:30 2024 -0400
@@ -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} -lvec
+Cflags: -I${includedir} -DVEC_EXTERN