set(OUTPUT_LIB_DIR "lib")

if (MSVC) #MSVC platform we build only Win64  

  #ignore linker warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
  #We would like to ignore warning LNK4099: PDB '.pdb' was not found with '.lib(.obj)' or at ''; linking object as if no debug info 
  # but it is on the non-ignorable warning list

  set(MSVC_LINKER_FLAGS "/Debug /INCREMENTAL /MANIFEST:NO /OPT:REF  /ignore:4099")
  #set(MSVC_LINKER_FLAGS_RELEASE "/DEBUG") # /MANIFEST:NO /INCREMENTAL:NO /OPT:REF /OPT:ICF")

  my_set_flags(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LINKER_FLAGS}")

  #my_set_flags(CMAKE_STATIC_LINKER_FLAGS_RELEASE "/ignore:4221")
  #my_set_flags(CMAKE_STATIC_LINKER_FLAGS_DEBUG "/ignore:4221")

  my_set_flags(CMAKE_SHARED_LINKER_FLAGS   "${CMAKE_SHARED_LINKER_FLAGS} ${MSVC_LINKER_FLAGS}")
  #my_set_flags(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} ${MSVC_LINKER_FLAGS_RELEASE} /ignore:4099")

  add_definitions(-D_CRT_SECURE_NO_WARNINGS)

  set(OUTPUT_LIB_DIR_DEBUG "${OUTPUT_LIB_DIR}/Win64/Debug/${DLL_SUFFIX}")
  set(OUTPUT_LIB_DIR_RELEASE "${OUTPUT_LIB_DIR}/Win64/Release/${DLL_SUFFIX}")

  #MSVC platform we build only Win64  
  # /Oi - use intrinsic functions
  # NDEBUG disables standard C-assertions
  # enable warnings as errors
  set(CompilerFlags
          CMAKE_CXX_FLAGS
          CMAKE_CXX_FLAGS_DEBUG
          CMAKE_CXX_FLAGS_RELEASE
          CMAKE_C_FLAGS
          CMAKE_C_FLAGS_DEBUG
          CMAKE_C_FLAGS_RELEASE
          )

  foreach(CompilerFlag ${CompilerFlags})
    string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
  endforeach()

  my_set_flags(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG /MP")
  my_set_flags(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /O2 /Oi -DNDEBUG /MP")

  my_set_flags(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG /MP")
  my_set_flags(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi /O2 /Oi -DNDEBUG /MP")

endif (MSVC)

add_definitions(-DMUMPS_BUILD)
add_definitions(-DMUMPS_ARITH=MUMPS_ARITH_d)
add_definitions(-Dmetis -Dpord)
#add_definitions(-DALLOW_NON_INIT)

#set all target output (libraries and applications) to the same directory 
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${OUTPUT_LIB_DIR_DEBUG})  
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${OUTPUT_LIB_DIR_RELEASE})  
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${OUTPUT_LIB_DIR_DEBUG})  
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${OUTPUT_LIB_DIR_RELEASE})  
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${OUTPUT_LIB_DIR_DEBUG})  
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${OUTPUT_LIB_DIR_RELEASE})  

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libseq)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/PORD/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
include_directories($ENV{METIS_INSTALL}/include)
