cmake_minimum_required(VERSION 3.12.0)
project(demo)

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR} CACHE PATH "Installing prefix of the project" FORCE)
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

if (NOT CMAKE_BUILD_TYPE)
  message(STATUS "No build type selected, default to Release")
  set(CMAKE_BUILD_TYPE "Release")
endif()

set(CMAKE_CXX_STANDARD 11)
find_package(OpenMP REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(fmt REQUIRED)

find_package(PkgConfig REQUIRED)
pkg_check_modules(GSL REQUIRED IMPORTED_TARGET gsl)
pkg_check_modules(CANTERA REQUIRED IMPORTED_TARGET cantera)

# Define path to header files and libraries
set(IDA_DIR /usr/local)
set(COOLPROP_DIR /opt/CoolProp/shared_library/Linux)

set(IDA_INCLUDES ${IDA_DIR}/include)
set(COOLPROP_INCLUDES ${COOLPROP_DIR}/include)

# Search for source files
file(GLOB SRC ${PROJECT_SOURCE_DIR}/src/*.cpp)
add_executable(DropletCombustion ${SRC})

# Link libraries
target_link_directories(DropletCombustion PRIVATE  ${IDA_DIR}/lib ${COOLPROP_DIR}/64bit)
target_link_libraries(DropletCombustion
    PRIVATE 
    PkgConfig::CANTERA
    PkgConfig::GSL
    fmt::fmt
    Eigen3::Eigen
    sundials_nvecopenmp sundials_ida sundials_sunlinsollapackband CoolProp)
target_link_libraries(DropletCombustion PRIVATE OpenMP::OpenMP_CXX)

# Include directories
target_include_directories(DropletCombustion
	PRIVATE ${PROJECT_SOURCE_DIR}/include ${IDA_INCLUDES} ${COOLPROP_INCLUDES})

# Set the output path
install(TARGETS DropletCombustion
	DESTINATION bin)
