 +			SET(CMAKE_NM ${GCC_NM})
 +			SET(CMAKE_RANLIB ${GCC_RANLIB})
 +		ENDIF()
++	ENDIF()
++	xpCheckCompilerFlags(CMAKE_CXX_FLAGS "-std=c++11 ${DETERMINISTIC} -fno-rtti -fno-exceptions -Wno-unknown-pragmas -Wall -pedantic -Wno-padded -fstack-protector-all -fstrict-aliasing -fwrapv")
++	xpCheckCompilerFlags(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wno-aggressive-loop-optimizations -ftrapv -fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute")
++	IF(HAS_LIBUBSAN)
++		xpCheckCompilerFlags(CMAKE_CXX_FLAGS_DEBUG "-fsanitize=undefined -fsanitize=shift -fsanitize=integer-divide-by-zero -fsanitize=vla-bound -fsanitize=null -fsanitize=return -fsanitize=signed-integer-overflow")
  	ENDIF()
 -	SET(CMAKE_CXX_FLAGS		   "${CMAKE_CXX_FLAGS} -std=c++11 ${DETERMINISTIC} -fno-rtti -fno-exceptions -Wno-unknown-pragmas -Wall -pedantic -Wno-padded  -fstack-protector-all -fstrict-aliasing -fwrapv")
 -# FIXME: some of these are gcc4.9+ only

+  IF(PROFILING)
+  	ADD_DEPENDENCIES(RaptorQ profile)
 	SET_TARGET_PROPERTIES(RaptorQ PROPERTIES COMPILE_FLAGS ${PROFILE_SET})
-ENDIF()
-SET_TARGET_PROPERTIES (
+  ENDIF()
+  SET_TARGET_PROPERTIES (
 	RaptorQ
 	PROPERTIES
 	LINK_FLAGS "-Wl,-z,now,-z,relro"
-)
-
+  )
+  SET(INSTALL_LIBS RaptorQ)
+  SET(theRaptorQLib RaptorQ)
+ELSE()
+  SET(INSTALL_LIBS RaptorQ_static)
+  SET(theRaptorQLib RaptorQ_static)
+ENDIF()
 
 # add main tests
 ADD_EXECUTABLE(libRaptorQ-test EXCLUDE_FROM_ALL test/rfc_test.cpp)

 	ENDIF()
 	# else I do not know your compiler options :)
 ENDIF()
@@ -194,9 +286,14 @@ ENDIF()
 IF(UNIX)
   MESSAGE(STATUS "UNIX system found")
   ADD_DEFINITIONS(-DUNIX)
