diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-11-09 13:54:43 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-11-09 13:54:43 -0500 |
commit | 8a0074d9b8da6112bb5e0f200f4bd17ef192bf9d (patch) | |
tree | 9895142115c0254b30c2bc41dcb978f529490d9d /cmake | |
parent | e9ac693bcde8e09e943b1e4a0e8a534c813501b8 (diff) | |
parent | 176930fa56bff3668d434779972ceb29d41d9bc7 (diff) | |
download | rneovim-8a0074d9b8da6112bb5e0f200f4bd17ef192bf9d.tar.gz rneovim-8a0074d9b8da6112bb5e0f200f4bd17ef192bf9d.tar.bz2 rneovim-8a0074d9b8da6112bb5e0f200f4bd17ef192bf9d.zip |
Merge pull request #1403 from fwalch/version-flags
version: Add compilation info.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/GetCompileFlags.cmake | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/cmake/GetCompileFlags.cmake b/cmake/GetCompileFlags.cmake new file mode 100644 index 0000000000..e0994b67bc --- /dev/null +++ b/cmake/GetCompileFlags.cmake @@ -0,0 +1,58 @@ +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>") + + # Get C compiler. + string(REPLACE + "<CMAKE_C_COMPILER>" + "${CMAKE_C_COMPILER}" + compile_flags + "${compile_flags}") + + # Get flags set by add_definition(). + get_directory_property(definitions + DIRECTORY "src/nvim" + DEFINITIONS) + string(REPLACE + "<DEFINITIONS>" + "${definitions}" + compile_flags + "${compile_flags}") + + # Get general C flags. + string(REPLACE + "<CFLAGS>" + "${CMAKE_C_FLAGS}" + compile_flags + "${compile_flags}") + + # Get C flags specific to build type. + string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type) + string(REPLACE + "<BUILD_TYPE_CFLAGS>" + "${CMAKE_C_FLAGS_${build_type}}" + compile_flags + "${compile_flags}") + + # Get include directories. + get_directory_property(include_directories_list + DIRECTORY "src/nvim" + INCLUDE_DIRECTORIES) + foreach(include_directory ${include_directories_list}) + set(include_directories "${include_directories} -I${include_directory}") + endforeach() + string(REPLACE + "<INCLUDES>" + "${include_directories}" + compile_flags + "${compile_flags}") + + # Clean duplicate whitespace. + string(REPLACE + " " + " " + compile_flags + "${compile_flags}") + + set(${_compile_flags} "${compile_flags}" PARENT_SCOPE) +endfunction() |