-
-
Notifications
You must be signed in to change notification settings - Fork 97
/
CMakeLists.txt
141 lines (107 loc) · 3.88 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
cmake_minimum_required (VERSION 2.8.12)
project (licensepp CXX)
option (test "Build all tests" OFF)
option (BUILD_SHARED_LIBS "build shared libraries" ON)
option (travis "Travis CI" OFF)
set (EXTERNAL_INCLUDE_DIR "external")
set (LICENSEPP_MAJOR "1")
set (LICENSEPP_MINOR "2")
set (LICENSEPP_PATCH "0")
set (LICENSEPP_SOVERSION "${LICENSEPP_MAJOR}.${LICENSEPP_MINOR}.${LICENSEPP_PATCH}")
set (LICENSEPP_NAME "licensepp")
add_definitions (-DLICENSEPP_SOVERSION="${LICENSEPP_SOVERSION}")
if (travis)
add_definitions (-DLICENSEPP_ON_CI)
endif()
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
include (FindPackageHandleStandardArgs)
if (APPLE)
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -O3 -Wall -Werror -Wno-return-stack-address")
endif()
# Check for cryptopp (static)
set(CryptoPP_USE_STATIC_LIBS ON)
find_package(CryptoPP REQUIRED)
message ("-- Crypto++ binary: " ${CRYPTOPP_LIBRARY})
include_directories (${CRYPTOPP_INCLUDE_DIRS})
# Ripe (static)
set(RIPE_USE_STATIC_LIBS OFF)
find_package(Ripe REQUIRED)
include_directories (${EXTERNAL_INCLUDE_DIR})
# Get a list of all header files in the 'license++' directory
file(GLOB HEADER_FILES "include/license++/*.h")
file(GLOB CC_FILES "src/*.cc")
set(LICENSEPP_SOURCE_FILES
${HEADER_FILES}
src/utils.cc
src/json-object.cc
src/crypto/aes.cc
src/crypto/base64.cc
src/crypto/base16.cc
src/crypto/rsa.cc
src/issuing-authority.cc
src/license.cc
src/c-bindings.cc
)
add_library (licensepp-lib ${LICENSEPP_SOURCE_FILES})
set_target_properties (licensepp-lib PROPERTIES
VERSION ${LICENSEPP_SOVERSION}
)
# ensure project headers are included before global include (notice BEFORE in line below)
target_include_directories (licensepp-lib BEFORE PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
)
target_include_directories (licensepp-lib PUBLIC
$<INSTALL_INTERFACE:include>
)
target_link_libraries (licensepp-lib
${CRYPTOPP_LIBRARIES}
${RIPE_LIBRARY}
)
set_target_properties (licensepp-lib PROPERTIES OUTPUT_NAME "licensepp")
install (TARGETS licensepp-lib EXPORT licensepp-config DESTINATION lib)
# Install the header files to the 'include/license++' directory
install(FILES ${HEADER_FILES} DESTINATION "include/license++")
install (EXPORT licensepp-config DESTINATION share/licensepp/cmake)
export (TARGETS licensepp-lib FILE licensepp-config.cmake)
############## Cmake Package #################
# Packaging config.
set (CPACK_PACKAGE_NAME "licensepp")
set (CPACK_PACKAGE_VERSION_MAJOR ${LICENSEPP_MAJOR})
set (CPACK_PACKAGE_VERSION_MINOR ${LICENSEPP_MINOR})
set (CPACK_PACKAGE_VERSION_PATCH ${LICENSEPP_PATCH})
set (CPACK_SOURCE_GENERATOR TGZ)
set (CPACK_SOURCE_IGNORE_FILES
"/build/"
)
include (CPack)
include_directories (${CMAKE_BINARY_DIR})
include_directories (${CMAKE_SOURCE_DIR})
if (test)
find_package (GTest REQUIRED)
include_directories (${GTEST_INCLUDE_DIRS})
enable_testing()
add_executable (licensepp-unit-tests
test/license-manager-for-test.h
test/license-manager-test.h
test/main.cc
test/test.h
)
# Standard linking to gtest stuff.
target_link_libraries (licensepp-unit-tests
${GTEST_LIBRARIES}
)
# Extra linking for the project.
target_link_libraries (licensepp-unit-tests licensepp-lib)
add_test (NAME licenseppUnitTests COMMAND licensepp-unit-tests)
endif() ## test