-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
62 lines (41 loc) · 1.66 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
cmake_minimum_required(VERSION 2.8.5)
project(cpufreq-bindings)
set(VERSION_MAJOR 0)
set(VERSION_MINOR 1)
set(VERSION_PATCH 1)
set(PROJECT_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c99")
include_directories(${PROJECT_SOURCE_DIR}/inc)
include(GNUInstallDirs)
# Libraries
add_library(${PROJECT_NAME} src/cpufreq-bindings.c)
if(BUILD_SHARED_LIBS)
set_target_properties(cpufreq-bindings PROPERTIES VERSION ${PROJECT_VERSION}
SOVERSION ${VERSION_MAJOR})
endif()
# pkg-config
set(PKG_CONFIG_EXEC_PREFIX "\${prefix}")
set(PKG_CONFIG_LIBDIR "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
set(PKG_CONFIG_INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}")
set(PKG_CONFIG_CFLAGS "-I\${includedir}")
set(PKG_CONFIG_NAME "${PROJECT_NAME}")
set(PKG_CONFIG_DESCRIPTION "C bindings to cpufreq in Linux sysfs")
set(PKG_CONFIG_LIBS "-L\${libdir} -l${PROJECT_NAME}")
set(PKG_CONFIG_LIBS_PRIVATE "")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
)
# Utilities
add_subdirectory(utils)
# Install
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES inc/cpufreq-bindings.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
# Uninstall
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
@ONLY
)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)