[Bf-blender-cvs] [6239afd] master: [MSVC/LNK4199/Cleanup] Delay loading is causing linker warnings.

Ray Molenkamp noreply at git.blender.org
Mon Jul 18 15:20:14 CEST 2016


Commit: 6239afd36f9216f7944d1320fa8f19cc802b3a19
Author: Ray Molenkamp
Date:   Mon Jul 18 15:16:45 2016 +0200
Branches: master
https://developer.blender.org/rB6239afd36f9216f7944d1320fa8f19cc802b3a19

[MSVC/LNK4199/Cleanup] Delay loading is causing linker warnings.

We recently added delay-loading of the openmp dll's so we no longer had to use
the stub loader, we however put these linker flags on the global linker flags
causing any sub projects not using openmp to spit linker warning 4199 while building,

```
Warning	LNK4199	/DELAYLOAD:vcomp140.dll ignored; no imports found from vcomp140.dll	datatoc	k:\BlenderGit\build_windows_2015a\source\blender\datatoc\LINK	1
```

This patch makes the delay-load only apply to the blender project.

Reviewers: sergey

Subscribers: sergey

Tags: #bf_blender

Differential Revision: https://developer.blender.org/D2092

===================================================================

M	CMakeLists.txt
M	build_files/cmake/macros.cmake

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1c933d3..59ddd97 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1353,17 +1353,6 @@ elseif(WIN32)
 
 		set(PLATFORM_LINKFLAGS_DEBUG "/IGNORE:4099 /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.lib")
 
-		# Use dynamic loading for OpenMP
-		if(WITH_OPENMP)
-			if(MSVC_VERSION EQUAL 1800)
-				set(OPENMP_DLL_NAME "vcomp120")
-			else()
-				set(OPENMP_DLL_NAME "vcomp140")
-			endif()
-			set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /DELAYLOAD:${OPENMP_DLL_NAME}.dll delayimp.lib")
-			set(PLATFORM_LINKFLAGS_DEBUG "${PLATFORM_LINKFLAGS_DEBUG} /DELAYLOAD:${OPENMP_DLL_NAME}d.dll delayimp.lib")
-		endif()
-
 		if(NOT DEFINED LIBDIR)
 
 			# Setup 64bit and 64bit windows systems
@@ -3162,6 +3151,14 @@ add_subdirectory(tests)
 # CPack for generating packages
 include(build_files/cmake/packaging.cmake)
 
+#-----------------------------------------------------------------------------
+# Use dynamic loading for OpenMP
+if(WITH_BLENDER)
+	openmp_delayload(blender)
+endif(WITH_BLENDER)
+if(WITH_PLAYER)
+	openmp_delayload(blenderplayer)
+endif(WITH_PLAYER)
 
 #-----------------------------------------------------------------------------
 # Print Final Configuration
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 5ffd6c4..f57a695 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -1547,3 +1547,21 @@ function(print_all_vars)
 		message("${_var}=${${_var}}")
 	endforeach()
 endfunction()
+
+macro(openmp_delayload
+	projectname
+	)
+		if(MSVC)
+			if(WITH_OPENMP)
+				if(MSVC_VERSION EQUAL 1800)
+					set(OPENMP_DLL_NAME "vcomp120")
+				else()
+					set(OPENMP_DLL_NAME "vcomp140")
+				endif()
+				SET_TARGET_PROPERTIES(${projectname} PROPERTIES LINK_FLAGS_RELEASE "/DELAYLOAD:${OPENMP_DLL_NAME}.dll delayimp.lib")
+				SET_TARGET_PROPERTIES(${projectname} PROPERTIES LINK_FLAGS_DEBUG "/DELAYLOAD:${OPENMP_DLL_NAME}d.dll delayimp.lib")
+				SET_TARGET_PROPERTIES(${projectname} PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/DELAYLOAD:${OPENMP_DLL_NAME}.dll delayimp.lib")
+				SET_TARGET_PROPERTIES(${projectname} PROPERTIES LINK_FLAGS_MINSIZEREL "/DELAYLOAD:${OPENMP_DLL_NAME}.dll delayimp.lib")
+			endif(WITH_OPENMP)
+		endif(MSVC)
+endmacro()




More information about the Bf-blender-cvs mailing list