Add link dependency on shlwapi.lib during build configuration instead of #pragma...
authorAndreas Schuh <andreas.schuh.84@gmail.com>
Wed, 19 Mar 2014 17:32:23 +0000 (17:32 +0000)
committerAndreas Schuh <andreas.schuh.84@gmail.com>
Wed, 19 Mar 2014 17:32:23 +0000 (17:32 +0000)
CMakeLists.txt
src/gflags.cc [changed mode: 0644->0755]
test/gflags_unittest.cc

index fa456ea..66bbd4c 100755 (executable)
@@ -91,7 +91,7 @@ else ()
       check_include_file_cxx ("${fname}.h" HAVE_${FNAME}_H)
     endif ()
   endforeach ()
-  # the following are used in #if not #ifdef
+  # the following are used in #if directives not #ifdef
   bool_to_int (HAVE_STDINT_H)
   bool_to_int (HAVE_SYS_TYPES_H)
   bool_to_int (HAVE_INTTYPES_H)
@@ -219,11 +219,17 @@ include_directories ("${PROJECT_BINARY_DIR}/include/${GFLAGS_NAMESPACE}")
 set (LIB_TARGETS)
 if (BUILD_gflags_LIB)
   add_library (gflags ${GFLAGS_SRCS} ${PRIVATE_HDRS} ${PUBLIC_HDRS})
+  if (HAVE_SHLWAPI_H)
+    target_link_libraries (gflags shlwapi.lib)
+  endif ()
   list (APPEND LIB_TARGETS gflags)
 endif ()
 if (BUILD_gflags_nothreads_LIB)
   add_library (gflags_nothreads ${GFLAGS_SRCS} ${PRIVATE_HDRS} ${PUBLIC_HDRS})
   set_target_properties (gflags_nothreads PROPERTIES COMPILE_DEFINITIONS NO_THREADS)
+  if (HAVE_SHLWAPI_H)
+    target_link_libraries (gflags_nothreads shlwapi.lib)
+  endif ()
   list (APPEND LIB_TARGETS gflags_nothreads)
 endif ()
 
old mode 100644 (file)
new mode 100755 (executable)
index b314f08..285050f
@@ -95,9 +95,8 @@
 #include <errno.h>
 #if defined(HAVE_FNMATCH_H)
 #  include <fnmatch.h>
-#elif defined(_MSC_VER) && defined(HAVE_SHLWAPI_H)
+#elif defined(HAVE_SHLWAPI_H)
 #  include <shlwapi.h>
-#  pragma comment(lib, "shlwapi.lib")
 #endif
 #include <stdarg.h> // For va_list and related operations
 #include <stdio.h>
@@ -1310,7 +1309,7 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked(
 #if defined(HAVE_FNMATCH_H)
             || fnmatch(glob.c_str(), ProgramInvocationName(),      FNM_PATHNAME) == 0
             || fnmatch(glob.c_str(), ProgramInvocationShortName(), FNM_PATHNAME) == 0
-#elif defined(_MSC_VER) && defined(HAVE_SHLWAPI_H)
+#elif defined(HAVE_SHLWAPI_H)
             || PathMatchSpec(glob.c_str(), ProgramInvocationName())
             || PathMatchSpec(glob.c_str(), ProgramInvocationShortName())
 #endif
index 7a44f64..80f7398 100644 (file)
@@ -408,7 +408,7 @@ TEST(FlagFileTest, FilenamesOurfileFirst) {
       -1.0);
 }
 
-#if defined(HAVE_FNMATCH_H) || (defined(_MSC_VER) && defined(HAVE_SHLWAPI_H))  // otherwise glob isn't supported
+#if defined(HAVE_FNMATCH_H) || defined(HAVE_SHLWAPI_H)  // otherwise glob isn't supported
 TEST(FlagFileTest, FilenamesOurfileGlob) {
   FLAGS_test_string = "initial";
   FLAGS_test_bool = false;
@@ -460,7 +460,7 @@ TEST(FlagFileTest, FilenamesOurfileInBigList) {
       1,
       -1.0);
 }
-#endif  // defined(HAVE_FNMATCH_H) || (defined(_MSC_VER) && defined(HAVE_SHLWAPI_H))
+#endif  // defined(HAVE_FNMATCH_H) || defined(HAVE_SHLWAPI_H)
 
 // Tests that a failed flag-from-string read keeps flags at default values
 TEST(FlagFileTest, FailReadFlagsFromString) {