message("Building NUMPY:\n@NUMPY_binary@")
set(ENV{LD_LIBRARY_PATH} "@python_install@/lib")
set(ENV{VS_UNICODE_OUTPUT} "")

if(APPLE)
  set(ENV{CFLAGS} "-arch x86_64 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk")
endif()

execute_process(
  COMMAND "@PYTHON_EXECUTABLE@" setup.py build
  WORKING_DIRECTORY "@NUMPY_binary@"
  RESULT_VARIABLE res
  OUTPUT_VARIABLE NUMPY_OUT
  OUTPUT_VARIABLE NUMPY_ERR)

if(NOT ${res} EQUAL 0)
  message("NUMPY Errors detected: \n${NUMPY_OUT}\n${NUMPY_ERR}")
  message(FATAL_ERROR "Error in config of NUMPY")
endif()
message("Numpy build worked.")
