mirror of
https://github.com/opencv/opencv.git
synced 2025-06-13 04:52:53 +08:00
Merge pull request #14071 from alalek:cmake_remove_unreferenced_functions
This commit is contained in:
commit
2c3f02c83f
@ -179,12 +179,24 @@ if(CV_GCC OR CV_CLANG)
|
|||||||
string(REPLACE "-ffunction-sections" "" ${flags} "${${flags}}")
|
string(REPLACE "-ffunction-sections" "" ${flags} "${${flags}}")
|
||||||
string(REPLACE "-fdata-sections" "" ${flags} "${${flags}}")
|
string(REPLACE "-fdata-sections" "" ${flags} "${${flags}}")
|
||||||
endforeach()
|
endforeach()
|
||||||
elseif(NOT ((IOS OR ANDROID) AND NOT BUILD_SHARED_LIBS) AND NOT MSVC)
|
else()
|
||||||
# Remove unreferenced functions: function level linking
|
if(MSVC)
|
||||||
add_extra_compiler_option(-ffunction-sections)
|
# TODO: Clang/C2 is not supported
|
||||||
add_extra_compiler_option(-fdata-sections)
|
elseif(((IOS OR ANDROID) AND NOT BUILD_SHARED_LIBS) AND NOT OPENCV_FORCE_FUNCTIONS_SECTIONS)
|
||||||
if(NOT APPLE AND NOT OPENCV_SKIP_GC_SECTIONS)
|
# don't create separate sections for functions/data, reduce package size
|
||||||
set(OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS} -Wl,--gc-sections")
|
else()
|
||||||
|
# Remove unreferenced functions: function level linking
|
||||||
|
add_extra_compiler_option(-ffunction-sections)
|
||||||
|
add_extra_compiler_option(-fdata-sections)
|
||||||
|
if(NOT OPENCV_SKIP_GC_SECTIONS)
|
||||||
|
if(APPLE)
|
||||||
|
set(OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS} -Wl,-dead_strip")
|
||||||
|
set(OPENCV_EXTRA_SHARED_LINKER_FLAGS "${OPENCV_EXTRA_SHARED_LINKER_FLAGS} -Wl,-dead_strip")
|
||||||
|
else()
|
||||||
|
set(OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS} -Wl,--gc-sections")
|
||||||
|
set(OPENCV_EXTRA_SHARED_LINKER_FLAGS "${OPENCV_EXTRA_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user