forked from liblogicalaccess/liblogicalaccess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
153 lines (123 loc) · 6.11 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
cmake_minimum_required(VERSION 3.3)
project(logicalaccess)
# Global C++ configuration
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Some build options. Either configured through CMake directly, or fed
# by Conan options. It is important, for consistency, to keep those defaults
# in sync with conafile.py
set(LLA_BUILD_IKS TRUE CACHE BOOL "Build Islog Key Server support")
set(LLA_BUILD_PKCS TRUE CACHE BOOL "Build PKCS11 support")
set(LLA_BUILD_UNITTEST FALSE CACHE BOOL "Build unittests")
include(GenerateExportHeader)
# Perform Conan basic setup to import targets etc
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# We define a macro that will help us properly generate and install
# export headers for all libraries that are part of LLA.
# This macro should be called with the following preconditions:
# + A variable HEADER_RELATIVE_INSTALL_DIR should be defined and point to a
# valid RELATIVE path for export header installation.
# + A single argument should be provide, which will be used as part of the export
# macro name. If LLA_CORE is passed, the export macro name is LLA_CORE_API.
#
# The generated header is XXX_api.hpp, where XXX is lowered-case of the first parameter
# of the macro.
#
# NOTE THAT THIS MACRO NEEDS ${PROJECT_NAME} TO EVALUATE TO A TARGET NAME
macro(LLA_GENERATE_EXPORTS)
string(TOLOWER ${ARGV0} _LOWERCASE_LIB_NAME)
set(_EXPORT_FILE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${_LOWERCASE_LIB_NAME}_api.hpp")
generate_export_header(${PROJECT_NAME}
EXPORT_MACRO_NAME "${ARGV0}_API"
EXPORT_FILE_NAME ${_EXPORT_FILE_PATH})
target_compile_definitions(${PROJECT_NAME} PRIVATE "${_LOWERCASE_LIB_NAME}_EXPORTS=1")
# Disable some MSVC warning we don't care about.
if (MSVC)
target_compile_options(${PROJECT_NAME} PUBLIC "/wd4251")
else()
target_compile_options(${PROJECT_NAME} PUBLIC -W -Wall -Wno-unused-parameter -Wsign-conversion)
if (CMAKE_BUILD_TYPE MATCHES "Debug")
target_compile_options(logicalaccess PUBLIC -g)
endif()
endif ()
# HEADER_INSTALL_DIR must be defined before calling the macro.
install(FILES ${_EXPORT_FILE_PATH} DESTINATION ${HEADER_RELATIVE_INSTALL_DIR})
endmacro()
#### We dont use this for LLA_CORE macro.
file(GLOB LLA_RESOURCE_RC ${CMAKE_CURRENT_SOURCE_DIR}/vc++/resource.rc)
file(GLOB_RECURSE LLA_NATIVE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
file(GLOB_RECURSE LLA_NATIVE_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp")
# Those 2 are under plugin but they arent plugins, they are
# required for LLA to link properly.
add_subdirectory(plugins/logicalaccess/plugins/llacommon)
add_subdirectory(plugins/logicalaccess/plugins/crypto)
# Create logicalaccess target
set(LIBLOGICALACCESS_LIBRARY logicalaccess)
add_library(logicalaccess SHARED ${LLA_NATIVE_SOURCES} ${LLA_NATIVE_HEADERS} ${LLA_RESOURCE_RC})
# We rely on CMake to generate an export macro for the target.
generate_export_header(logicalaccess
EXPORT_MACRO_NAME LLA_CORE_API
EXPORT_FILE_NAME "${CMAKE_CURRENT_SOURCE_DIR}/include/logicalaccess/lla_core_api.hpp")
target_compile_definitions(logicalaccess PRIVATE logicalaccess_EXPORTS=1)
if (LLA_BOOST_ASIO_HAS_STD_STRING_VIEW)
# Work around a boost / clang issue with include to string/view.
# See https://github.com/boostorg/asio/issues/82
target_compile_definitions(logicalaccess PUBLIC BOOST_ASIO_HAS_STD_STRING_VIEW=1)
endif()
# Variable containing external library that LLA needs to link against
set(LLA_ADDITIONAL_LIBRARIES_TO_LINK_AGAINST)
if (UNIX AND NOT ANDROID)
target_compile_options(logicalaccess PUBLIC -W -Wall -Wno-unused-parameter)
list(APPEND LLA_ADDITIONAL_LIBRARIES_TO_LINK_AGAINST dl pthread)
endif ()
target_link_libraries(logicalaccess PUBLIC
llacommon
logicalaccess-cryptolib
CONAN_PKG::openssl
${LLA_ADDITIONAL_LIBRARIES_TO_LINK_AGAINST}
CONAN_PKG::boost
CONAN_PKG::nlohmann_json
)
# Wrong, fix /plugins/
target_include_directories(logicalaccess PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include)
if (CMAKE_BUILD_TYPE MATCHES "Debug")
target_compile_options(logicalaccess PUBLIC -O0 -g)
endif()
install(TARGETS ${LIBLOGICALACCESS_LIBRARY}
RUNTIME DESTINATION bin/${LIB_SUFFIX}
LIBRARY DESTINATION lib/${LIB_SUFFIX}
ARCHIVE DESTINATION lib/${LIB_SUFFIX})
if (MSVC)
#Enable PDB for release
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
install(FILES $<TARGET_PDB_FILE:${PROJECT_NAME}> DESTINATION pdb/${LIB_SUFFIX} OPTIONAL)
SET(VERSION_PRODUCTNAME_VALUE "Liblogicalaccess")
SET(VERSION_PROJECT_FILE_DESCRIPTION_VALUE "${VERSION_PRODUCTNAME_VALUE}\ (${TARGET_ARCH})")
target_compile_definitions(logicalaccess PUBLIC -DVERSION_PRODUCTNAME_VALUE="${VERSION_PRODUCTNAME_VALUE}" -DVERSION_PROJECT_FILE_DESCRIPTION_VALUE="${VERSION_PROJECT_FILE_DESCRIPTION_VALUE}" -DVERSION_FILE_AND_PRODUCT_VALUE_STRING="${LIBLOGICALACCESS_VERSION_STRING}" -DVERSION_FILE_AND_PRODUCT_VALUE=${LIBLOGICALACCESS_WINDOWS_VERSION})
endif ()
set_target_properties(${LIBLOGICALACCESS_LIBRARY} PROPERTIES VERSION ${LIBLOGICALACCESS_VERSION_STRING})
set_target_properties(${LIBLOGICALACCESS_LIBRARY} PROPERTIES LINKER_LANGUAGE CXX)
if (LLA_BUILD_IKS)
add_subdirectory(plugins/logicalaccess/plugins/iks)
endif ()
add_subdirectory(plugins/logicalaccess/plugins/cards)
add_subdirectory(plugins/logicalaccess/plugins/readers)
if (LLA_BUILD_PKCS)
add_subdirectory(plugins/logicalaccess/plugins/pkcs)
endif ()
if (LLA_BUILD_UNITTEST)
enable_testing()
add_subdirectory(tests)
endif ()
add_subdirectory(samples/basic)
if (NOT DEFINED SYSCONF_INSTALL_DIR)
set(SYSCONF_INSTALL_DIR res)
endif ()
install(FILES liblogicalaccess.config DESTINATION ${SYSCONF_INSTALL_DIR})
# This perform the "real installation" of header files.
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/logicalaccess DESTINATION include/)