cmake_minimum_required(VERSION 3.15)

# set the project name
project(bliss)

option(USE_GMP "Use GNU Multiple Precision Arithmetic library" OFF)

# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

if (MSVC)
    # /permissive- for standard C++ with "and" and "or" logical operators
    add_compile_options(/permissive-)
else()
    # Warnings, optimization, no assertions
    add_compile_options(-Wall -pedantic -O3 -DNDEBUG) #-Wextra -Werror
endif()

if(USE_GMP)
  find_path(GMP_INCLUDE_DIR NAMES gmp.h)
  find_library(GMP_LIBRARIES NAMES gmp libgmp mpir REQUIRED)
  if (MSVC)
    add_compile_options(/DBLISS_USE_GMP /I${GMP_INCLUDE_DIR})
  else()
    add_compile_options(-DBLISS_USE_GMP -I${GMP_INCLUDE_DIR})
  endif()
endif(USE_GMP)

set(
  BLISS_SOURCE_FILES
  src/abstractgraph.cc
  src/bliss_C.cc
  src/defs.cc
  src/digraph.cc
  src/graph.cc
  src/orbit.cc
  src/partition.cc
  src/uintseqhash.cc
  src/utils.cc
)

set(
  BLISS_HEADER_FILES
  src/abstractgraph.hh
  src/bignum.hh
  src/bliss_C.h
  src/defs.hh
  src/digraph.hh
  src/graph.hh
  src/heap.hh
  src/kqueue.hh
  src/orbit.hh
  src/partition.hh
  src/stats.hh
  src/timer.hh
  src/uintseqhash.hh
  src/utils.hh
)

if(BUILD_SHARED_LIBS)
	# Add the shared library
	add_library(bliss SHARED ${BLISS_SOURCE_FILES} ${BLISS_HEADER_FILES})
	set_property(TARGET bliss PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded")
else()
	# Add the static library
	add_library(bliss STATIC ${BLISS_SOURCE_FILES} ${BLISS_HEADER_FILES})
endif()

install(
	TARGETS bliss
	ARCHIVE DESTINATION lib
	LIBRARY DESTINATION lib
	RUNTIME DESTINATION bin
)

install(
	FILES ${BLISS_HEADER_FILES}
	DESTINATION include
)