File: CMakeLists.txt

package info (click to toggle)
biblesync 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 308 kB
  • sloc: cpp: 1,050; ansic: 81; sh: 30; makefile: 20
file content (116 lines) | stat: -rw-r--r-- 5,091 bytes parent folder | download
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
# Accepted options
# - BUILD_SHARED_LIBS (default FALSE) - set to true to build shared libraries
# - CMAKE_INSTALL_PREFIX (default "/usr/local") - set to directory where you want libs installed
# - LIBDIR (default "CMAKE_INSTALL_PREFIX/lib") - set to directory where binaries should be installed
# - MANDIR (default "CMAKE_INSTALL_PREFIX/share/man/man7") - set to directory where manual pages should be installed
# - INCLUDEDIR (default "CMAKE_INSTALL_PREFIX/include") - set to directory where header files should be installed
# - BIBLESYNC_SOVERSION (defaults to BIBLESYNC_VERSION) - Manually set the SOVERSION of the installed file
PROJECT(libbiblesync CXX)
SET(BIBLESYNC_VERSION 1.2.0)
# A required CMake line
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
# Where our custom Find* files are located
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# Just a variable so if we expand to more files we only have to edit one place
SET(biblesync_sources src/biblesync.cc)
SET(biblesync_headers            include/biblesync.hh
    "${CMAKE_CURRENT_BINARY_DIR}/include/biblesync-version.hh")

# Set a library to build (the fact that it is "biblesync" and matches the name
# in the PROJECT declaration above is purely a matter of choice and convention and
# need not be the case. We can also add additional libraries if we wanted to have
# multiple products from this build process
IF(BUILD_SHARED_LIBS)
    ADD_LIBRARY(biblesync SHARED ${biblesync_sources})
    SET(SHAREDLIB_FALSE "#")
ELSE(BUILD_SHARED_LIBS)
    ADD_LIBRARY(biblesync STATIC ${biblesync_sources})
    SET(SHAREDLIB_TRUE "#")
ENDIF(BUILD_SHARED_LIBS)

# Set the default headers location
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/include")
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/include")

# System defines
IF(WIN32)
    MESSAGE(STATUS "Building for Win32")
    ADD_DEFINITIONS(-DWIN32)
    TARGET_LINK_LIBRARIES(biblesync "ws2_32" "rpcrt4" "intl")
ELSE(WIN32)
    # Headers and linkage from libuuid
    FIND_PACKAGE(UUID REQUIRED)
    INCLUDE_DIRECTORIES("${UUID_INCLUDE_DIRS}")
    TARGET_LINK_LIBRARIES(biblesync "${UUID_LIBRARIES}")
ENDIF(WIN32)

# Allow build systems to specify non-standard install locations
IF(NOT CMAKE_INSTALL_PREFIX)
    SET(PREFIX "/usr/local")
ELSE(NOT CMAKE_INSTALL_PREFIX)
    SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
ENDIF(NOT CMAKE_INSTALL_PREFIX)

MESSAGE(STATUS "Will install to: ${PREFIX}")

SET(LIBDIR "${PREFIX}/lib" CACHE STRING 
    "Object code library install directory. Defaults to CMAKE_INSTALL_PREFIX/lib")
SET(MANDIR "${PREFIX}/share/man/man7" CACHE STRING 
    "Manual page install directory. Defaults to CMAKE_INSTALL_PREFIX/share/man/man7")
SET(INCLUDEDIR "${PREFIX}/include/biblesync" CACHE STRING 
    "Header library install directory. Defaults to CMAKE_INSTALL_PREFIX/include/biblecync")

##########################################################################################
# Copied from Sword's code to handle the setting of version numbers
##########################################################################################
# Post-processing of variables
MACRO(PROCESS_VERSION LEVEL VALUE)
    SET(BIBLESYNC_VERSION_${LEVEL} ${VALUE})
    IF(${VALUE} LESS 10)
        SET(${LEVEL} "00${VALUE}")
    ELSEIF(${VALUE} LESS 100)
        SET(${LEVEL} "0${VALUE}")
    ELSE()
        SET(${LEVEL} "${VALUE}")
    ENDIF()
ENDMACRO()

STRING(REGEX MATCHALL "^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.?([0-9]+)?$"
    BIBLESYNC_VERSION_PARTS "${BIBLESYNC_VERSION}")
# We don't always have a nano version
IF("${CMAKE_MATCH_4}" STREQUAL "")
    SET(CMAKE_MATCH_4 "0")
ENDIF("${CMAKE_MATCH_4}" STREQUAL "")

SET(BIBLESYNC_VERSION_MAJOR ${CMAKE_MATCH_1}) # No post-processing on this, so it's not octal
PROCESS_VERSION("MINOR" ${CMAKE_MATCH_2})
PROCESS_VERSION("MICRO" ${CMAKE_MATCH_3})
PROCESS_VERSION("NANO"  ${CMAKE_MATCH_4})

SET(BIBLESYNC_VERSION_STR "${BIBLESYNC_VERSION}")
SET(BIBLESYNC_VERSION_NUM "${BIBLESYNC_VERSION_MAJOR}${MINOR}${MICRO}${NANO}")
##########################################################################################
# End of copy from Sword's code
##########################################################################################

# Set the SOVERSION of the package, for binary compatibility tracking
INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/soversion.cmake")

# Set the variables in the .in file
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/biblesync-version.hh.in 
    ${CMAKE_CURRENT_BINARY_DIR}/include/biblesync-version.hh @ONLY)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/biblesync.spec.in 
    ${CMAKE_CURRENT_BINARY_DIR}/biblesync.spec @ONLY)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/biblesync.pc.in 
    ${CMAKE_CURRENT_BINARY_DIR}/biblesync.pc @ONLY)

# Install both the library and its headers
INSTALL(TARGETS biblesync
    DESTINATION "${LIBDIR}")
INSTALL(FILES ${biblesync_headers}
    DESTINATION "${INCLUDEDIR}")
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/biblesync.pc"
    DESTINATION "${LIBDIR}/pkgconfig")
INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/man/biblesync.7"
    DESTINATION "${MANDIR}")