build: CMake: do not set CMP0059 to old (#10363)

Keeps using add_definitions for compatibility with older CMake.

Newer CMake (3.12) would have `add_compile_definitions`, but it is not
required, since `add_defitions` was meant to be used for
compile/preprocessor definitions initially anyway.

Ref: https://github.com/neovim/neovim/pull/4389
This commit is contained in:
Daniel Hahler
2019-06-29 20:37:48 +02:00
committed by GitHub
parent 39ba35b38d
commit c207095445
5 changed files with 38 additions and 28 deletions

View File

@@ -1,6 +1,6 @@
function(get_compile_flags _compile_flags)
# Create template akin to CMAKE_C_COMPILE_OBJECT.
set(compile_flags "<CMAKE_C_COMPILER> <CFLAGS> <BUILD_TYPE_CFLAGS> <DEFINITIONS> <INCLUDES>")
set(compile_flags "<CMAKE_C_COMPILER> <CFLAGS> <BUILD_TYPE_CFLAGS> <COMPILE_OPTIONS> <COMPILE_DEFINITIONS> <INCLUDES>")
# Get C compiler.
string(REPLACE
@@ -9,13 +9,28 @@ function(get_compile_flags _compile_flags)
compile_flags
"${compile_flags}")
# Get flags set by add_definition().
get_directory_property(definitions
# Get flags set by add_definitions().
get_directory_property(compile_definitions
DIRECTORY "src/nvim"
DEFINITIONS)
COMPILE_DEFINITIONS)
# NOTE: list(JOIN) requires CMake 3.12.
string(REPLACE ";" " -D" compile_definitions "${compile_definitions}")
string(CONCAT compile_definitions "-D" "${compile_definitions}")
string(REPLACE
"<DEFINITIONS>"
"${definitions}"
"<COMPILE_DEFINITIONS>"
"${compile_definitions}"
compile_flags
"${compile_flags}")
# Get flags set by add_compile_options().
get_directory_property(compile_options
DIRECTORY "src/nvim"
COMPILE_OPTIONS)
# NOTE: list(JOIN) requires CMake 3.12.
string(REPLACE ";" " " compile_options "${compile_options}")
string(REPLACE
"<COMPILE_OPTIONS>"
"${compile_options}"
compile_flags
"${compile_flags}")