forked from abumq/licensepp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
134 lines (105 loc) · 4.02 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
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 (LICENSEPP_MAJOR "1")
set (LICENSEPP_MINOR "0")
set (LICENSEPP_PATCH "6")
set (LICENSEPP_SOVERSION "${LICENSEPP_MAJOR}.${LICENSEPP_MINOR}.${LICENSEPP_PATCH}")
set (LICENSEPP_NAME "licensepp")
add_definitions (-DLICENSEPP_SOVERSION="${LICENSEPP_SOVERSION}")
add_definitions (-DRIPE_VERSION="4.0.1-custom-static")
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++11 -O3 -Wall -Werror")
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})
set(LICENSEPP_SOURCE_FILES
license++/license-exception.h
license++/license.h
license++/issuing-authority.h
license++/base-license-manager.h
license++/license-c-bindings.h
src/external/Ripe.cc
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/license-c-bindings.cc
)
add_library (licensepp-lib ${LICENSEPP_SOURCE_FILES})
set_target_properties (licensepp-lib PROPERTIES
VERSION ${LICENSEPP_SOVERSION}
)
target_include_directories (licensepp-lib PUBLIC $<INSTALL_INTERFACE:include>)
target_link_libraries (licensepp-lib
${CRYPTOPP_LIBRARIES}
)
set_target_properties (licensepp-lib PROPERTIES OUTPUT_NAME "licensepp")
install (TARGETS licensepp-lib EXPORT licensepp-config DESTINATION lib)
install (FILES license++/base-license-manager.h DESTINATION "include/license++")
install (FILES license++/issuing-authority.h DESTINATION "include/license++")
install (FILES license++/license.h DESTINATION "include/license++")
install (FILES license++/license-exception.h DESTINATION "include/license++")
install (FILES license++/license-c-bindings.h 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)
# Compile-time configuration.
configure_file (
${CMAKE_SOURCE_DIR}/cmake/config.h.cmake
${CMAKE_BINARY_DIR}/config.h
)
include_directories (${CMAKE_BINARY_DIR})
include_directories (${CMAKE_SOURCE_DIR})
if (test)
find_package (gtest REQUIRED)
include_directories (${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
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 gtest_main)
# Extra linking for the project.
target_link_libraries (licensepp-unit-tests licensepp-lib)
target_link_libraries (licensepp-unit-tests ${CRYPTOPP_LIBRARIES})
add_test (NAME licenseppUnitTests COMMAND licensepp-unit-tests)
endif() ## test