cmake_minimum_required(VERSION 3.15)
project (foamgen)

SET(SOURCE_DIR "src/foamgen/cxx")
include_directories(${SOURCE_DIR})
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/)
find_package(GSL REQUIRED)
find_library(VOROLIB voro++ /usr/local/lib)
include_directories(/usr/local/include/voro++ ${GSL_INCLUDE_DIRS})
set (CMAKE_CXX_FLAGS "-O3")
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
    message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
file (GLOB _sources ${SOURCE_DIR}/*.c*)
add_executable(foamreconstr ${_sources})
target_link_libraries(foamreconstr ${VOROLIB} ${GSL_LIBRARIES})
install(TARGETS foamreconstr DESTINATION bin)