-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
84 lines (71 loc) · 2.6 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
cmake_minimum_required(VERSION 3.14)
project(epoll-shim LANGUAGES C)
option(BUILD_SHARED_LIBS "build libepoll-shim as shared lib" ON)
option(ENABLE_COMPILER_WARNINGS "enable compiler warnings" OFF)
if(ENABLE_COMPILER_WARNINGS)
add_compile_options(
"-Wall"
"-Wextra"
"-Wconversion"
"-Wsign-conversion"
"-Wmissing-prototypes"
"-pedantic"
"-Werror=implicit-function-declaration"
"-Werror=return-type"
"-Werror=incompatible-pointer-types")
endif()
include(CTest)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_EXTENSIONS ON)
include(CheckTypeSize)
list(APPEND CMAKE_EXTRA_INCLUDE_FILES "errno.h")
check_type_size(errno_t ERRNO_T BUILTIN_TYPES_ONLY LANGUAGE C)
if(NOT HAVE_ERRNO_T)
add_definitions(-Derrno_t=int)
endif()
add_subdirectory(src)
if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(_namespace "${PROJECT_NAME}")
if(BUILD_TESTING)
file(WRITE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
"add_library(${_namespace}::epoll-shim ALIAS epoll-shim)\n")
set(${PROJECT_NAME}_DIR "${PROJECT_BINARY_DIR}")
add_subdirectory(test)
endif()
include(GNUInstallDirs)
set(CMAKE_INSTALL_PKGCONFIGDIR
"libdata/pkgconfig"
CACHE PATH "Installation directory for pkgconfig (.pc) files")
mark_as_advanced(CMAKE_INSTALL_PKGCONFIGDIR)
set(CMAKE_INSTALL_CMAKEBASEDIR
"${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
CACHE PATH "Installation directory for CMake config (.cmake) files")
mark_as_advanced(CMAKE_INSTALL_CMAKEBASEDIR)
configure_file("${PROJECT_SOURCE_DIR}/${PROJECT_NAME}.pc.cmakein"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc" @ONLY)
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc"
DESTINATION "${CMAKE_INSTALL_PKGCONFIGDIR}")
set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/libepoll-shim")
install(
TARGETS epoll-shim
EXPORT ${PROJECT_NAME}-targets
LIBRARY
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/" TYPE INCLUDE)
install(
EXPORT ${PROJECT_NAME}-targets
NAMESPACE "${_namespace}::"
DESTINATION "${CMAKE_INSTALL_CMAKEBASEDIR}")
if(NOT BUILD_SHARED_LIBS)
set(_deps
"include(CMakeFindDependencyMacro)\n" #
"set(THREADS_PREFER_PTHREAD_FLAG ON)\n" #
"find_dependency(Threads)\n")
endif()
file(
WRITE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
${_deps}
"include(\"\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}-targets.cmake\")\n")
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
DESTINATION "${CMAKE_INSTALL_CMAKEBASEDIR}")
endif()