-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
47 lines (35 loc) · 1.24 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
cmake_minimum_required(VERSION 3.30)
project(memmgr C)
set(CMAKE_C_STANDARD 23)
set(MEMMGR_VERSION_MAJOR 1)
set(MEMMGR_VERSION_MINOR 0)
set(SOURCE_DIRECTORY src)
set(INCLUDE_DIRECTORY include)
set(TEST_DIRECTORY test)
# Collect source files
file(GLOB_RECURSE SOURCES "${SOURCE_DIRECTORY}/*.c")
# Create library
add_library(memmgr_static STATIC ${SOURCES})
add_library(memmgr_shared include ${SOURCES})
# Set include directories
target_include_directories(memmgr_static PUBLIC ${INCLUDE_DIRECTORY})
target_include_directories(memmgr_shared PUBLIC ${INCLUDE_DIRECTORY})
# Set output names
set_target_properties(memmgr_static PROPERTIES OUTPUT_NAME "memmgr")
set_target_properties(memmgr_shared PROPERTIES OUTPUT_NAME "memmgr")
# Add versioning for the include library
set_target_properties(memmgr_shared PROPERTIES
VERSION "${MEMMGR_VERSION_MAJOR}.${MEMMGR_VERSION_MINOR}"
SOVERSION "${MEMMGR_VERSION_MAJOR}"
)
# Enable testing
enable_testing()
# Add tests
add_executable(memmgr_test ${TEST_DIRECTORY}/test_memmgr.c)
target_link_libraries(memmgr_test PRIVATE memmgr_static)
add_test(NAME MemMGRTest COMMAND memmgr_test)
# Installation
install(TARGETS memmgr_static memmgr_shared
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)