-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
67 lines (59 loc) · 2.34 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
cmake_minimum_required(VERSION 3.14)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(USE_SYSTEM_GOOGLETEST "Use system gtest" ON)
option(USE_SYSTEM_LIBUV "Use system gtest" ON)
option(BUILD_FULL_STATIC "Fully static binary including libc for musl" OFF)
option(BUILD_STATIC "Fully static binary" OFF)
option(BUILD_TEST "Build test binary" OFF)
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE "Release")
message("[INFO] CMAKE_BUILD_TYPE not set, setting to Release")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Ofast -fomit-frame-pointer -flto")
endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
message("[INFO] Debug Build")
add_compile_options(-g3 -O0)
else()
message("[INFO] CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
endif()
if(DEFINED SANITIZE)
if(${SANITIZE} STREQUAL undefined)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
elseif(${SANITIZE} STREQUAL address)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
elseif(${SANITIZE} STREQUAL leak)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=leak")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=leak")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak")
elseif(${SANITIZE} STREQUAL thread)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
endif()
endif()
if(${BUILD_FULL_STATIC})
set(USE_SYSTEM_GOOGLETEST OFF)
set(USE_SYSTEM_LIBUV OFF)
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_EXE_LINKER_FLAGS "-static")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
elseif(${BUILD_STATIC})
set(USE_SYSTEM_GOOGLETEST OFF)
set(USE_SYSTEM_LIBUV OFF)
endif()
include(ExternalProject)
include(FindPkgConfig)
set(proj_name vim9-nox11)
if(NOT BUILD_TEST)
project(${proj_name} C)
else()
project(${proj_name})
endif()
add_subdirectory(native/ext)
add_subdirectory(native/app)