-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
78 lines (62 loc) · 1.6 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
cmake_minimum_required(VERSION 3.10)
project(CANvenient C)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/export)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/export)
include(FetchContent)
set(CMAKE_C_STANDARD 90)
if (POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
if(WIN32)
set(PLATFORM "windows")
elseif(UNIX)
set(PLATFORM "linux")
else()
message(FATAL_ERROR "Unsupported platform")
endif()
set(core_sources
${CMAKE_CURRENT_SOURCE_DIR}/src/CANvenient.c)
add_library(
CANvenient
STATIC
${core_sources})
include_directories(
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_compile_options(
${PROJECT_NAME}
PUBLIC
-Wall
-Wextra
-Wpedantic
-Wno-unsafe-buffer-usage
-Wno-covered-switch-default
-Werror)
if (ENABLE_ADDRESS_SANITIZER)
target_compile_options(
${PROJECT_NAME}
PUBLIC
-fsanitize=address)
target_link_options(
${PROJECT_NAME}
PUBLIC
-fsanitize=address)
target_link_libraries(
${PROJECT_NAME}
clang_rt.asan_dynamic-x86_64
clang_rt.asan_dynamic_runtime_thunk-x86_64)
endif()
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(
${PROJECT_NAME}
PUBLIC
-Wall
-Wextra
-Wpedantic)
elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
target_compile_options(
${PROJECT_NAME}
PUBLIC
/W4
/utf-8)
endif()