2014-11-09 05:52:15 -07:00
|
|
|
function(get_compile_flags _compile_flags)
|
2023-01-10 10:49:57 -07:00
|
|
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
|
|
|
|
set(compile_flags ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${build_type}})
|
2014-11-09 05:52:15 -07:00
|
|
|
|
2023-01-10 10:49:57 -07:00
|
|
|
# Get flags set by target_compile_options().
|
|
|
|
get_target_property(opt main_lib INTERFACE_COMPILE_OPTIONS)
|
|
|
|
if(opt)
|
|
|
|
list(APPEND compile_flags ${opt})
|
|
|
|
endif()
|
2014-11-09 05:52:15 -07:00
|
|
|
|
2023-01-10 10:49:57 -07:00
|
|
|
get_target_property(opt nvim COMPILE_OPTIONS)
|
|
|
|
if(opt)
|
|
|
|
list(APPEND compile_flags ${opt})
|
2019-08-14 18:00:45 -07:00
|
|
|
endif()
|
2023-01-10 10:49:57 -07:00
|
|
|
|
|
|
|
# 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()
|
2019-07-07 04:01:38 -07:00
|
|
|
endif()
|
2019-06-29 11:37:48 -07:00
|
|
|
|
2023-01-10 10:49:57 -07:00
|
|
|
get_target_property(defs nvim COMPILE_DEFINITIONS)
|
|
|
|
if(defs)
|
|
|
|
foreach(def ${defs})
|
|
|
|
list(APPEND compile_flags "-D${def}")
|
|
|
|
endforeach()
|
2019-08-14 18:00:45 -07:00
|
|
|
endif()
|
2014-11-09 05:52:15 -07:00
|
|
|
|
2023-01-10 10:49:57 -07:00
|
|
|
# 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()
|
2014-11-09 05:52:15 -07:00
|
|
|
|
2023-01-10 10:49:57 -07:00
|
|
|
get_target_property(dirs main_lib INTERFACE_SYSTEM_INCLUDE_DIRECTORIES)
|
|
|
|
if(dirs)
|
|
|
|
foreach(dir ${dirs})
|
|
|
|
list(APPEND compile_flags "-I${dir}")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2014-11-09 05:52:15 -07:00
|
|
|
|
2023-01-10 10:49:57 -07:00
|
|
|
get_target_property(dirs nvim INCLUDE_DIRECTORIES)
|
|
|
|
if(dirs)
|
|
|
|
foreach(dir ${dirs})
|
|
|
|
list(APPEND compile_flags "-I${dir}")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2014-11-09 05:52:15 -07:00
|
|
|
|
2023-01-10 10:49:57 -07:00
|
|
|
list(REMOVE_DUPLICATES compile_flags)
|
|
|
|
string(REPLACE ";" " " compile_flags "${compile_flags}")
|
2014-11-09 05:52:15 -07:00
|
|
|
|
|
|
|
set(${_compile_flags} "${compile_flags}" PARENT_SCOPE)
|
|
|
|
endfunction()
|