Skip to content

Commit

Permalink
Experimental: added CMake-based installer.
Browse files Browse the repository at this point in the history
  • Loading branch information
tfpf committed Sep 23, 2023
1 parent 14f6e24 commit 356fa95
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
30 changes: 30 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cmake_policy(SET CMP0048 NEW)
project(hdrbg VERSION 1.0.0 DESCRIPTION "C implementation of Hash DRBG")
cmake_minimum_required(VERSION 3.22)
include(GNUInstallDirs)

set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED TRUE)

file(GLOB sources lib/*.c)
list(FILTER sources EXCLUDE REGEX ".*py.*")
add_library(hdrbg SHARED ${sources})
target_include_directories(hdrbg PRIVATE include)
configure_file(hdrbg.pc.in hdrbg.pc @ONLY)

set_target_properties(hdrbg PROPERTIES
PUBLIC_HEADER include/hdrbg.h
SOVERSION 1
VERSION ${PROJECT_VERSION}
)
target_compile_options(hdrbg PRIVATE -O2 -Wall -Wextra -fstrict-aliasing)

install(TARGETS hdrbg
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(FILES ${CMAKE_BINARY_DIR}/hdrbg.pc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig
)
12 changes: 12 additions & 0 deletions hdrbg.pc.in
Original file line number Diff line number Diff line change
@@ -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} -lhdrbg
Cflags: -I${includedir}

0 comments on commit 356fa95

Please sign in to comment.