aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt49
1 files changed, 35 insertions, 14 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 594f631ba0..e0daea5969 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -113,15 +113,14 @@ else()
set(HAS_OG_FLAG 0)
endif()
-# Set custom build flags for RelWithDebInfo.
-# -DNDEBUG purposely omitted because we want assertions.
+#
+# Build-type: RelWithDebInfo
+#
if(HAS_OG_FLAG)
- set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Og -g"
- CACHE STRING "Flags used by the compiler during release-with-debug builds." FORCE)
-elseif(NOT MSVC)
- set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g"
- CACHE STRING "Flags used by the compiler during release-with-debug builds." FORCE)
-elseif(CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DNDEBUG)
+ set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -Og -g")
+endif()
+# We _want_ assertions in RelWithDebInfo build-type.
+if(CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DNDEBUG)
string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
endif()
@@ -254,7 +253,10 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.5")
# Array-bounds testing is broken in some GCC versions before 4.8.5.
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
- add_definitions(-Wno-array-bounds)
+ check_c_compiler_flag(-Wno-array-bounds HAS_NO_ARRAY_BOUNDS_FLAG)
+ if(HAS_NO_ARRAY_BOUNDS_FLAG)
+ add_definitions(-Wno-array-bounds)
+ endif()
endif()
endif()
@@ -344,6 +346,21 @@ if(FEAT_TUI)
find_package(Unibilium REQUIRED)
include_directories(SYSTEM ${UNIBILIUM_INCLUDE_DIRS})
+ list(APPEND CMAKE_REQUIRED_INCLUDES "${UNIBILIUM_INCLUDE_DIRS}")
+ list(APPEND CMAKE_REQUIRED_LIBRARIES "${UNIBILIUM_LIBRARIES}")
+ check_c_source_compiles("
+ #include <unibilium.h>
+
+ int
+ main(void)
+ {
+ return unibi_num_from_var(unibi_var_from_num(0));
+ }
+ " UNIBI_HAS_VAR_FROM)
+ if(UNIBI_HAS_VAR_FROM)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNVIM_UNIBI_HAS_VAR_FROM")
+ endif()
+
find_package(LibTermkey REQUIRED)
include_directories(SYSTEM ${LIBTERMKEY_INCLUDE_DIRS})
endif()
@@ -351,6 +368,11 @@ endif()
find_package(LibVterm REQUIRED)
include_directories(SYSTEM ${LIBVTERM_INCLUDE_DIRS})
+if(WIN32)
+ find_package(Winpty REQUIRED)
+ include_directories(SYSTEM ${WINPTY_INCLUDE_DIRS})
+endif()
+
option(CLANG_ASAN_UBSAN "Enable Clang address & undefined behavior sanitizer for nvim binary." OFF)
option(CLANG_MSAN "Enable Clang memory sanitizer for nvim binary." OFF)
option(CLANG_TSAN "Enable Clang thread sanitizer for nvim binary." OFF)
@@ -456,20 +478,19 @@ install_helper(
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
# MIN_LOG_LEVEL for log.h
-if(DEFINED MIN_LOG_LEVEL)
+if("${MIN_LOG_LEVEL}" MATCHES "^$")
+ message(STATUS "MIN_LOG_LEVEL not specified")
+else()
if(NOT MIN_LOG_LEVEL MATCHES "^[0-3]$")
message(FATAL_ERROR "invalid MIN_LOG_LEVEL: " ${MIN_LOG_LEVEL})
endif()
message(STATUS "MIN_LOG_LEVEL set to ${MIN_LOG_LEVEL}")
-else()
- message(STATUS "MIN_LOG_LEVEL not specified, defaulting to 1 (INFO)")
endif()
# Go down the tree.
add_subdirectory(src/nvim)
-# Read compilation flags from src/nvim,
-# used in config subdirectory below.
+# Read compilation flags from src/nvim, used in config subdirectory below.
include(GetCompileFlags)
get_compile_flags(NVIM_VERSION_CFLAGS)