CMake: Add option to link against system-wide Gflags library
[blender.git] / build_files / cmake / macros.cmake
index b7f6649e5070e5fe0b81e2756bee1365ed1b8b39..0221ac55e4207c074a539c9755a19f030ca9a965 100644 (file)
@@ -491,6 +491,9 @@ function(setup_liblinks
                        target_link_libraries(${target} ${NDOF_LIBRARIES})
                endif()
        endif()
+       if(WITH_SYSTEM_GFLAGS)
+               target_link_libraries(${target} ${GFLAGS_LIBRARIES})
+       endif()
 
        # We put CLEW and CUEW here because OPENSUBDIV_LIBRARIES dpeends on them..
        if(WITH_CYCLES OR WITH_COMPOSITOR OR WITH_OPENSUBDIV)
@@ -659,12 +662,15 @@ function(SETUP_BLENDER_SORTED_LIBS)
                extern_wcwidth
                bf_intern_libmv
                extern_glog
-               extern_gflags
                extern_sdlew
 
                bf_intern_glew_mx
        )
 
+       if(NOT WITH_SYSTEM_GFLAGS)
+               list(APPEND BLENDER_SORTED_LIBS extern_gflags)
+       endif()
+
        if(WITH_COMPOSITOR)
                # added for opencl compositor
                list_insert_before(BLENDER_SORTED_LIBS "bf_blenkernel" "bf_compositor")