forked from halon/libdkimpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
92 lines (78 loc) · 3.13 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
SET(CMAKE_BUILD_TYPE Release)
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wconversion")
SET(CMAKE_CXX_FLAGS_RELEASE "-Wall -Wconversion")
INCLUDE(FindPkgConfig)
PROJECT(libdkim++)
SET(TARGET_NAME "dkim++")
SET(TARGET_VERSION_MAJOR 2)
SET(TARGET_VERSION_MINOR 0)
SET(TARGET_VERSION_PATCH 0)
SET(TARGET_VERSION ${TARGET_VERSION_MAJOR}.${TARGET_VERSION_MINOR}.${TARGET_VERSION_PATCH})
SET(DKIM_RELEASE "lib${TARGET_NAME}-${TARGET_VERSION}")
LINK_DIRECTORIES(/usr/local/lib)
PKG_CHECK_MODULES(LIBSODIUM REQUIRED libsodium)
FIND_PACKAGE(OpenSSL REQUIRED)
FILE(GLOB_RECURSE SOURCE_FILES src/*.cpp)
ADD_LIBRARY(${TARGET_NAME} SHARED
${SOURCE_FILES}
)
SET_PROPERTY(TARGET ${TARGET_NAME} PROPERTY VERSION ${TARGET_VERSION})
SET_PROPERTY(TARGET ${TARGET_NAME} PROPERTY SOVERSION ${TARGET_VERSION_MAJOR})
IF("${CMAKE_SYSTEM}" MATCHES "Linux")
SET(LIBRESOLV "resolv")
SET(LIBCRYPTO "crypto")
ENDIF("${CMAKE_SYSTEM}" MATCHES "Linux")
IF("${CMAKE_SYSTEM}" MATCHES "OpenBSD")
SET(LIBCRYPTO "crypto")
ENDIF("${CMAKE_SYSTEM}" MATCHES "OpenBSD")
# Try with res_init
ADD_DEFINITIONS(-DHAS_RES_NINIT)
ADD_DEFINITIONS("-std=c++11")
TARGET_LINK_LIBRARIES(${TARGET_NAME}
ssl
${LIBSODIUM_LIBRARIES}
${LIBCRYPTO}
${LIBRESOLV}
)
INCLUDE_DIRECTORIES(
${DIRECTORY}
${CMAKE_SOURCE_DIR}
/usr/local/include/
)
ENABLE_TESTING()
SUBDIRS(
tests
tools
)
IF (NOT DEFINED LIB_INSTALL_DIR)
SET(LIB_INSTALL_DIR "lib")
ENDIF(NOT DEFINED LIB_INSTALL_DIR)
FILE(GLOB_RECURSE files src/*.hpp)
INSTALL(FILES ${files} DESTINATION include/libdkim++)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libdkim++.so DESTINATION lib${LIB_SUFFIX})
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libdkim++.so.${TARGET_VERSION} DESTINATION lib${LIB_SUFFIX})
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libdkim++.so.${TARGET_VERSION_MAJOR} DESTINATION lib${LIB_SUFFIX})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libdkim++.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libdkim++.pc @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libdkim++.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig)
# Make FreeBSD packages
IF (CMAKE_SYSTEM_NAME MATCHES BSD)
SET(CPACK_GENERATOR TBZ2)
SET(CPACK_PACKAGE_FILE_NAME "${DKIM_RELEASE}")
SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
INSTALL(CODE "
IF(\${CMAKE_INSTALL_PREFIX} MATCHES .*/_CPack_Packages/.*)
FILE(WRITE \"\${CMAKE_INSTALL_PREFIX}/+DESC\" \"libdkim++ is a lightweight and portable DKIM (RFC6376) library for *NIX\n\")
FILE(WRITE \"\${CMAKE_INSTALL_PREFIX}/+COMMENT\" \"libdkim++ is a lightweight and portable DKIM (RFC6376)\n\")
FILE(WRITE \"\${CMAKE_INSTALL_PREFIX}/+CONTENTS\" \"@comment PKG_FORMAT_REVISION:1.1\n\")
FILE(APPEND \"\${CMAKE_INSTALL_PREFIX}/+CONTENTS\" \"@name ${DKIM_RELEASE}\n\")
FILE(APPEND \"\${CMAKE_INSTALL_PREFIX}/+CONTENTS\" \"@comment ORIGIN:/dev/null\n\")
FILE(APPEND \"\${CMAKE_INSTALL_PREFIX}/+CONTENTS\" \"@cwd /usr/local\n\")
FOREACH(file \${CMAKE_INSTALL_MANIFEST_FILES})
FILE(RELATIVE_PATH file \${CMAKE_INSTALL_PREFIX} \${file})
FILE(APPEND \"\${CMAKE_INSTALL_PREFIX}/+CONTENTS\" \"\${file}\n\")
ENDFOREACH()
ENDIF(\${CMAKE_INSTALL_PREFIX} MATCHES .*/_CPack_Packages/.*)
")
INCLUDE(CPack)
ENDIF (CMAKE_SYSTEM_NAME MATCHES BSD)