From 13338379d3cd30831d5baec6fe17b4cf9885f886 Mon Sep 17 00:00:00 2001
From: Sergei Nikulov <sergey.nikulov@gmail.com>
Date: Tue, 9 Jul 2013 18:25:21 +0400
Subject: [PATCH] fix for CMake generated VC2010 static builds

---
 lib/CMakeLists.txt           | 12 ++++--------
 src/CMakeLists.txt           |  7 -------
 tests/libtest/CMakeLists.txt |  8 --------
 tests/server/CMakeLists.txt  |  8 --------
 4 files changed, 4 insertions(+), 31 deletions(-)

diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 09b976c..b2bcf09 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -94,6 +94,10 @@ add_library(
   ${HHEADERS} ${CSOURCES}
   )
 
+if(MSVC AND CURL_STATICLIB)
+  set_target_properties(${LIB_NAME} PROPERTIES STATIC_LIBRARY_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
+endif()
+
 target_link_libraries(${LIB_NAME} ${CURL_LIBS})
 
 if(WIN32)
@@ -108,14 +112,6 @@ setup_curl_dependencies(${LIB_NAME})
 set_target_properties(${LIB_NAME} PROPERTIES PREFIX "")
 set_target_properties(${LIB_NAME} PROPERTIES IMPORT_PREFIX "")
 
-if(MSVC)
-  if(NOT BUILD_RELEASE_DEBUG_DIRS)
-    # Ugly workaround to remove the "/debug" or "/release" in each output
-    set_target_properties(${LIB_NAME} PROPERTIES PREFIX "../")
-    set_target_properties(${LIB_NAME} PROPERTIES IMPORT_PREFIX "../")
-  endif()
-endif()
-
 if(WIN32)
   if(NOT CURL_STATICLIB)
     # Add "_imp" as a suffix before the extension to avoid conflicting with the statically linked "libcurl.lib"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bda8357..0b4556f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -46,13 +46,6 @@ target_link_libraries( ${EXE_NAME} libcurl )
 set_target_properties(${EXE_NAME} PROPERTIES
   DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
 
-if(MSVC)
-  if(NOT BUILD_RELEASE_DEBUG_DIRS)
-    # Ugly workaround to remove the "/debug" or "/release" in each output
-    set_target_properties(${EXE_NAME} PROPERTIES PREFIX "../")
-  endif()
-endif()
-
 #INCLUDE(ModuleInstall OPTIONAL)
 
 install(TARGETS ${EXE_NAME} DESTINATION bin)
diff --git a/tests/libtest/CMakeLists.txt b/tests/libtest/CMakeLists.txt
index 733cdd3..c06b356 100644
--- a/tests/libtest/CMakeLists.txt
+++ b/tests/libtest/CMakeLists.txt
@@ -25,14 +25,6 @@ function(SETUP_TEST TEST_NAME)          # ARGN are the files in the test
   set_target_properties(${TEST_NAME}
     PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
 
-  if(MSVC)
-    if(NOT BUILD_RELEASE_DEBUG_DIRS)
-      # Ugly workaround to remove the "/debug" or "/release" in each output
-      set_target_properties(${TEST_NAME} PROPERTIES PREFIX "../")
-      set_target_properties(${TEST_NAME} PROPERTIES IMPORT_PREFIX "../")
-    endif()
-  endif()
-
 endfunction()
 
 
diff --git a/tests/server/CMakeLists.txt b/tests/server/CMakeLists.txt
index cc5b3e0..ee08345 100644
--- a/tests/server/CMakeLists.txt
+++ b/tests/server/CMakeLists.txt
@@ -33,14 +33,6 @@ function(SETUP_EXECUTABLE TEST_NAME)    # ARGN are the files in the test
   set_target_properties(${TEST_NAME} PROPERTIES
     DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
 
-  if(MSVC)
-    if(NOT BUILD_RELEASE_DEBUG_DIRS)
-      # Ugly workaround to remove the "/debug" or "/release" in each output
-      set_target_properties(${TEST_NAME} PROPERTIES PREFIX "../")
-      set_target_properties(${TEST_NAME} PROPERTIES IMPORT_PREFIX "../")
-    endif()
-  endif()
-
 endfunction()
 
 
-- 
1.8.3.msysgit.0

