-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
52 lines (40 loc) · 1.68 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
cmake_minimum_required(VERSION 3.10)
# For Clang to do parsing
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(System2)
set(SYSTEM2_USE_SOURCE OFF CACHE BOOL "")
if(SYSTEM2_USE_SOURCE)
add_library(System2 "${CMAKE_CURRENT_LIST_DIR}/System2.c")
target_include_directories(System2 PUBLIC "${CMAKE_CURRENT_LIST_DIR}")
else()
add_library(System2 INTERFACE)
target_include_directories(System2 INTERFACE "${CMAKE_CURRENT_LIST_DIR}")
endif()
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set_target_properties(System2 PROPERTIES C_STANDARD 99)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(STANDARD_COMPILE_FLAGS "/utf-8;/W1")
else()
set(STANDARD_COMPILE_FLAGS "-Wall"
"-Wno-return-local-addr"
"-Wno-sign-compare"
"-Wno-unused-variable"
"-Wno-unused-parameter"
"-Wno-switch"
"-Wno-gnu-zero-variadic-macro-arguments"
"-Wextra"
"-pedantic"
"-Werror")
endif()
target_compile_options(System2 INTERFACE ${STANDARD_COMPILE_FLAGS})
set(SYSTEM2_BUILD_EXAMPLES ON CACHE BOOL "")
else()
set(SYSTEM2_BUILD_EXAMPLES OFF CACHE BOOL "")
endif()
if(SYSTEM2_BUILD_EXAMPLES)
add_executable(System2Example "${CMAKE_CURRENT_LIST_DIR}/main.c")
if(SYSTEM2_USE_SOURCE)
target_compile_definitions(System2Example PRIVATE USE_SYSTEM2_SOURCE=1)
endif()
target_link_libraries(System2Example System2)
endif()