set(commonSources kernel/common/TimeDependent.cpp kernel/common/timing.cpp  kernel/common/utils.cpp  kernel/common/Variable.cpp)
set(laSources kernel/la/GMRES.cpp kernel/la/PETScManager.cpp kernel/la/uBlasKrylovMatrix.cpp kernel/la/LU.cpp
    kernel/la/PETScMatrix.cpp kernel/la/uBlasKrylovSolver.cpp kernel/la/PETScEigenvalueSolver.cpp
    kernel/la/PETScPreconditioner.cpp kernel/la/uBlasLUSolver.cpp kernel/la/PETScKrylovMatrix.cpp kernel/la/PETScVector.cpp
    kernel/la/uBlasVector.cpp kernel/la/PETScKrylovSolver.cpp kernel/la/uBlasDummyPreconditioner.cpp
    kernel/la/PETScLUSolver.cpp kernel/la/uBlasILUPreconditioner.cpp)
set(logSources kernel/log/Buffer.cpp kernel/log/GenericLogger.cpp kernel/log/LogManager.cpp kernel/log/SilentLogger.cpp
    kernel/log/CursesLogger.cpp kernel/log/Logger.cpp kernel/log/LogStream.cpp  kernel/log/TerminalLogger.cpp kernel/log/Event.cpp
    kernel/log/LoggerMacros.cpp kernel/log/Progress.cpp)
set(mainSources kernel/main/init.cpp)
set(parameterSources kernel/parameter/Parameter.cpp kernel/parameter/ParameterSystem.cpp kernel/parameter/Parametrized.cpp
    kernel/parameter/ParameterList.cpp kernel/parameter/ParameterValue.cpp)

add_library(dolfin SHARED ${commonSources} ${laSources} ${logSources} ${mainSources} ${parameterSources})

#if (ENABLE_PETSC)
#    # Check for PETSc
#    if (EXISTS "/usr/local/lib/petsc/bmake/common/base")
#        message("Hej hopp")
#        exec_program(make ARGS -f petsc.conf get_petsc_include PETSC_DIR=/usr/local/lib/petsc OUTPUT_VARIABLE PETSC_CFLAGS)
#        exec_program(make ARGS -f petsc.conf get_petsc_libs PETSC_DIR=/usr/local/lib/petsc OUTPUT_VARIABLE PETSC_LIBS)
#    else (EXISTS "/usr/local/lib/bmake/common/base")
#        message(SEND_ERROR "Unable to find PETSc on your system.")
#    endif (EXISTS "/usr/local/lib/petsc/bmake/common/base")
#
#    # Found PETSc, so set HAVE_PETSC_H
#    add_definitions(-DHAVE_PETSC_H=1)
#    set(CMAKE_CXX_FLAGS "${PETSC_CFLAGS} ${CMAKE_CXX_FLAGS}")
#    target_link_libraries(dolfin PETSC_LIBS)
#endif (ENABLE_PETSC)

if (ENABLE_CURSES)
    message(STATUS "Enabling curses, set ENABLE_CURSES to OFF to disable.")
    target_link_libraries(dolfin ncurses)
else (ENABLE_CURSES)
    message(STATUS "Disabling curses, set ENABLE_CURSES to ON to enable.")
    add_definitions("-DNO_CURSES=1")
endif (ENABLE_CURSES)
