-
Notifications
You must be signed in to change notification settings - Fork 198
/
CMakeLists.txt
94 lines (72 loc) · 2.63 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
PROJECT(libsocket)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
# Header conf
SET(VERSION 2.4)
IF( CMAKE_SYSTEM_NAME STREQUAL "Linux" )
SET(IS_FREEBSD 0)
SET(IS_LINUX 1)
SET(IS_SUNOS 0)
ELSEIF( CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" )
SET(IS_FREEBSD 1)
SET(IS_LINUX 0)
SET(IS_SUNOS 0)
ELSEIF( CMAKE_SYSTEM_NAME STREQUAL "SunOS" )
SET(IS_FREEBSD 0)
SET(IS_LINUX 0)
SET(IS_SUNOS 1)
ENDIF()
OPTION(BUILD_STATIC_LIBS "Build the static library" OFF)
OPTION(BUILD_SHARED_LIBS "Build the shared library" ON)
CONFIGURE_FILE(headers/conf.h.in ${CMAKE_CURRENT_BINARY_DIR}/headers/conf.h)
# Compiler configuration
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/headers/ ${CMAKE_CURRENT_SOURCE_DIR}/headers/)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
ADD_DEFINITIONS(-Wall -Wextra)
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(CMAKE_INSTALL_PREFIX "/usr")
ENDIF()
# Install directories
SET(HEADER_DIR "include/libsocket")
SET(LIB_DIR "lib")
ADD_SUBDIRECTORY(C/)
ADD_SUBDIRECTORY(headers/)
IF( NOT IS_SUNOS )
ADD_SUBDIRECTORY(C++/)
ADD_DEPENDENCIES(socket++ socket)
ENDIF()
IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
SET(CPACK_BINARY_DEB "ON")
SET(CPACK_BINARY_RPM "OFF")
SET(CPACK_BINARY_STGZ "OFF")
SET(CPACK_BINARY_TBZ2 "OFF")
SET(CPACK_BINARY_TGZ "OFF")
SET(CPACK_BINARY_TZ "OFF")
SET(CPACK_PACKAGE_NAME "libsocket")
SET(CPACK_PACKAGE_VERSION "2.4.0")
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "")
SET(CPACK_PACKAGE_CONTACT "Lewin Bormann <[email protected]>")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The ultimate socket abstraction library for C and C++.")
# List executables
INCLUDE(CPack)
ENDIF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
set(DEF_INSTALL_CMAKE_DIR lib/CMake/libsocket)
foreach(p LIB BIN INCLUDE CMAKE)
set(var INSTALL_${p}_DIR)
if(NOT IS_ABSOLUTE "${${var}}")
set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif()
endforeach()
export(TARGETS socket++ socket_int
FILE "${PROJECT_BINARY_DIR}/libsocketTargets.cmake")
export(PACKAGE libsocket)
file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}"
"${INSTALL_INCLUDE_DIR}")
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/headers")
configure_file(libsocketConfig.cmake.in
"${PROJECT_BINARY_DIR}/libsocketConfig.cmake" @ONLY)
configure_file(libsocketConfigVersion.cmake.in
"${PROJECT_BINARY_DIR}/libsocketConfigVersion.cmake" @ONLY)