| 1 |
cmake_minimum_required(VERSION 3.5) |
| 2 |
project(libnsspem C) |
| 3 |
enable_testing() |
| 4 |
|
| 5 |
# use pkg-config to detect CFLAGS and LDFLAGS |
| 6 |
find_package(PkgConfig REQUIRED) |
| 7 |
pkg_check_modules(NSS REQUIRED "nss") |
| 8 |
include_directories(${NSS_INCLUDE_DIRS}) |
| 9 |
link_directories(${NSS_LIBRARY_DIRS}) |
| 10 |
|
| 11 |
# some distros (e.g. Gentoo Linux) put <blapi.h> to a separate directory |
| 12 |
if(EXISTS "${NSS_INCLUDEDIR}/private/") |
| 13 |
include_directories("${NSS_INCLUDEDIR}/private") |
| 14 |
endif() |
| 15 |
|
| 16 |
# some distros (e.g. Fedora) put <nssck.api> to a separate directory |
| 17 |
if(EXISTS "${NSS_INCLUDEDIR}/templates/") |
| 18 |
include_directories("${NSS_INCLUDEDIR}/templates") |
| 19 |
endif() |
| 20 |
|
| 21 |
include(CheckIncludeFile) |
| 22 |
set(CMAKE_REQUIRED_INCLUDES ${NSS_INCLUDE_DIRS}) |
| 23 |
check_include_file(lowkeyti.h LOWKEYTI_H) |
| 24 |
if(LOWKEYTI_H) |
| 25 |
add_definitions(-DHAVE_LOWKEYTI_H) |
| 26 |
endif() |
| 27 |
|
| 28 |
include(CheckFunctionExists) |
| 29 |
set(CMAKE_REQUIRED_LIBRARIES nsspem nssckfw nssb freebl ${NSS_LIBRARIES}) |
| 30 |
check_function_exists(NSSCKFWSlot_GetSlotID GETSLOTID_FN) |
| 31 |
if(GETSLOTID_FN) |
| 32 |
add_definitions(-DHAVE_GETSLOTID_FN) |
| 33 |
endif() |
| 34 |
|
| 35 |
# modules used to build libnsspem.so |
| 36 |
set(MODULES |
| 37 |
anchor.c |
| 38 |
ckpemver.c |
| 39 |
constants.c |
| 40 |
pargs.c |
| 41 |
pfind.c |
| 42 |
pinst.c |
| 43 |
pobject.c |
| 44 |
prsa.c |
| 45 |
psession.c |
| 46 |
pslot.c |
| 47 |
ptoken.c |
| 48 |
rsawrapr.c |
| 49 |
util.c) |
| 50 |
|
| 51 |
# rules to create libnsspem.so |
| 52 |
add_library(nsspem SHARED ${MODULES}) |
| 53 |
target_link_libraries(${CMAKE_REQUIRED_LIBRARIES}) |
| 54 |
set_target_properties(nsspem PROPERTIES LINK_FLAGS -Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/nsspem.def) |
| 55 |
|
| 56 |
# install libnsspem.so |
| 57 |
include(GNUInstallDirs) |
| 58 |
install(TARGETS nsspem DESTINATION ${CMAKE_INSTALL_LIBDIR}) |