Index: /library/system/SetBdmEnv.cmake
===================================================================
--- /library/system/SetBdmEnv.cmake (revision 812)
+++ /library/system/SetBdmEnv.cmake (revision 827)
@@ -16,7 +16,4 @@
 # THEN IT IS NECESSARY TO CREATE TEXT FILE "\system\WIN32\LOCAL_PATHS.TXT" WITH 
 # COPIES OF THE TWO FOLLOWING LINES AND THEN CORECT ALL THE INVOLVED PATHS
-	IF(NOT ITPP_DIR)
-		SET(ITPP_DIR "${BDM_SOURCE_DIR}\\system\\win32\\itpp-4.0.6")
-	ENDIF(NOT ITPP_DIR)
 	IF(NOT ACML_DIR)
 		SET(ACML_DIR "${BDM_SOURCE_DIR}\\system\\win32\\acml3.6.0")
@@ -26,25 +23,21 @@
 	ADD_DEFINITIONS(-DHAVE_ACML)
 	ADD_DEFINITIONS(/wd4290)
-	ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
+	ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
 	ADD_DEFINITIONS(-DLIBCONFIG_STATIC -DLIBCONFIGXX_STATIC)
+
+	FIND_PACKAGE(ACML REQUIRED)
+	IF(ACML_FOUND)
+		INCLUDE_DIRECTORIES(${ACML_INCLUDE_DIR})
+		LINK_DIRECTORIES(${NATIVE_ACML_LIB_PATH})
+	ENDIF(ACML_FOUND)
+	SET(lapack_libs libacml_dll)
 ENDIF(WIN32)
 IF(APPLE)
-	IF(NOT ITPP_DIR)
-		SET(ITPP_DIR "${BDM_SOURCE_DIR}/system/macosx/itpp-4.0.6")
-	ENDIF(NOT ITPP_DIR)
 	FIND_LIBRARY(FRAMEWORK_VECLIB vecLib)
 	ADD_DEFINITIONS(-DHAVE_XLOCALE_H)
+	SET(lapack_libs ${FRAMEWORK_VECLIB})
 ENDIF(APPLE)
 IF(UNIX)
-	# Generally this directory should not exist!
-	# Use this location is you compile itpp from sources
-	MESSAGE("ITPPDIR $ENV{ITPP_DIR}")
-	IF($ENV{ITPP_DIR})
-		SET(ITPP_DIR $ENV{ITPP_DIR})
-	ELSE($ENV{ITPP_DIR})
-		SET(ITPP_DIR "${BDM_SOURCE_DIR}/system/linux/")
-	ENDIF($ENV{ITPP_DIR})
-	MESSAGE("ITPPDIR ${ITPP_DIR}")
-	#This is for UNIX makefile which does only one release at a time.
+	SET(lapack_libs lapack blas)
 ENDIF(UNIX)
 
@@ -53,15 +46,11 @@
 INCLUDE(CMakeLists.local OPTIONAL)	
 
-#FIND_PACKAGE(ITPP REQUIRED)
-FIND_PACKAGE(ACML COMPONENTS)
 FIND_PACKAGE(Matlab COMPONENTS)
 
+
+## BUILD own ITPP
 INCLUDE_DIRECTORIES("${BDM_SOURCE_DIR}/bdm/base")#${ITPP_INCLUDE_DIR})
 LINK_DIRECTORIES("${BDM_SOURCE_DIR}/bdm/base/itpp")#${NATIVE_ITPP_LIB_PATH})
 
-IF(ACML_FOUND)
-	INCLUDE_DIRECTORIES(${ACML_INCLUDE_DIR})
-	LINK_DIRECTORIES(${NATIVE_ACML_LIB_PATH})
-ENDIF(ACML_FOUND)
 
 IF(UNIX)
@@ -86,21 +75,6 @@
 	add_executable (${FN} ${FN}.cpp)
 	target_link_libraries (${FN} bdm)
-	IF(WIN32)
-		target_link_libraries (${FN} debug itpp_debug)
-		target_link_libraries (${FN} optimized itpp)
-		target_link_libraries (${FN} libacml_dll)
- 	ELSE(WIN32)
- 		IF(APPLE)
- 			target_link_libraries (${FN} ${FRAMEWORK_VECLIB})
- 		ENDIF(APPLE)
-		IF(ITPP_LIBRARY_DEBUG)
-			target_link_libraries (${FN} debug itpp_debug)
-			target_link_libraries (${FN} optimized itpp)
-			target_link_libraries (${FN} lapack blas)
-		ELSE(ITPP_LIBRARY_DEBUG)
-			target_link_libraries (${FN} itpp)	
-			target_link_libraries (${FN} lapack blas)
-	ENDIF(ITPP_LIBRARY_DEBUG)
- 	ENDIF(WIN32)
+	target_link_libraries (${FN} itpp)
+	target_link_libraries (${FN} ${lapack_libs})
 	target_link_libraries (${FN} ${ARGN}) ## Additional libraries can be added to a macro
 ENDMACRO(EXEC)
@@ -108,21 +82,6 @@
 MACRO(LINK_EXEC FN)
 	target_link_libraries (${FN} bdm)
-	IF(WIN32)
-		target_link_libraries (${FN} debug itpp_debug)
-		target_link_libraries (${FN} optimized itpp)
-		target_link_libraries (${FN} libacml_dll)
- 	ELSE(WIN32)
- 		IF(APPLE)
- 			target_link_libraries (${FN} ${FRAMEWORK_VECLIB})
- 		ENDIF(APPLE)
-		IF(ITPP_LIBRARY_DEBUG)
-			target_link_libraries (${FN} debug itpp_debug)
-			target_link_libraries (${FN} optimized itpp)
-			target_link_libraries (${FN} lapack blas)
-		ELSE(ITPP_LIBRARY_DEBUG)
-			target_link_libraries (${FN} itpp)	
-			target_link_libraries (${FN} lapack blas)
-		ENDIF(ITPP_LIBRARY_DEBUG)
- 	ENDIF(WIN32)
+	target_link_libraries (${FN} itpp)
+	target_link_libraries (${FN} ${lapack_libs})
 ENDMACRO(LINK_EXEC)
 	
@@ -146,13 +105,5 @@
 		)
 		# general libraries
-		TARGET_LINK_LIBRARIES("${FN}.${MATLAB_MEX_SUFFIX}" ${MATLAB_LIBRARIES} bdm itpp lapack blas)
-		# platform specific libraries
-		IF(WIN32)
-			target_link_libraries ("${FN}.${MATLAB_MEX_SUFFIX}" libacml_dll)
-		ELSE(WIN32)
-			IF(APPLE)
-				target_link_libraries ("${FN}.${MATLAB_MEX_SUFFIX}" ${FRAMEWORK_VECLIB})
-			ENDIF(APPLE)
-		ENDIF(WIN32)
+		TARGET_LINK_LIBRARIES("${FN}.${MATLAB_MEX_SUFFIX}" ${MATLAB_LIBRARIES} bdm itpp ${lapack_libs})
 		## Additional libraries can be added to a macro
 		target_link_libraries ("${FN}.${MATLAB_MEX_SUFFIX}" ${ARGN}) 
