-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
56 lines (42 loc) · 1.96 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
# Project
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(stackusage VERSION 1.0 LANGUAGES C CXX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -g \
-Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual \
-Wstrict-prototypes -Wmissing-prototypes -Wno-missing-braces -Wswitch-default \
-Wcast-align -Wunreachable-code -Wundef -Wuninitialized ")
# Library
add_library(stackusage SHARED src/sumain.c)
install(TARGETS stackusage LIBRARY DESTINATION lib)
set_target_properties(stackusage PROPERTIES LINK_FLAGS "-fPIC")
target_link_libraries(stackusage pthread dl)
if(CMAKE_BUILD_TYPE MATCHES "Debug")
target_compile_options(stackusage PRIVATE -fsanitize=address -fno-omit-frame-pointer
-fsanitize-recover=address)
set_target_properties(stackusage PROPERTIES LINK_FLAGS "-fsanitize=address")
endif()
# Utility
configure_file(src/stackusage ${CMAKE_CURRENT_BINARY_DIR}/stackusage COPYONLY)
install(PROGRAMS src/stackusage DESTINATION bin)
# Manual
install(FILES src/stackusage.1 DESTINATION share/man/man1)
# Tests
enable_testing()
add_executable(ex001 tests/ex001.c)
target_link_libraries(ex001 pthread)
configure_file(tests/test001 ${CMAKE_CURRENT_BINARY_DIR}/test001 COPYONLY)
add_test(test001 "${PROJECT_BINARY_DIR}/test001")
add_executable(ex002 tests/ex002.c)
target_link_libraries(ex002 pthread)
configure_file(tests/test002 ${CMAKE_CURRENT_BINARY_DIR}/test002 COPYONLY)
add_test(test002 "${PROJECT_BINARY_DIR}/test002")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_executable(ex003 tests/ex003.c)
target_link_libraries(ex003 pthread)
configure_file(tests/test003 ${CMAKE_CURRENT_BINARY_DIR}/test003 COPYONLY)
add_test(test003 "${PROJECT_BINARY_DIR}/test003")
endif()
add_executable(ex004 tests/ex004.c)
target_link_libraries(ex004 pthread)
configure_file(tests/test004 ${CMAKE_CURRENT_BINARY_DIR}/test004 COPYONLY)
add_test(test004 "${PROJECT_BINARY_DIR}/test004")