-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
84 lines (67 loc) · 2.04 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
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright(c) 2023 John Sanpe <[email protected]>
#
cmake_minimum_required(VERSION 3.12)
project(liblksu VERSION 1.0.0 LANGUAGES C)
include(GNUInstallDirs)
include(CheckIncludeFiles)
file(GLOB_RECURSE LKSU_HEADERS
${PROJECT_SOURCE_DIR}/include/*.h
)
option(LIBLKSU_CLI "Build CLI" ON)
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_BINARY_DIR}/generated)
include(${PROJECT_SOURCE_DIR}/src/build.cmake)
set(LKSU_LIBRARY
${LKSU_HEADERS}
${LKSU_SOURCES}
)
add_custom_target(
lksu_kernel
COMMAND bash -c \"
install -Dpm 644
${PROJECT_SOURCE_DIR}/kernel/src/lksu.h
${PROJECT_BINARY_DIR}/generated/lksu/kernel.h
\"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
add_library(lksu_object OBJECT ${LKSU_LIBRARY})
add_library(lksu ALIAS lksu_object)
add_dependencies(lksu_object lksu_kernel)
target_link_libraries(lksu_object bfdev)
if(LIBLKSU_CLI)
add_executable(lksu-cmd main.c)
target_link_libraries(lksu-cmd lksu)
endif()
if(${CMAKE_PROJECT_NAME} STREQUAL "liblksu")
add_library(lksu_static STATIC ${LKSU_LIBRARY})
add_library(lksu_shared SHARED ${LKSU_LIBRARY})
add_dependencies(lksu_static lksu_kernel)
add_dependencies(lksu_shared lksu_kernel)
target_link_libraries(lksu_static bfdev)
target_link_libraries(lksu_shared bfdev)
set_target_properties(lksu_static
PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}
LINKER_LANGUAGE C
)
set_target_properties(lksu_shared
PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
LINKER_LANGUAGE C
MACOSX_RPATH ON
)
install(DIRECTORY
${PROJECT_SOURCE_DIR}/include/lksu
${PROJECT_BINARY_DIR}/generated/lksu
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(TARGETS
lksu_static lksu_shared
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()