--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -22,6 +22,7 @@ set (SZIP_PUBLIC_HEADERS
     ${SZIP_SRC_SOURCE_DIR}/szlib.h
 )
 
+if (NOT BUILD_SHARED_LIBS)
 add_library (${SZIP_LIB_TARGET} STATIC ${SZIP_SRCS} ${SZIP_PUBLIC_HEADERS})
 #set_target_properties (${SZIP_LIB_TARGET}
 #  PROPERTIES
@@ -37,7 +38,7 @@ set_global_variable (SZIP_LIBRARIES_TO_EXPORT ${SZIP_LIB_TARGET})
 SZIP_SET_LIB_OPTIONS (${SZIP_LIB_TARGET} ${SZIP_LIB_NAME} STATIC)
 set (install_targets ${SZIP_LIB_TARGET})
 
-if (BUILD_SHARED_LIBS)
+else()
   add_library (${SZIP_LIBSH_TARGET} SHARED ${SZIP_SRCS} ${SZIP_PUBLIC_HEADERS})
 #  set_target_properties (${SZIP_LIB_TARGET}
 #    PROPERTIES
@@ -62,8 +63,9 @@ endif ()
 if (SZIP_EXPORTED_TARGETS)
   if (BUILD_SHARED_LIBS)
     INSTALL_TARGET_PDB (${SZIP_LIBSH_TARGET} ${SZIP_INSTALL_BIN_DIR} libraries)
-  endif (BUILD_SHARED_LIBS)
-  INSTALL_TARGET_PDB (${SZIP_LIB_TARGET} ${SZIP_INSTALL_BIN_DIR} libraries)
+  else()
+    INSTALL_TARGET_PDB (${SZIP_LIB_TARGET} ${SZIP_INSTALL_BIN_DIR} libraries)
+  endif()
 
   install (
       TARGETS
