################################################################################
FIND_PACKAGE(SWIG 3.0)

if (SWIG_FOUND)
  # Determine python path using python's distutils module
  execute_process(
      COMMAND ${PYTHON_EXECUTABLE} -c
      "from distutils.sysconfig import get_python_inc; print(get_python_inc())"
      OUTPUT_VARIABLE PYTHON_INCLUDE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)

  INCLUDE(${SWIG_USE_FILE})

  INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
  INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
  INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/Source/C)
  INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/Source/CPlusPlus)

  SET(CMAKE_SWIG_FLAGS "")

  set(Swigsrc
    NTPolySwig.i
  )

  foreach(file ${Swigsrc})
    SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES CPLUSPLUS ON)
  endforeach(file)
  set(CMAKE_SWIG_OUTDIR ${CMAKE_BINARY_DIR}/python)
  SWIG_ADD_MODULE(NTPolySwig python ${Swigsrc})
  SWIG_LINK_LIBRARIES(NTPolySwig NTPolyCPP NTPolyWrapper NTPoly ${PYTHON_LIBRARIES})
  set_target_properties(_NTPolySwig PROPERTIES
    ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/python
    LIBRARY_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/python
  )
endif()

################################################################################
FIND_PACKAGE(SWIG 3.0)

if (SWIG_FOUND)
  # Determine python path using python's distutils module
  execute_process(
      COMMAND ${PYTHON_EXECUTABLE} -c
      "from distutils.sysconfig import get_python_inc; print(get_python_inc())"
      OUTPUT_VARIABLE PYTHON_INCLUDE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
  MESSAGE("Using Python Include Path:" ${PYTHON_INCLUDE_PATH})
  INCLUDE(${SWIG_USE_FILE})

  INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
  INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
  INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/Source/C)
  INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/Source/CPlusPlus)

  SET(CMAKE_SWIG_FLAGS "")

  set(Swigsrc
    NTPolySwig.i
  )

  foreach(file ${Swigsrc})
    SET_SOURCE_FILES_PROPERTIES(${file} PROPERTIES CPLUSPLUS ON)
  endforeach(file)
  set(CMAKE_SWIG_OUTDIR ${CMAKE_BINARY_DIR}/python)
  SWIG_ADD_MODULE(NTPolySwig python ${Swigsrc})
  SWIG_LINK_LIBRARIES(NTPolySwig NTPolyCPP NTPolyWrapper NTPoly ${PYTHON_LIBRARIES})
  set_target_properties(_NTPolySwig PROPERTIES
    ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/python
    LIBRARY_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/python
  )
endif()

Print info about choosen python path
Print info about choosen python path
