Aligning it with other C based projects.
Signed-off-by: Petr Štetiar <ynezz@true.cz>
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
+
+PROJECT(libnl-tiny C)
+INCLUDE(GNUInstallDirs)
+
+INCLUDE_DIRECTORIES(include)
+
+ADD_DEFINITIONS(-Wall -Werror)
+STRING(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
+
+ADD_LIBRARY(nl-tiny SHARED
+ attr.c
+ cache.c
+ cache_mngt.c
+ error.c
+ genl.c
+ genl_ctrl.c
+ genl_family.c
+ genl_mngt.c
+ handlers.c
+ msg.c
+ nl.c
+ object.c
+ socket.c
+ unl.c
+)
+
+CONFIGURE_FILE(
+ "${CMAKE_CURRENT_SOURCE_DIR}/libnl-tiny.pc.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/libnl-tiny.pc"
+ @ONLY
+)
+
+INSTALL(TARGETS nl-tiny LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+INSTALL(
+ DIRECTORY ${CMAKE_SOURCE_DIR}/include/
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libnl-tiny
+ FILES_MATCHING PATTERN "*.h"
+)
+++ /dev/null
-CC=gcc
-WFLAGS=-Wall
-CFLAGS=-O2
-INCLUDES=-Iinclude
-
-LIBNAME=libnl-tiny.so
-
-all: $(LIBNAME)
-
-%.o: %.c
- $(CC) $(WFLAGS) -c -o $@ $(INCLUDES) $(CFLAGS) $<
-
-LIBNL_OBJ=nl.o handlers.o msg.o attr.o cache.o cache_mngt.o object.o socket.o error.o
-GENL_OBJ=genl.o genl_family.o genl_ctrl.o genl_mngt.o unl.o
-
-$(LIBNAME): $(LIBNL_OBJ) $(GENL_OBJ)
- $(CC) $(CFLAGS) -Wl,-Bsymbolic-functions -shared -o $@ $^
+++ /dev/null
-prefix=/usr
-exec_prefix=/usr
-libdir=${exec_prefix}/lib
-includedir=${prefix}/include/libnl-tiny
-
-Name: libnl-tiny
-Description: Convenience library for netlink sockets
-Version: 2.0
-Libs: -L${libdir} -lnl-tiny
-Cflags: -I${includedir}
--- /dev/null
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}
+libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/libnl-tiny
+
+Name: libnl-tiny
+Description: Convenience library for netlink sockets
+Version: 2.0
+Libs: -L${libdir} -lnl-tiny
+Cflags: -I${includedir}