-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
60 lines (48 loc) · 1.67 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
cmake_minimum_required(VERSION 3.8)
project(libashmem VERSION 1.0.0 LANGUAGES C CXX)
include(CTest)
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
option(BUILD_EXAMPLES "Build examples using library" ON)
option(ENABLE_TESTS "Build examples using library" OFF)
add_compile_options(-Wall -Wextra -Wpedantic)
set(SRCS ashmem.cpp)
if(BUILD_SHARED_LIBS)
add_library(ashmem SHARED ${SRCS})
else()
add_library(ashmem STATIC ${SRCS})
endif()
set_property(TARGET ashmem PROPERTY C_STANDARD 11)
set_property(TARGET ashmem PROPERTY CXX_STANDARD 17)
include_directories(include)
target_compile_options(ashmem PRIVATE -fno-threadsafe-statics)
target_link_options(ashmem PUBLIC -Wl,--wrap=mmap)
target_link_libraries(ashmem android)
set_target_properties(ashmem PROPERTIES LINKER_LANGUAGE CXX)
if(ENABLE_TESTS)
enable_testing()
find_package(GTest REQUIRED)
include(GoogleTest)
add_executable(ashmem_test "ashmem_test.cpp")
target_link_libraries(ashmem_test ashmem GTest::gtest GTest::gtest_main)
gtest_discover_tests(ashmem_test)
endif()
if(BUILD_EXAMPLES)
add_executable(shm-launch ${PROJECT_SOURCE_DIR}/examples/shm-launch.c)
target_link_libraries(shm-launch PRIVATE ashmem)
add_executable(test-client ${PROJECT_SOURCE_DIR}/examples/test-client.c)
target_link_libraries(test-client PRIVATE ashmem)
add_executable(test-server ${PROJECT_SOURCE_DIR}/examples/test-server.c)
target_link_libraries(test-server PRIVATE ashmem)
endif()
install(FILES ${PROJECT_SOURCE_DIR}/include/ashm.h DESTINATION include)
install(
TARGETS ashmem
RUNTIME
DESTINATION bin
LIBRARY
DESTINATION lib
ARCHIVE
DESTINATION lib
INCLUDES
DESTINATION include
)