-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
95 lines (75 loc) · 2.85 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
cmake_minimum_required(VERSION 2.6.4)
cmake_policy(SET CMP0017 NEW)
PROJECT(libkvsns C)
set(LIBKVSNS_MAJOR_VERSION 1)
set(LIBKVSNS_MINOR_VERSION 3)
set(LIBKVSNS_PATCH_LEVEL 1)
set(LIBKVSNS_EXTRA_VERSION "")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_SOURCE_DIR}/include -fPIC -g")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")
set(LIBKVSNS_BASE_VERSION ${LIBKVSNS_MAJOR_VERSION}.${LIBKVSNS_MINOR_VERSION}.${LIBKVSNS_PATCH_LEVEL})
message( STATUS "cmake version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" )
message( STATUS "libkvsns version ${LIBKVSNS_BASE_VERSION}")
# Final tuning
include(CheckIncludeFiles)
include(CheckLibraryExists)
## Check ini_config
check_include_files("ini_config.h" HAVE_INI_CONFIG_H)
find_library(HAVE_INI_CONFIG ini_config)
check_library_exists(
ini_config
config_from_file
""
HAVE_INI_CONFIG
)
# Build ancillary libs
add_subdirectory(kvsns)
add_subdirectory(tests)
add_subdirectory(kvsns_shell)
add_subdirectory(kvsns_script)
add_subdirectory(kvsns_attach)
add_subdirectory(kvsns_hsm)
# CPack / rpmbuild specific stuff
set(CPACK_PACKAGE_FILE_NAME "libkvsns-Source" )
set(CPACK_PACKAGE_VENDOR "KVSNS")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "KVSNS - a namespace on top of a KVS")
SET(CPACK_PACKAGE_VERSION_MAJOR ${LIBKVSNS_MAJOR_VERSION})
SET(CPACK_PACKAGE_VERSION_MINOR ${LIBKVSNS_MINOR_VERSION})
SET(CPACK_PACKAGE_VERSION_PATCH ${LIBKVSNS_PATCH_LEVEL})
# Tell CPack the kind of packages to be generated
set(CPACK_GENERATOR "TGZ")
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES
"/.git/;/.gitignore/;/build/;/.bzr/;~$;${CPACK_SOURCE_IGNORE_FILES}")
include(CPack)
set(PKG_NAME "${CPACK_PACKAGE_NAME}.tar.gz")
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
# Create the .pc file
configure_file(
"${PROJECT_SOURCE_DIR}/libkvsns.pc-in.cmake"
"${PROJECT_SOURCE_DIR}/libkvsns.pc"
)
# Now create a useable specfile
configure_file(
"${PROJECT_SOURCE_DIR}/libkvsns.spec-in.cmake"
"${PROJECT_SOURCE_DIR}/libkvsns.spec"
)
set(RPMDEST "--define '_srcrpmdir ${CMAKE_CURRENT_BINARY_DIR}'")
add_custom_target( rpms DEPENDS dist)
add_custom_command(TARGET rpms
COMMAND sh -c "rpmbuild ${RPMDEST} -ta ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz"
VERBATIM
DEPENDS dist)
add_custom_target( rpm DEPENDS dist)
add_custom_command(TARGET rpm
COMMAND sh -c "rpmbuild ${RPMDEST} -tb ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz"
VERBATIM
DEPENDS dist)
add_custom_target( srpm DEPENDS dist)
add_custom_command(TARGET srpm
COMMAND sh -c "rpmbuild ${RPMDEST} -ts ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz"
VERBATIM
DEPENDS dist)
# INSTALL
install(FILES ${PROJECT_SOURCE_DIR}/libkvsns.pc DESTINATION lib)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/iosea DESTINATION include)