File: CMakeLists.txt

package info (click to toggle)
libtypec 0.6.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 432 kB
  • sloc: ansic: 4,991; makefile: 4
file content (61 lines) | stat: -rw-r--r-- 2,632 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
cmake_minimum_required(VERSION 3.16.3)
project(libtypec VERSION 0.6.0 DESCRIPTION "Library to interface with USB Type-C and USB Power Delivery class devices")


# Distributions set arch-specific include dir by patching GNUInstallDirs
include(GNUInstallDirs)

# Saying ${CMAKE_CURRENT_BINARY_DIR}/ here is redundant but more readable
configure_file(libtypec_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/libtypec_config.h)

include(InstallRequiredSystemLibraries)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSES")
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
SET(CPACK_SET_DESTDIR "ON")
set(CPACK_PACKAGE_VENDOR "Rajaram Regupathy")
set(CPACK_PACKAGE_CONTACT "rajaram.regupathy@gmail.com")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
set(CPACK_RPM_SPEC_CHANGELOG "${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}\n  Generated by CPack RPM (Refer:https://github.com/Rajaram-Regupathy/libtypec/releases)")
set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_PROCESSOR}")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Rajaram Regupathy")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_PACKAGE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/package)
set(CPACK_SOURCE_IGNORE_FILES .git/ build/ bin/ CMakeCache.txt cmake_install.cmake _CPack_Packages/ CMakeFiles/ package/ )
include(CPack)

add_library(libtypec SHARED libtypec.c libtypec_sysfs_ops.c libtypec_dbgfs_ops.c)

target_include_directories(libtypec PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_link_libraries(libtypec PUBLIC udev)

option(LIBTYPEC_STRICT_CFLAGS "Compile for strict warnings" ON)
if(LIBTYPEC_STRICT_CFLAGS)
    target_compile_options(libtypec PRIVATE -g -O2 -fstack-protector-strong -Wformat=1 -Werror=format-security -Wdate-time -fasynchronous-unwind-tables -D_FORTIFY_SOURCE=2)
endif()

set_target_properties(libtypec PROPERTIES
	OUTPUT_NAME "typec"
	VERSION ${PROJECT_VERSION}
	SOVERSION "0"
	PUBLIC_HEADER "libtypec.h;${CMAKE_CURRENT_BINARY_DIR}/libtypec_config.h")

add_subdirectory(utils)


install(TARGETS libtypec lstypec typecstatus ucsicontrol
    LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
    RUNTIME     DESTINATION bin
    PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

configure_file(
    libtypec.pc.in
    ${CMAKE_CURRENT_BINARY_DIR}/libtypec.pc
    @ONLY
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtypec.pc
    DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)