Commit 4d09ff39 authored by Niccolò Iardella's avatar Niccolò Iardella

Add CMake support (without external dependencies yet)

parent c9307528
# --------------------------------------------------------------------------- #
# Main CMake file for NDOSolver / FiOracle library #
# #
# Niccolo' Iardella #
# Operations Research Group #
# Dipartimento di Informatica #
# Universita' di Pisa #
# --------------------------------------------------------------------------- #
cmake_minimum_required(VERSION 3.8)
# ----- Project description and directories --------------------------------- #
# TODO: set proper version
project(NDOSolver_FiOracle VERSION 1.0.0)
# ----- Requirements -------------------------------------------------------- #
# find_package() is used to find libraries and automatically configure them.
# It requires either a package configuration module (***Config.cmake) or a
# find module (Find***.cmake), usually provided by libraries.
# If we are configuring from the umbrella project, we assume that the valid
# settings are there.
# If we are building this project alone we use its settings but we check
# also for settings in its parent directory.
# TODO: Check if this behaviour is correct
#if (NOT SMS++_CONFIG_ALL)
# include(CMakeCustom.txt OPTIONAL)
# include(../CMakeCustom.txt OPTIONAL)
#endif ()
# This is to use the find modules we provide
#list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
#find_package(CPLEX)
# TODO FindCOINOR
#
# ----- Library ------------------------------------------------------------- #
add_library(NDOFiOracle STATIC)
target_compile_features(NDOFiOracle PUBLIC cxx_std_11)
target_sources(NDOFiOracle PRIVATE
Bundle/Bundle.C
LukFi/LukFiOrcl.C
QPPnltMP/BMinQuad.C
QPPnltMP/MinQuad.C
QPPnltMP/QPPnltMP.C
SubGrad/SubGrad.C
# TODO Optional
# CutPlane/CutPlane.C
# OSIMPSolver/OSIMPSolver.C
)
# Different INSTALL_INTERFACE and BUILD_INTERFACE paths are used when
# generating the target import file (***Targets.cmake), that must be different
# for local build and installation.
target_include_directories(
NDOFiOracle PUBLIC
$<INSTALL_INTERFACE:include/NDOFiOracle>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/Bundle>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/LukFi>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/MPTester>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/NDOSlver>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/OPTUtils>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/QPPnltMP>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/SubGrad>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/SubGrad/Deflection>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/SubGrad/Stepsize>
# TODO Optional
# $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/CutPlane>
# $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/OSIMPSolver>
)
# Alias for testing
add_library(NDOFiOracle::NDOFiOracle ALIAS NDOFiOracle)
# ----- Install instructions ------------------------------------------------ #
# For installing the library and all its CMake modules on the system.
# Not required for local builds (see below).
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/NDOFiOracle)
# Install library
install(TARGETS NDOFiOracle
EXPORT NDOFiOracle-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
# Install headers
install(FILES
${PROJECT_SOURCE_DIR}/Bundle/Bundle.h
${PROJECT_SOURCE_DIR}/Bundle/MPSolver.h
${PROJECT_SOURCE_DIR}/LukFi/LukFiOrcl.h
${PROJECT_SOURCE_DIR}/MPTester/MPTester.h
${PROJECT_SOURCE_DIR}/NDOSlver/NDOSlver.h
${PROJECT_SOURCE_DIR}/NDOSlver/FiOracle.h
${PROJECT_SOURCE_DIR}/OPTUtils/OPTtypes.h
${PROJECT_SOURCE_DIR}/OPTUtils/OPTUtils.h
${PROJECT_SOURCE_DIR}/OPTUtils/OPTvect.h
${PROJECT_SOURCE_DIR}/QPPnltMP/BMinQuad.h
${PROJECT_SOURCE_DIR}/QPPnltMP/MinQuad.h
${PROJECT_SOURCE_DIR}/QPPnltMP/QPPnltMP.h
${PROJECT_SOURCE_DIR}/SubGrad/SubGrad.h
${PROJECT_SOURCE_DIR}/SubGrad/Stepsize.h
${PROJECT_SOURCE_DIR}/SubGrad/Deflection.h
${PROJECT_SOURCE_DIR}/SubGrad/Deflection/Volume.h
${PROJECT_SOURCE_DIR}/SubGrad/Deflection/PrimalDual.h
${PROJECT_SOURCE_DIR}/SubGrad/Stepsize/ColorTV.h
${PROJECT_SOURCE_DIR}/SubGrad/Stepsize/FumeroTV.h
${PROJECT_SOURCE_DIR}/SubGrad/Stepsize/Polyak.h
# TODO Optional
# ${PROJECT_SOURCE_DIR}/CutPlane/CutPlane.h
# ${PROJECT_SOURCE_DIR}/OSIMPSolver/OSIMPSolver.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/NDOFiOracle)
# Install target import file
install(EXPORT NDOFiOracle-targets
FILE NDOFiOracleTargets.cmake
NAMESPACE NDOFiOracle::
DESTINATION ${INSTALL_CONFIGDIR})
# Generate package version file
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/NDOFiOracleConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
# Generate package configuration file
configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/NDOFiOracleConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/NDOFiOracleConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR})
# Install package version and configuration files
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/NDOFiOracleConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/NDOFiOracleConfigVersion.cmake
DESTINATION ${INSTALL_CONFIGDIR})
# ----- Export from the build tree ------------------------------------------ #
# This is needed so other projects can find the library in a local build.
# It does not affect installation.
export(EXPORT NDOFiOracle-targets
FILE ${CMAKE_CURRENT_BINARY_DIR}/NDOFiOracleTargets.cmake
NAMESPACE NDOFiOracle::)
# Register package in user's package registry (~/.cmake/registry)
export(PACKAGE NDOFiOracle)
# --------------------------------------------------------------------------- #
# Package configuration file #
# #
# This file contains instructions on how to generate ***Config.cmake, #
# that is, the file that tells CMake how the package should be #
# configured when found by other projects using find_package(). #
# #
# ***Targets.cmake (to be found alongside this file) is the target import #
# file that tells where the headers and library are. It will be different #
# depending on a local build or an installed package. #
# #
# Niccolo' Iardella #
# Operations Research Group #
# Dipartimento di Informatica #
# Universita' di Pisa #
# --------------------------------------------------------------------------- #
get_filename_component(NDOFiOracle_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(CMakeFindDependencyMacro)
# ----- Requirements -------------------------------------------------------- #
# This is needed to find the custom modules we provide
list(APPEND CMAKE_MODULE_PATH ${MILPSolver_CMAKE_DIR})
list(REMOVE_AT CMAKE_MODULE_PATH -1)
# ----- Import target ------------------------------------------------------- #
if (NOT TARGET SMS++::NDOFiOracle)
include("${NDOFiOracle_CMAKE_DIR}/NDOFiOracleTargets.cmake")
endif ()
set(NDOFiOracle_LIBRARIES NDOFiOracle::NDOFiOracle)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment