From f9826e1dff5f1ac8212ca55a847c872c426142db Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 3 Feb 2023 00:00:15 +0100 Subject: build: stop relying on CMAKE_BUILD_TYPE to determine the build type (#22051) Any logic involving CMAKE_BUILD_TYPE is automatically broken as it won't work with multi-config generators. The only exception is if we explicitly check whether the current generator is single-config as well. Instead, use generator expressions or cmake variables that allows to set options for certain build types only such as INTERPROCEDURAL_OPTIMIZATION_. Opt to generate all headers with optimization level O2 with no debug information for all build types as that is the simplest way to make it behave the same for all generators. --- cmake/GetCompileFlags.cmake | 57 --------------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 cmake/GetCompileFlags.cmake (limited to 'cmake/GetCompileFlags.cmake') diff --git a/cmake/GetCompileFlags.cmake b/cmake/GetCompileFlags.cmake deleted file mode 100644 index 9b3c053871..0000000000 --- a/cmake/GetCompileFlags.cmake +++ /dev/null @@ -1,57 +0,0 @@ -function(get_compile_flags _compile_flags) - string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type) - set(compile_flags ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${build_type}}) - - # Get flags set by target_compile_options(). - get_target_property(opt main_lib INTERFACE_COMPILE_OPTIONS) - if(opt) - list(APPEND compile_flags ${opt}) - endif() - - get_target_property(opt nvim COMPILE_OPTIONS) - if(opt) - list(APPEND compile_flags ${opt}) - endif() - - # Get flags set by target_compile_definitions(). - get_target_property(defs main_lib INTERFACE_COMPILE_DEFINITIONS) - if(defs) - foreach(def ${defs}) - list(APPEND compile_flags "-D${def}") - endforeach() - endif() - - get_target_property(defs nvim COMPILE_DEFINITIONS) - if(defs) - foreach(def ${defs}) - list(APPEND compile_flags "-D${def}") - endforeach() - endif() - - # Get include directories. - get_target_property(dirs main_lib INTERFACE_INCLUDE_DIRECTORIES) - if(dirs) - foreach(dir ${dirs}) - list(APPEND compile_flags "-I${dir}") - endforeach() - endif() - - get_target_property(dirs main_lib INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) - if(dirs) - foreach(dir ${dirs}) - list(APPEND compile_flags "-I${dir}") - endforeach() - endif() - - get_target_property(dirs nvim INCLUDE_DIRECTORIES) - if(dirs) - foreach(dir ${dirs}) - list(APPEND compile_flags "-I${dir}") - endforeach() - endif() - - list(REMOVE_DUPLICATES compile_flags) - string(REPLACE ";" " " compile_flags "${compile_flags}") - - set(${_compile_flags} "${compile_flags}" PARENT_SCOPE) -endfunction() -- cgit