aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2024-05-13 14:33:09 -0500
committerMatt Strapp <matt@mattstrapp.net>2024-05-13 14:33:09 -0500
commit0d7386c7529dc106dc12827ce0f2dee91c3945c2 (patch)
tree3070f83eb7f8990d61e21236caa3137203d2b5fa
parentAdd versioning to CMake and Meson (diff)
downloadlocusts-0d7386c7529dc106dc12827ce0f2dee91c3945c2.tar
locusts-0d7386c7529dc106dc12827ce0f2dee91c3945c2.tar.gz
locusts-0d7386c7529dc106dc12827ce0f2dee91c3945c2.tar.bz2
locusts-0d7386c7529dc106dc12827ce0f2dee91c3945c2.tar.lz
locusts-0d7386c7529dc106dc12827ce0f2dee91c3945c2.tar.xz
locusts-0d7386c7529dc106dc12827ce0f2dee91c3945c2.tar.zst
locusts-0d7386c7529dc106dc12827ce0f2dee91c3945c2.zip
Add a C file to make C compilers actually build this into a shared object
Signed-off-by: Matt Strapp <matt@mattstrapp.net>
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt17
-rwxr-xr-xconfigure2
-rw-r--r--configure.ac2
-rw-r--r--include/locusts.h2
-rw-r--r--meson.build10
-rw-r--r--src/locusts.c3
6 files changed, 26 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8f770a0..e5e8927 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,7 +3,7 @@ project(libocusts VERSION 1.0.0 DESCRIPTION "A completely normal C library" LANG
include(GNUInstallDirs)
-add_library(objlib OBJECT include/locusts.h)
+add_library(objlib OBJECT src/locusts.c)
target_include_directories(objlib PUBLIC include)
set_target_properties(objlib PROPERTIES LINKER_LANGUAGE C)
@@ -11,15 +11,26 @@ add_library(ocusts SHARED $<TARGET_OBJECTS:objlib> include/locusts.h)
target_link_libraries(ocusts PUBLIC objlib)
set_target_properties(ocusts PROPERTIES LINKER_LANGUAGE C)
set_target_properties(ocusts PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
+set_target_properties(ocusts PROPERTIES PUBLIC_HEADER include/locusts.h)
add_library(ocusts_static STATIC $<TARGET_OBJECTS:objlib> include/locusts.h)
target_link_libraries(ocusts_static PUBLIC objlib)
set_target_properties(ocusts_static PROPERTIES LINKER_LANGUAGE C)
+set_target_properties(ocusts_static PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
+set_target_properties(ocusts_static PROPERTIES OUTPUT_NAME ocusts)
# Make autoconf and cmake agree with each other
set(prefix ${CMAKE_INSTALL_PREFIX})
-set(libdir $\${prefix}/${CMAKE_INSTALL_LIBDIR})
+set(libdir \${prefix}/${CMAKE_INSTALL_LIBDIR})
set(includedir \${prefix}/${CMAKE_INSTALL_INCLUDEDIR})
set(VERSION ${PROJECT_VERSION})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ocusts.pc.in ${CMAKE_CURRENT_BINARY_DIR}/ocusts.pc @ONLY)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ocusts.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) \ No newline at end of file
+install(
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/ocusts.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
+)
+install(
+ TARGETS ocusts ocusts_static
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+) \ No newline at end of file
diff --git a/configure b/configure
index 627bc2a..09f32b3 100755
--- a/configure
+++ b/configure
@@ -616,7 +616,7 @@ PACKAGE_STRING='libocusts 1.0.0'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
-ac_unique_file="include/locusts.h"
+ac_unique_file="src/locusts.c"
# Factoring default headers for most tests.
ac_includes_default="\
#include <stddef.h>
diff --git a/configure.ac b/configure.ac
index c70a7e0..bf77830 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
AC_INIT([libocusts], [1.0.0])
-AC_CONFIG_SRCDIR([include/locusts.h])
+AC_CONFIG_SRCDIR([src/locusts.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIRS([m4])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
diff --git a/include/locusts.h b/include/locusts.h
index 7d03539..870a0ad 100644
--- a/include/locusts.h
+++ b/include/locusts.h
@@ -11,7 +11,7 @@ Introduces locusts into your codebase.
Note: locusts are not included with installing this library. Please source your
own.
*/
-void introduce_locusts(void) { return; }
+void introduce_locusts(void);
#ifdef __cplusplus
}
diff --git a/meson.build b/meson.build
index 7afb496..c38fa14 100644
--- a/meson.build
+++ b/meson.build
@@ -1,12 +1,14 @@
project('locusts', 'c', version: '1.0.0', default_options: ['warning_level=3'])
-source = 'include/locusts.h'
+source = 'src/locusts.c'
+header = 'include/locusts.h'
+includes = include_directories('include')
-lib = library('ocusts', source, install: true, version: meson.project_version(), soversion: '1')
+lib = library('ocusts', source, include_directories: includes, install: true, version: meson.project_version(), soversion: '1')
-project_dep =declare_dependency(include_directories: include_directories('include'))
+project_dep =declare_dependency(include_directories: includes)
-install_headers(source)
+install_headers(header)
pkg = import('pkgconfig')
pkg.generate(lib, description: 'A completely normal C library')
diff --git a/src/locusts.c b/src/locusts.c
new file mode 100644
index 0000000..4f21f0c
--- /dev/null
+++ b/src/locusts.c
@@ -0,0 +1,3 @@
+#include "locusts.h"
+
+void introduce_locusts(void) { return; } \ No newline at end of file