Replace some SM cmake macros with builtin functions

This commit is contained in:
Martin Natano
2022-03-20 00:25:50 +01:00
committed by teejusb
parent 1ab364c0fa
commit a8b9c1da09
17 changed files with 118 additions and 155 deletions
+3 -37
View File
@@ -1,10 +1,3 @@
# Borrowed from http://stackoverflow.com/a/3323227/445373
function(sm_list_replace container index newvalue)
list(INSERT ${container} ${index} ${newvalue})
math(EXPR __INDEX "${index} + 1")
list(REMOVE_AT ${container} ${__INDEX})
endfunction()
function(sm_append_simple_target_property target property str)
get_target_property(current_property ${target} ${property})
if(current_property)
@@ -16,31 +9,6 @@ function(sm_append_simple_target_property target property str)
endif()
endfunction()
# Borrowed from http://stackoverflow.com/a/7172941/445373 TODO: Upgrade to cmake
# 3.x so that this function is not needed.
function(sm_join values glue output)
string(REPLACE ";"
"${glue}"
_TMP_STR
"${values}")
set(${output} "${_TMP_STR}" PARENT_SCOPE)
endfunction()
function(sm_add_compile_definition target def)
sm_append_simple_target_property(${target} COMPILE_DEFINITIONS ${def})
endfunction()
function(sm_add_compile_flag target flag)
get_target_property(current_property ${target} COMPILE_FLAGS)
if(current_property)
set(current_property "${current_property} ${flag}")
set_target_properties(${target}
PROPERTIES COMPILE_FLAGS "${current_property}")
else()
set_target_properties(${target} PROPERTIES COMPILE_FLAGS ${flag})
endif()
endfunction()
function(sm_add_link_flag target flag)
if(MSVC)
# Use a modified form of sm_append_simple_target_property.
@@ -59,13 +27,11 @@ endfunction()
function(disable_project_warnings projectName)
if(NOT WITH_EXTERNAL_WARNINGS)
if(MSVC)
sm_add_compile_flag(${projectName} "/W0")
target_compile_options(${projectName} PRIVATE "/W0")
elseif(APPLE)
set_target_properties(
${projectName}
PROPERTIES XCODE_ATTRIBUTE_GCC_WARN_INHIBIT_ALL_WARNINGS "YES")
set_property(TARGET ${projectName} PROPERTY XCODE_ATTRIBUTE_GCC_WARN_INHIBIT_ALL_WARNINGS "YES")
else()
set_target_properties(${projectName} PROPERTIES COMPILE_FLAGS "-w")
target_compile_options(${projectName} PRIVATE "-w")
endif()
endif()
endfunction()
+1 -1
View File
@@ -10,7 +10,7 @@ set(SM_FFMPEG_SRC_LIST
"${SM_EXTERN_DIR}"
"/ffmpeg-linux-"
"${SM_FFMPEG_VERSION}")
sm_join("${SM_FFMPEG_SRC_LIST}" "" SM_FFMPEG_SRC_DIR)
list(JOIN SM_FFMPEG_SRC_LIST "" SM_FFMPEG_SRC_DIR)
set(SM_FFMPEG_CONFIGURE_EXE "${SM_FFMPEG_SRC_DIR}/configure")
if(MINGW)
# Borrow from http://stackoverflow.com/q/11845823 string(SUBSTRING