diff options
author | Daniel Hahler <github@thequod.de> | 2019-06-29 20:37:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-29 20:37:48 +0200 |
commit | c207095445286321cbb319ab1498c34b204760cf (patch) | |
tree | c839456e97332255d1ced1607477083149a6df77 /cmake/GetCompileFlags.cmake | |
parent | 39ba35b38da0724f8562e4e63258ca0c51890e1d (diff) | |
download | rneovim-c207095445286321cbb319ab1498c34b204760cf.tar.gz rneovim-c207095445286321cbb319ab1498c34b204760cf.tar.bz2 rneovim-c207095445286321cbb319ab1498c34b204760cf.zip |
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
Diffstat (limited to 'cmake/GetCompileFlags.cmake')
-rw-r--r-- | cmake/GetCompileFlags.cmake | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/cmake/GetCompileFlags.cmake b/cmake/GetCompileFlags.cmake index 527bc88cdd..77a5260780 100644 --- a/cmake/GetCompileFlags.cmake +++ b/cmake/GetCompileFlags.cmake @@ -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}") |