# HG changeset patch # User Paper # Date 1729730670 14400 # Node ID 6e0eb3aa12aba19a81025c1584ed92783353ce08 # Parent 945d410803f8d46d76127e59fb3923513c5e89e7 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 diff -r 945d410803f8 -r 6e0eb3aa12ab .hgignore --- /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/ diff -r 945d410803f8 -r 6e0eb3aa12ab CMakeLists.txt --- /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 diff -r 945d410803f8 -r 6e0eb3aa12ab include/vec/vec.h --- 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 diff -r 945d410803f8 -r 6e0eb3aa12ab src/vec.c --- /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" diff -r 945d410803f8 -r 6e0eb3aa12ab vec.pc.in --- /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