cmake_minimum_required(VERSION 3.18)
project(morphdG LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=x86-64-v3 -fPIC -fvisibility=hidden")

# Find the Heavyweight Math Libraries
find_package(Kokkos REQUIRED)
find_package(KokkosKernels REQUIRED)

# Tell Pybind11 to use the modern Python search method!
set(PYBIND11_FINDPYTHON ON)
find_package(pybind11 REQUIRED)


# Create the Python Module
# When you add files like aggmesh.cpp or physics.cpp, add them to this list!
pybind11_add_module(morphdg_core 
    bindings/pybind_wrapper.cpp 
)



# Add both lib and lib64 to the search path for the linker
# target_include_directories(morphdg_core PRIVATE /opt/METIS/include)
# target_link_directories(morphdg_core PRIVATE /opt/METIS/lib64 /opt/METIS/lib)
# target_link_libraries(morphdg_core PRIVATE Kokkos::kokkos Kokkos::kokkoskernels metis GKlib)


# Add both lib and lib64 to the search path for the linker
target_include_directories(morphdg_core PRIVATE /opt/METIS/include)
target_link_directories(morphdg_core PRIVATE /opt/METIS/lib64 /opt/METIS/lib)

# Link Kokkos and METIS
target_link_libraries(morphdg_core PRIVATE 
    Kokkos::kokkos 
    Kokkos::kokkoskernels 
    metis 
    GKlib
)


# target_include_directories(morphdg_core PRIVATE /opt/METIS/include)

# target_link_directories(morphdg_core PRIVATE /opt/METIS/lib /opt/METIS/lib64)

# Link Kokkos to the Python Module
# target_link_libraries(morphdg_core PRIVATE Kokkos::kokkos Kokkos::kokkoskernels metis GKlib)

set_target_properties(morphdg_core PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/morphdg)
