diff --git a/CMakeLists.txt b/CMakeLists.txt
index 529c18e..beace9e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,7 +21,11 @@ SET(LOG4CPP_LIBS)
 
 IF (WIN32)
   SET (CMAKE_DEBUG_POSTFIX "d")
-  LIST(APPEND LOG4CPP_CFLAGS -D_CRT_SECURE_NO_WARNINGS -DLOG4CPP_HAS_DLL -DLOG4CPP_BUILD_DLL )
+  IF (BUILD_SHARED_LIBS)
+    LIST(APPEND LOG4CPP_CFLAGS -D_CRT_SECURE_NO_WARNINGS -DLOG4CPP_HAS_DLL -DLOG4CPP_BUILD_DLL )
+  ELSE ()
+    LIST(APPEND LOG4CPP_CFLAGS -D_CRT_SECURE_NO_WARNINGS )
+  ENDIF ()
 ELSE (WIN32)
   IF (APPLE)
 #	LIST(APPEND LOG4CPP_CFLAGS -DLOG4CPP_HAVE_SSTREAM)
@@ -32,7 +36,7 @@ ENDIF (WIN32)
 
 SET ( LOG4CPP_LIBRARY_NAME "orocos-log4cpp" )
 
-ADD_LIBRARY ( ${LOG4CPP_LIBRARY_NAME} SHARED
+ADD_LIBRARY ( ${LOG4CPP_LIBRARY_NAME}
   src/Appender.cpp
   src/AppenderSkeleton.cpp
   src/AppendersFactory.cpp
