# Custom CMakeLists.txt for Bigint library.
#
# Copyright (c) 2020, Boyuan Yang <byang@debian.org>
# 
# This file is put into the public domain.

cmake_minimum_required(VERSION 3.6.0)
project(bigint VERSION 2010.04.30 DESCRIPTION "C++ Big Integer Library")

include(GNUInstallDirs)

set(BIGINT_SRC_FILES BigIntegerAlgorithms.cc
                     BigInteger.cc
                     BigIntegerUtils.cc
                     BigUnsigned.cc
                     BigUnsignedInABase.cc)
set(BIGINT_HEADER_FILES BigIntegerLibrary.hh
                        BigIntegerUtils.hh
                        BigUnsigned.hh
                        BigUnsignedInABase.hh
                        NumberlikeArray.hh
                        BigIntegerAlgorithms.hh
                        BigInteger.hh)

add_library(bigint SHARED ${BIGINT_SRC_FILES})
add_library(bigint_Static STATIC ${BIGINT_SRC_FILES})
target_include_directories(bigint PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(bigint_Static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(bigint PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(bigint PROPERTIES SOVERSION 0)
set_target_properties(bigint PROPERTIES PUBLIC_HEADER "${BIGINT_HEADER_FILES}")
set_target_properties(bigint_Static PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(bigint_Static PROPERTIES OUTPUT_NAME "bigint")

configure_file(bigint.pc.in bigint.pc @ONLY)

install(TARGETS bigint
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS bigint_Static
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${CMAKE_BINARY_DIR}/bigint.pc 
    DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
