COIN-OR::LEMON - Graph Library

Ticket #658: 779318694d8b.patch

File 779318694d8b.patch, 73.4 KB (added by Alpar Juttner, 3 years ago)
  • CMakeLists.txt

    # HG changeset patch
    # User David Torres Sanchez <d.torressanchez@lancaster.ac.uk>
    # Date 1637679578 -3600
    #      Tue Nov 23 15:59:38 2021 +0100
    # Node ID 779318694d8bc7836940300b83705f5267d41cb0
    # Parent  76253ddee3ce2303fa8bac87c0158f46fc035632
    CMAKE rework (#658)
    
    diff --git a/CMakeLists.txt b/CMakeLists.txt
    a b  
    1 cmake_minimum_required(VERSION 2.8)
     1#[[
     2This file is a part of LEMON, a generic C++ optimization library.
    23
    3 if(POLICY CMP0048)
    4   cmake_policy(SET CMP0048 OLD)
    5 endif(POLICY CMP0048)
     4Copyright (C) 2003-2021
     5Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6(Egervary Research Group on Combinatorial Optimization, EGRES).
    67
    7 if(POLICY CMP0043)
    8   cmake_policy(SET CMP0043 NEW)
    9 endif(POLICY CMP0043)
     8Permission to use, modify and distribute this software is granted
     9provided that this copyright notice appears in all copies. For
     10precise terms see the accompanying LICENSE file.
    1011
    11 if(POLICY CMP0026)
    12   #This is for copying the dll's needed by glpk (in lp_test and mip_test)
    13   cmake_policy(SET CMP0026 NEW)
    14 endif(POLICY CMP0026)
     12This software is provided "AS IS" with no warranty of any kind,
     13express or implied, and with no claim as to its suitability for any
     14purpose.
     15]]
    1516
    16 set(PROJECT_NAME "LEMON")
    17 project(${PROJECT_NAME})
     17#[[
     18This file defines the build options and orchestrates the build by including
     19files in the cmake directory.
     20]]
    1821
    19 include(FindPythonInterp)
    20 include(FindWget)
     22cmake_minimum_required(VERSION 3.15)
     23list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
     24
     25project(LEMON LANGUAGES CXX C)
    2126
    22 if(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
    23   include(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
     27# Get version
     28find_package(Hg)
     29if(EXISTS ${PROJECT_SOURCE_DIR}/cmake/LEMONVersion.cmake)
     30  include(${PROJECT_SOURCE_DIR}/cmake/LEMONVersion.cmake)
    2431elseif(DEFINED ENV{LEMON_VERSION})
    25   set(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.")
    26 else()
     32  set(LEMON_VERSION
     33      $ENV{LEMON_VERSION}
     34      CACHE STRING "LEMON version string.")
     35elseif(HG_FOUND)
    2736  execute_process(
    28     COMMAND
    29     hg log -r. --template "{latesttag}"
     37    COMMAND hg log -r. --template "{latesttag}"
    3038    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
    3139    OUTPUT_VARIABLE HG_REVISION_TAG
    32     ERROR_QUIET
    33     OUTPUT_STRIP_TRAILING_WHITESPACE
    34   )
     40    ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
    3541  execute_process(
    36     COMMAND
    37     hg log -r. --template "{latesttagdistance}"
     42    COMMAND hg log -r. --template "{latesttagdistance}"
    3843    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
    3944    OUTPUT_VARIABLE HG_REVISION_DIST
    40     ERROR_QUIET
    41     OUTPUT_STRIP_TRAILING_WHITESPACE
    42   )
     45    ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
    4346  execute_process(
    44     COMMAND
    45     hg log -r. --template "{node|short}"
     47    COMMAND hg log -r. --template "{node|short}"
    4648    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
    4749    OUTPUT_VARIABLE HG_REVISION_ID
    48     ERROR_QUIET
    49     OUTPUT_STRIP_TRAILING_WHITESPACE
    50   )
    51 
     50    ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
    5251  if(HG_REVISION_TAG STREQUAL "")
    5352    set(HG_REVISION_ID "hg-tip")
    5453  else()
     
    6160      set(HG_REVISION ${HG_REVISION_TAG})
    6261    else()
    6362      set(HG_REVISION
    64         "${HG_REVISION_TAG}+${HG_REVISION_DIST}-${HG_REVISION_ID}")
     63          "${HG_REVISION_TAG}+${HG_REVISION_DIST}-${HG_REVISION_ID}")
    6564    endif()
    6665  endif()
    67 
    68   set(LEMON_VERSION ${HG_REVISION} CACHE STRING "LEMON version string.")
     66  set(LEMON_VERSION ${HG_REVISION})
    6967endif()
    7068
    71 set(PROJECT_VERSION ${LEMON_VERSION})
    72 
    73 set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
    74 
    75 find_package(Doxygen)
    76 find_package(Ghostscript)
    77 
     69# OS
    7870if(WIN32)
    79   set(LEMON_WIN32 TRUE)
    80 endif(WIN32)
    81 
    82 set(LEMON_ENABLE_GLPK YES CACHE STRING "Enable GLPK solver backend.")
    83 set(LEMON_ENABLE_ILOG YES CACHE STRING "Enable ILOG (CPLEX) solver backend.")
    84 set(LEMON_ENABLE_COIN YES CACHE STRING "Enable COIN solver backend.")
    85 set(LEMON_ENABLE_SOPLEX YES CACHE STRING "Enable SoPlex solver backend.")
    86 
    87 if(LEMON_ENABLE_GLPK)
    88   find_package(GLPK 4.33)
    89   if(GLPK_FOUND)
    90     set(LEMON_HAVE_LP TRUE)
    91     set(LEMON_HAVE_MIP TRUE)
    92     set(LEMON_HAVE_GLPK TRUE)
    93   endif(GLPK_FOUND)
    94 endif(LEMON_ENABLE_GLPK)
    95 if(LEMON_ENABLE_ILOG)
    96   find_package(ILOG)
    97   if(ILOG_FOUND)
    98     set(LEMON_HAVE_LP TRUE)
    99     set(LEMON_HAVE_MIP TRUE)
    100     set(LEMON_HAVE_CPLEX TRUE)
    101   endif(ILOG_FOUND)
    102 endif(LEMON_ENABLE_ILOG)
    103 if(LEMON_ENABLE_COIN)
    104   find_package(COIN)
    105   if(COIN_FOUND)
    106     set(LEMON_HAVE_LP TRUE)
    107     set(LEMON_HAVE_MIP TRUE)
    108     set(LEMON_HAVE_CLP TRUE)
    109     set(LEMON_HAVE_CBC TRUE)
    110   endif(COIN_FOUND)
    111 endif(LEMON_ENABLE_COIN)
    112 if(LEMON_ENABLE_SOPLEX)
    113   find_package(SOPLEX)
    114   if(SOPLEX_FOUND)
    115     set(LEMON_HAVE_LP TRUE)
    116     set(LEMON_HAVE_SOPLEX TRUE)
    117   endif(SOPLEX_FOUND)
    118 endif(LEMON_ENABLE_SOPLEX)
    119 
    120 if(ILOG_FOUND)
    121   set(DEFAULT_LP "CPLEX")
    122   set(DEFAULT_MIP "CPLEX")
    123 elseif(COIN_FOUND)
    124   set(DEFAULT_LP "CLP")
    125   set(DEFAULT_MIP "CBC")
    126 elseif(GLPK_FOUND)
    127   set(DEFAULT_LP "GLPK")
    128   set(DEFAULT_MIP "GLPK")
    129 elseif(SOPLEX_FOUND)
    130   set(DEFAULT_LP "SOPLEX")
     71  set(LEMON_WIN32 ON)
    13172endif()
    13273
    133 if(NOT LEMON_DEFAULT_LP OR
    134     (NOT ILOG_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CPLEX")) OR
    135     (NOT COIN_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CLP")) OR
    136     (NOT GLPK_FOUND AND (LEMON_DEFAULT_LP STREQUAL "GLPK")) OR
    137     (NOT SOPLEX_FOUND AND (LEMON_DEFAULT_LP STREQUAL "SOPLEX")))
    138   set(LEMON_DEFAULT_LP ${DEFAULT_LP} CACHE STRING
    139     "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)" FORCE)
    140 else()
    141   set(LEMON_DEFAULT_LP ${DEFAULT_LP} CACHE STRING
    142     "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)")
    143 endif()
    144 if(NOT LEMON_DEFAULT_MIP OR
    145     (NOT ILOG_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CPLEX")) OR
    146     (NOT COIN_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CBC")) OR
    147     (NOT GLPK_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "GLPK")))
    148   set(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
    149     "Default MIP solver backend (GLPK, CPLEX or CBC)" FORCE)
    150 else()
    151   set(LEMON_DEFAULT_MIP ${DEFAULT_MIP} CACHE STRING
    152     "Default MIP solver backend (GLPK, CPLEX or CBC)")
    153 endif()
     74# Building Options #
    15475
    155 if( ( ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") AND
    156       ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_GREATER_EQUAL "4.8") )
    157     OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
    158     OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
    159     )
    160   set(LEMON_NO_UNUSED_LOCAL_TYPEDEF_WARNINGS TRUE)
    161 endif()
    162 
    163 if(DEFINED ENV{LEMON_CXX_WARNING})
    164   set(CXX_WARNING $ENV{LEMON_CXX_WARNING})
    165 else()
    166   if( ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
    167       OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
    168       )
    169     set(CXX_WARNING "-Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas")
    170     set(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb")
    171     set(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
    172   elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
    173     set(CXX_WARNING "-Wall -W -Wunused -Wformat=2 -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wsign-promo -Woverloaded-virtual -fno-strict-aliasing -Wno-unknown-pragmas")
    174     set(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb")
    175     set(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
    176   elseif(MSVC)
    177     # This part is unnecessary 'casue the same is set by the lemon/core.h.
    178     # Still kept as an example.
    179 
    180     # set(CXX_WARNING "/wd4250 /wd4267 /wd4355 /wd4503 /wd4800 /wd4996")
     76# Solvers
     77option(LEMON_ENABLE_GLPK "Enable GLPK solver backend." OFF)
     78option(LEMON_ENABLE_ILOG "Enable ILOG (CPLEX) solver backend." OFF)
     79option(LEMON_ENABLE_COIN "Enable COIN solver backend." OFF)
     80option(LEMON_ENABLE_SOPLEX "Enable SoPlex solver backend." OFF)
    18181
    182     # Suppressed warnings:
    183     # C4250: 'class1' : inherits 'class2::member' via dominance
    184     # C4267: conversion from 'size_t' to 'type', possible loss of data
    185     # C4355: 'this' : used in base member initializer list
    186     # C4503: 'function' : decorated name length exceeded, name was truncated
    187     # C4800: 'type' : forcing value to bool 'true' or 'false'
    188     #        (performance warning)
    189     # C4996: 'function': was declared deprecated
    190   else()
    191     set(CXX_WARNING "-Wall")
    192   endif()
    193 endif()
    194 set(LEMON_CXX_WARNING_FLAGS ${CXX_WARNING} CACHE STRING "LEMON warning flags.")
    195 
    196 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}")
    197 
    198 if(MSVC)
    199   set( CMAKE_CXX_FLAGS "/bigobj ${CMAKE_CXX_FLAGS}")
    200   set( CMAKE_CXX_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
    201     "Flags used by the C++ compiler during maintainer builds." FORCE
    202     )
    203   set( CMAKE_C_FLAGS_MAINTAINER "/WX ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
    204     "Flags used by the C compiler during maintainer builds." FORCE
    205     )
    206   set( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
    207     "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
    208     "Flags used for linking binaries during maintainer builds." FORCE
    209     )
    210   set( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
    211     "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
    212     "Flags used by the shared libraries linker during maintainer builds."
    213      FORCE
    214     )
    215 else()
    216   set( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb -O0" CACHE STRING
    217     "Flags used by the C++ compiler during maintainer builds." FORCE
    218     )
    219   set( CMAKE_C_FLAGS_MAINTAINER "-Werror -O0" CACHE STRING
    220     "Flags used by the C compiler during maintainer builds." FORCE
    221     )
    222   set( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
    223     "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING
    224     "Flags used for linking binaries during maintainer builds." FORCE
    225     )
    226   set( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
    227     "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" CACHE STRING
    228     "Flags used by the shared libraries linker during maintainer builds." FORCE)
    229 endif()
    230 
    231 mark_as_advanced(
    232     CMAKE_CXX_FLAGS_MAINTAINER
    233     CMAKE_C_FLAGS_MAINTAINER
    234     CMAKE_EXE_LINKER_FLAGS_MAINTAINER
    235     CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
    236 
    237 if(CMAKE_CONFIGURATION_TYPES)
    238   list(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
    239   list(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
    240   set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
    241       "Add the configurations that we need"
    242       FORCE)
    243  endif()
     82# Building + Testing
     83option(LEMON_BUILD_TESTING "Enable unit tests" ON)
     84option(LEMON_MAINTAINER "Enable Maintainer options." OFF)
     85option(LEMON_BUILD_DOCS "Enable docs using doxygen and ghostcript" OFF)
     86option(LEMON_BUILD_TOOLS "Enable project in tools directory" OFF)
     87option(LEMON_BUILD_DEMO "Enable project in demo directory" OFF)
     88option(LEMON_BUILD_ARCHIVE "Enable to create archive" OFF)
     89option(LEMON_BUILD_CPACK "Enable to create cpack" OFF)
     90option(LEMON_TEST_WITH_VALGRIND "Run the tests with valgrind" OFF)
     91option(LEMON_ENABLE_DEBUG "Display debug messages" OFF)
    24492
    24593if(NOT CMAKE_BUILD_TYPE)
    24694  set(CMAKE_BUILD_TYPE "Release")
    24795endif()
    24896
    249 set( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
    250     "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer."
    251     FORCE )
    252 
    253 set_directory_properties(PROPERTIES
    254   COMPILE_DEFINITIONS
    255   $<$<OR:$<CONFIG:Debug>,$<CONFIG:Maintainer>>:LEMON_ENABLE_DEBUG>
    256 )
    257 
    258 include(CheckTypeSize)
    259 CHECK_TYPE_SIZE("long long" LONG_LONG)
    260 set(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
    261 
    262 include(FindThreads)
    263 
    264 if(NOT LEMON_THREADING)
    265   if(CMAKE_USE_PTHREADS_INIT)
    266     set(LEMON_THREADING "Pthread")
    267   elseif(CMAKE_USE_WIN32_THREADS_INIT)
    268     set(LEMON_THREADING "Win32")
    269   else()
    270     set(LEMON_THREADING "None")
    271   endif()
    272 endif()
    273 
    274 set( LEMON_THREADING "${LEMON_THREADING}" CACHE STRING
    275   "Choose the threading library, options are: Pthread Win32 None."
    276   FORCE )
    277 
    278 if(LEMON_THREADING STREQUAL "Pthread")
    279   set(LEMON_USE_PTHREAD TRUE)
    280 elseif(LEMON_THREADING STREQUAL "Win32")
    281   set(LEMON_USE_WIN32_THREADS TRUE)
    282 endif()
     97set(CMAKE_BUILD_TYPE
     98    "${CMAKE_BUILD_TYPE}"
     99    CACHE
     100      STRING
     101      "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
     102      FORCE)
    283103
    284104enable_testing()
    285105
     106# Add LEMON::LEMON target
     107include(base)
    286108
    287 include(CheckCXXCompilerFlag)
    288 CHECK_CXX_COMPILER_FLAG("-std=c++11" LEMON_CXX11)
    289 if(LEMON_CXX11)
    290   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
    291 endif()
    292 
    293 
    294 if(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
     109if(LEMON_MAINTAINER)
    295110  add_custom_target(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
    296111else()
    297112  add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
    298113endif()
    299114
    300 add_subdirectory(lemon)
    301 if(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
    302   add_subdirectory(contrib)
    303   add_subdirectory(demo)
    304   add_subdirectory(tools)
    305   add_subdirectory(doc)
     115if(LEMON_BUILD_TESTING)
    306116  add_subdirectory(test)
    307117endif()
    308118
    309 configure_file(
    310   ${PROJECT_SOURCE_DIR}/cmake/LEMONConfig.cmake.in
    311   ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
    312   @ONLY
    313 )
    314 if(UNIX)
    315   install(
    316     FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
    317     DESTINATION share/lemon/cmake
    318   )
    319 elseif(WIN32)
    320   install(
    321     FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
    322     DESTINATION cmake
    323   )
     119if(LEMON_BUILD_TOOLS)
     120  add_subdirectory(tools)
     121endif()
     122
     123if(LEMON_BUILD_DOCS)
     124  add_subdirectory(doc)
    324125endif()
    325126
    326 configure_file(
    327   ${PROJECT_SOURCE_DIR}/cmake/version.cmake.in
    328   ${PROJECT_BINARY_DIR}/cmake/version.cmake
    329   @ONLY
    330 )
    331 
    332 set(ARCHIVE_BASE_NAME ${CMAKE_PROJECT_NAME})
    333 string(TOLOWER ${ARCHIVE_BASE_NAME} ARCHIVE_BASE_NAME)
    334 set(ARCHIVE_NAME ${ARCHIVE_BASE_NAME}-${PROJECT_VERSION})
    335 add_custom_target(dist
    336   COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
    337   COMMAND hg archive ${ARCHIVE_NAME}
    338   COMMAND cmake -E copy cmake/version.cmake ${ARCHIVE_NAME}/cmake/version.cmake
    339   COMMAND tar -czf ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_NAME}
    340   COMMAND zip -r ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.zip ${ARCHIVE_NAME}
    341   COMMAND cmake -E copy_directory doc/html ${ARCHIVE_NAME}/doc/html
    342   COMMAND tar -czf ${ARCHIVE_NAME}.tar.gz ${ARCHIVE_NAME}
    343   COMMAND zip -r ${ARCHIVE_NAME}.zip ${ARCHIVE_NAME}
    344   COMMAND cmake -E copy_directory doc/html ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
    345   COMMAND tar -czf ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
    346   COMMAND zip -r ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.zip ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
    347   COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
    348   COMMAND cmake -E remove_directory ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
    349   DEPENDS html
    350   WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
    351 
    352 # CPACK config (Basically for NSIS)
    353 if(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
    354   set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
    355   set(CPACK_PACKAGE_VENDOR "EGRES")
    356   set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
    357     "LEMON - Library for Efficient Modeling and Optimization in Networks")
    358   set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
    359 
    360   set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
    361 
    362   set(CPACK_PACKAGE_INSTALL_DIRECTORY
    363     "${PROJECT_NAME} ${PROJECT_VERSION}")
    364   set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
    365     "${PROJECT_NAME} ${PROJECT_VERSION}")
    366 
    367   set(CPACK_COMPONENTS_ALL headers library html_documentation bin)
     127if(LEMON_BUILD_DEMO)
     128  add_subdirectory(demo)
     129endif()
    368130
    369   set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
    370   set(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
    371   set(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
    372   set(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
    373 
    374   set(CPACK_COMPONENT_HEADERS_DESCRIPTION
    375     "C++ header files")
    376   set(CPACK_COMPONENT_LIBRARY_DESCRIPTION
    377     "DLL and import library")
    378   set(CPACK_COMPONENT_BIN_DESCRIPTION
    379     "Command line utilities")
    380   set(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
    381     "Doxygen generated documentation")
    382 
    383   set(CPACK_COMPONENT_HEADERS_DEPENDS library)
    384 
    385   set(CPACK_COMPONENT_HEADERS_GROUP "Development")
    386   set(CPACK_COMPONENT_LIBRARY_GROUP "Development")
    387   set(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
    388 
    389   set(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
    390     "Components needed to develop software using LEMON")
    391   set(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
    392     "Documentation of LEMON")
     131if(LEMON_BUILD_ARCHIVE)
     132  include(archive)
     133endif()
    393134
    394   set(CPACK_ALL_INSTALL_TYPES Full Developer)
    395 
    396   set(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
    397   set(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
    398   set(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
    399 
    400   set(CPACK_GENERATOR "NSIS")
    401   set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
    402   set(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
    403   #set(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
    404   set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
    405   set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
    406   set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
    407   set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
    408   set(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
    409   set(CPACK_NSIS_CREATE_ICONS_EXTRA "
    410     CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
    411     ")
    412   set(CPACK_NSIS_DELETE_ICONS_EXTRA "
    413     !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
    414     Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"
    415     ")
    416 
    417   include(CPack)
     135if(LEMON_BUILD_CPACK)
     136  include(cpack)
    418137endif()
  • new file cmake/Config.cmake.in

    diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in
    new file mode 100644
    - +  
     1@PACKAGE_INIT@
     2
     3include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
  • cmake/FindCOIN.cmake

    diff --git a/cmake/FindCOIN.cmake b/cmake/FindCOIN.cmake
    a b  
    1 set(COIN_ROOT_DIR "" CACHE PATH "COIN root directory")
     1#[[
     2This file is a part of LEMON, a generic C++ optimization library.
     3
     4Copyright (C) 2003-2021
     5Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6(Egervary Research Group on Combinatorial Optimization, EGRES).
     7
     8Permission to use, modify and distribute this software is granted
     9provided that this copyright notice appears in all copies. For
     10precise terms see the accompanying LICENSE file.
     11
     12This software is provided "AS IS" with no warranty of any kind,
     13express or implied, and with no claim as to its suitability for any
     14purpose.
     15]]
     16
     17#[[
     18This file finds the necessary components of the COIN-OR libraries.
     19Cbc, Clp, Cgl, Osi, and Vol
     20]]
     21
     22set(COIN_ROOT_DIR
     23    ""
     24    CACHE PATH "COIN root directory")
    225
    326find_path(COIN_INCLUDE_DIR coin/CoinUtilsConfig.h
    4   HINTS ${COIN_ROOT_DIR}/include
    5 )
    6 find_library(COIN_CBC_LIBRARY
     27          HINTS ${COIN_ROOT_DIR}/include)
     28find_library(
     29  COIN_CBC_LIBRARY
    730  NAMES Cbc libCbc
    831  HINTS ${COIN_ROOT_DIR}/lib/coin
    9   HINTS ${COIN_ROOT_DIR}/lib
    10 )
    11 find_library(COIN_CBC_SOLVER_LIBRARY
     32  HINTS ${COIN_ROOT_DIR}/lib)
     33find_library(
     34  COIN_CBC_SOLVER_LIBRARY
    1235  NAMES CbcSolver libCbcSolver
    1336  HINTS ${COIN_ROOT_DIR}/lib/coin
    14   HINTS ${COIN_ROOT_DIR}/lib
    15 )
    16 find_library(COIN_CGL_LIBRARY
     37  HINTS ${COIN_ROOT_DIR}/lib)
     38find_library(
     39  COIN_CGL_LIBRARY
    1740  NAMES Cgl libCgl
    1841  HINTS ${COIN_ROOT_DIR}/lib/coin
    19   HINTS ${COIN_ROOT_DIR}/lib
    20 )
    21 find_library(COIN_CLP_LIBRARY
     42  HINTS ${COIN_ROOT_DIR}/lib)
     43find_library(
     44  COIN_CLP_LIBRARY
    2245  NAMES Clp libClp
    2346  HINTS ${COIN_ROOT_DIR}/lib/coin
    24   HINTS ${COIN_ROOT_DIR}/lib
    25 )
    26 find_library(COIN_COIN_UTILS_LIBRARY
     47  HINTS ${COIN_ROOT_DIR}/lib)
     48find_library(
     49  COIN_COIN_UTILS_LIBRARY
    2750  NAMES CoinUtils libCoinUtils
    2851  HINTS ${COIN_ROOT_DIR}/lib/coin
    29   HINTS ${COIN_ROOT_DIR}/lib
    30 )
    31 find_library(COIN_OSI_LIBRARY
     52  HINTS ${COIN_ROOT_DIR}/lib)
     53find_library(
     54  COIN_OSI_LIBRARY
    3255  NAMES Osi libOsi
    3356  HINTS ${COIN_ROOT_DIR}/lib/coin
    34   HINTS ${COIN_ROOT_DIR}/lib
    35 )
    36 find_library(COIN_OSI_CBC_LIBRARY
     57  HINTS ${COIN_ROOT_DIR}/lib)
     58find_library(
     59  COIN_OSI_CBC_LIBRARY
    3760  NAMES OsiCbc libOsiCbc
    3861  HINTS ${COIN_ROOT_DIR}/lib/coin
    39   HINTS ${COIN_ROOT_DIR}/lib
    40 )
    41 find_library(COIN_OSI_CLP_LIBRARY
     62  HINTS ${COIN_ROOT_DIR}/lib)
     63find_library(
     64  COIN_OSI_CLP_LIBRARY
    4265  NAMES OsiClp libOsiClp
    4366  HINTS ${COIN_ROOT_DIR}/lib/coin
    44   HINTS ${COIN_ROOT_DIR}/lib
    45 )
    46 find_library(COIN_OSI_VOL_LIBRARY
     67  HINTS ${COIN_ROOT_DIR}/lib)
     68find_library(
     69  COIN_OSI_VOL_LIBRARY
    4770  NAMES OsiVol libOsiVol
    4871  HINTS ${COIN_ROOT_DIR}/lib/coin
    49   HINTS ${COIN_ROOT_DIR}/lib
    50 )
    51 find_library(COIN_VOL_LIBRARY
     72  HINTS ${COIN_ROOT_DIR}/lib)
     73find_library(
     74  COIN_VOL_LIBRARY
    5275  NAMES Vol libVol
    5376  HINTS ${COIN_ROOT_DIR}/lib/coin
    54   HINTS ${COIN_ROOT_DIR}/lib
    55 )
     77  HINTS ${COIN_ROOT_DIR}/lib)
    5678
    57 find_library(COIN_ZLIB_LIBRARY
     79find_library(
     80  COIN_ZLIB_LIBRARY
    5881  NAMES z libz
    5982  HINTS ${COIN_ROOT_DIR}/lib/coin
    60   HINTS ${COIN_ROOT_DIR}/lib
    61 )
    62 find_library(COIN_BZ2_LIBRARY
     83  HINTS ${COIN_ROOT_DIR}/lib)
     84find_library(
     85  COIN_BZ2_LIBRARY
    6386  NAMES bz2 libbz2
    6487  HINTS ${COIN_ROOT_DIR}/lib/coin
    65   HINTS ${COIN_ROOT_DIR}/lib
    66 )
     88  HINTS ${COIN_ROOT_DIR}/lib)
    6789
    68 find_library(COIN_PTHREADS_LIBRARY
     90find_library(
     91  COIN_PTHREADS_LIBRARY
    6992  NAMES pthreads libpthreads
    7093  HINTS ${COIN_ROOT_DIR}/lib/coin
    71   HINTS ${COIN_ROOT_DIR}/lib
    72 )
     94  HINTS ${COIN_ROOT_DIR}/lib)
    7395
    7496include(FindPackageHandleStandardArgs)
    75 FIND_PACKAGE_HANDLE_STANDARD_ARGS(COIN DEFAULT_MSG
     97find_package_handle_standard_args(
     98  COIN
     99  DEFAULT_MSG
    76100  COIN_INCLUDE_DIR
    77101  COIN_CBC_LIBRARY
    78102  COIN_CBC_SOLVER_LIBRARY
     
    92116  if(COIN_ZLIB_LIBRARY)
    93117    set(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARIES};${COIN_ZLIB_LIBRARY}")
    94118  endif(COIN_ZLIB_LIBRARY)
    95    if(COIN_BZ2_LIBRARY)
     119  if(COIN_BZ2_LIBRARY)
    96120    set(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARIES};${COIN_BZ2_LIBRARY}")
    97121  endif(COIN_BZ2_LIBRARY)
    98    if(COIN_PTHREADS_LIBRARY)
     122  if(COIN_PTHREADS_LIBRARY)
    99123    set(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARIES};${COIN_PTHREADS_LIBRARY}")
    100124  endif(COIN_PTHREADS_LIBRARY)
    101   set(COIN_CBC_LIBRARIES "${COIN_CBC_LIBRARY};${COIN_CBC_SOLVER_LIBRARY};${COIN_CGL_LIBRARY};${COIN_OSI_LIBRARY};${COIN_OSI_CBC_LIBRARY};${COIN_OSI_CLP_LIBRARY};${COIN_CLP_LIBRARIES}")
     125  set(COIN_CBC_LIBRARIES
     126      "${COIN_CBC_LIBRARY};${COIN_CBC_SOLVER_LIBRARY};${COIN_CGL_LIBRARY};${COIN_OSI_LIBRARY};${COIN_OSI_CBC_LIBRARY};${COIN_OSI_CLP_LIBRARY};${COIN_CLP_LIBRARIES}"
     127  )
    102128  set(COIN_LIBRARIES ${COIN_CBC_LIBRARIES})
    103129endif(COIN_FOUND)
    104130
     
    115141  COIN_OSI_VOL_LIBRARY
    116142  COIN_VOL_LIBRARY
    117143  COIN_ZLIB_LIBRARY
    118   COIN_BZ2_LIBRARY
    119 )
     144  COIN_BZ2_LIBRARY)
  • cmake/FindGLPK.cmake

    diff --git a/cmake/FindGLPK.cmake b/cmake/FindGLPK.cmake
    a b  
    1 set(GLPK_ROOT_DIR "" CACHE PATH "GLPK root directory")
     1#[[
     2This file is a part of LEMON, a generic C++ optimization library.
     3
     4Copyright (C) 2003-2021
     5Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6(Egervary Research Group on Combinatorial Optimization, EGRES).
     7
     8Permission to use, modify and distribute this software is granted
     9provided that this copyright notice appears in all copies. For
     10precise terms see the accompanying LICENSE file.
     11
     12This software is provided "AS IS" with no warranty of any kind,
     13express or implied, and with no claim as to its suitability for any
     14purpose.
     15]]
     16
     17#[[
     18This file finds the necessary components for the GLPK solver.
     19]]
     20
     21set(GLPK_ROOT_DIR
     22    ""
     23    CACHE PATH "GLPK root directory")
    224
    325set(GLPK_REGKEY "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Glpk;InstallPath]")
    426get_filename_component(GLPK_ROOT_PATH ${GLPK_REGKEY} ABSOLUTE)
    527
    6 find_path(GLPK_INCLUDE_DIR
    7   glpk.h
     28find_path(
     29  GLPK_INCLUDE_DIR glpk.h
    830  PATHS ${GLPK_REGKEY}/include
    9   HINTS ${GLPK_ROOT_DIR}/include
    10 )
    11 find_library(GLPK_LIBRARY
    12   glpk
     31  HINTS ${GLPK_ROOT_DIR}/include)
     32
     33find_library(
     34  GLPK_LIBRARY glpk
    1335  PATHS ${GLPK_REGKEY}/lib
    14   HINTS ${GLPK_ROOT_DIR}/lib
    15 )
     36  HINTS ${GLPK_ROOT_DIR}/lib)
    1637
    1738if(GLPK_INCLUDE_DIR AND GLPK_LIBRARY)
    1839  file(READ ${GLPK_INCLUDE_DIR}/glpk.h GLPK_GLPK_H)
    1940
    20   string(REGEX MATCH "define[ ]+GLP_MAJOR_VERSION[ ]+[0-9]+" GLPK_MAJOR_VERSION_LINE "${GLPK_GLPK_H}")
    21   string(REGEX REPLACE "define[ ]+GLP_MAJOR_VERSION[ ]+([0-9]+)" "\\1" GLPK_VERSION_MAJOR "${GLPK_MAJOR_VERSION_LINE}")
     41  string(REGEX MATCH "define[ ]+GLP_MAJOR_VERSION[ ]+[0-9]+"
     42               GLPK_MAJOR_VERSION_LINE "${GLPK_GLPK_H}")
     43  string(REGEX REPLACE "define[ ]+GLP_MAJOR_VERSION[ ]+([0-9]+)" "\\1"
     44                       GLPK_VERSION_MAJOR "${GLPK_MAJOR_VERSION_LINE}")
    2245
    23   string(REGEX MATCH "define[ ]+GLP_MINOR_VERSION[ ]+[0-9]+" GLPK_MINOR_VERSION_LINE "${GLPK_GLPK_H}")
    24   string(REGEX REPLACE "define[ ]+GLP_MINOR_VERSION[ ]+([0-9]+)" "\\1" GLPK_VERSION_MINOR "${GLPK_MINOR_VERSION_LINE}")
     46  string(REGEX MATCH "define[ ]+GLP_MINOR_VERSION[ ]+[0-9]+"
     47               GLPK_MINOR_VERSION_LINE "${GLPK_GLPK_H}")
     48  string(REGEX REPLACE "define[ ]+GLP_MINOR_VERSION[ ]+([0-9]+)" "\\1"
     49                       GLPK_VERSION_MINOR "${GLPK_MINOR_VERSION_LINE}")
    2550
    2651  set(GLPK_VERSION_STRING "${GLPK_VERSION_MAJOR}.${GLPK_VERSION_MINOR}")
    2752
     
    3055      message(SEND_ERROR "unexpected version string")
    3156    endif(GLPK_FIND_VERSION_COUNT GREATER 2)
    3257
    33     math(EXPR GLPK_REQUESTED_VERSION "${GLPK_FIND_VERSION_MAJOR}*100 + ${GLPK_FIND_VERSION_MINOR}")
    34     math(EXPR GLPK_FOUND_VERSION "${GLPK_VERSION_MAJOR}*100 + ${GLPK_VERSION_MINOR}")
     58    math(EXPR GLPK_REQUESTED_VERSION
     59         "${GLPK_FIND_VERSION_MAJOR}*100 + ${GLPK_FIND_VERSION_MINOR}")
     60    math(EXPR GLPK_FOUND_VERSION
     61         "${GLPK_VERSION_MAJOR}*100 + ${GLPK_VERSION_MINOR}")
    3562
    3663    if(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION)
    3764      set(GLPK_PROPER_VERSION_FOUND FALSE)
     
    4471endif(GLPK_INCLUDE_DIR AND GLPK_LIBRARY)
    4572
    4673include(FindPackageHandleStandardArgs)
    47 FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLPK DEFAULT_MSG GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_PROPER_VERSION_FOUND)
     74find_package_handle_standard_args(GLPK DEFAULT_MSG GLPK_LIBRARY
     75                                  GLPK_INCLUDE_DIR GLPK_PROPER_VERSION_FOUND)
    4876
    4977if(GLPK_FOUND)
    5078  set(GLPK_INCLUDE_DIRS ${GLPK_INCLUDE_DIR})
  • cmake/FindGhostscript.cmake

    diff --git a/cmake/FindGhostscript.cmake b/cmake/FindGhostscript.cmake
    a b  
     1#[[
     2This file is a part of LEMON, a generic C++ optimization library.
     3
     4Copyright (C) 2003-2021
     5Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6(Egervary Research Group on Combinatorial Optimization, EGRES).
     7
     8Permission to use, modify and distribute this software is granted
     9provided that this copyright notice appears in all copies. For
     10precise terms see the accompanying LICENSE file.
     11
     12This software is provided "AS IS" with no warranty of any kind,
     13express or implied, and with no claim as to its suitability for any
     14purpose.
     15]]
     16
     17#[[
     18This file finds the necessary components for Ghostscript.
     19]]
     20
    121include(FindPackageHandleStandardArgs)
    222
    3 find_program(GHOSTSCRIPT_EXECUTABLE
     23find_program(
     24  GHOSTSCRIPT_EXECUTABLE
    425  NAMES gs gswin32c
    526  PATHS "$ENV{ProgramFiles}/gs"
    627  PATH_SUFFIXES gs8.61/bin gs8.62/bin gs8.63/bin gs8.64/bin gs8.65/bin
    7   DOC "Ghostscript: PostScript and PDF language interpreter and previewer."
    8 )
     28  DOC "Ghostscript: PostScript and PDF language interpreter and previewer.")
    929
    10 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ghostscript DEFAULT_MSG GHOSTSCRIPT_EXECUTABLE)
     30find_package_handle_standard_args(Ghostscript DEFAULT_MSG
     31                                  GHOSTSCRIPT_EXECUTABLE)
  • cmake/FindILOG.cmake

    diff --git a/cmake/FindILOG.cmake b/cmake/FindILOG.cmake
    a b  
    1 find_path(ILOG_ROOT_DIR
     1#[[
     2This file is a part of LEMON, a generic C++ optimization library.
     3
     4Copyright (C) 2003-2021
     5Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6(Egervary Research Group on Combinatorial Optimization, EGRES).
     7
     8Permission to use, modify and distribute this software is granted
     9provided that this copyright notice appears in all copies. For
     10precise terms see the accompanying LICENSE file.
     11
     12This software is provided "AS IS" with no warranty of any kind,
     13express or implied, and with no claim as to its suitability for any
     14purpose.
     15]]
     16
     17#[[
     18This file finds the necessary components for the ILOG Cplex solver.
     19]]
     20
     21find_path(
     22  ILOG_ROOT_DIR
    223  NAMES cplex
    324  DOC "CPLEX STUDIO root directory"
    425  PATHS /opt/ibm/ILOG /usr/local/ibm/ILOG /usr/local/ILOG /usr/local/ilog
    526  PATHS "$ENV{HOME}/ILOG" "$ENV{HOME}/.local/ILOG"
    627  PATHS "$ENV{HOME}/ibm/ILOG" "$ENV{HOME}/.local/ibm/ILOG"
    7   PATHS "C:/Program Files/IBM/ILOG"
    8   PATH_SUFFIXES "CPLEX_Studio126" "CPLEX_Studio125"
    9   "CPLEX_Studio124" "CPLEX_Studio123" "CPLEX_Studio122"
    10   NO_DEFAULT_PATH
    11 )
     28  PATHS "C:/Program Files/IBM/ILOG"
     29  PATH_SUFFIXES "CPLEX_Studio126" "CPLEX_Studio125" "CPLEX_Studio124"
     30                "CPLEX_Studio123" "CPLEX_Studio122" "CPLEX_Studio201"
     31  NO_DEFAULT_PATH)
    1232
    1333if(WIN32)
    1434  if(MSVC_VERSION STREQUAL "1400")
     
    2949  endif()
    3050endif()
    3151
    32 find_path(ILOG_CPLEX_ROOT_DIR
     52find_path(
     53  ILOG_CPLEX_ROOT_DIR
    3354  NAMES include/ilcplex
    3455  HINTS ${ILOG_ROOT_DIR}/cplex ${ILOG_ROOT_DIR}/cplex121
    35   ${ILOG_ROOT_DIR}/cplex122 ${ILOG_ROOT_DIR}/cplex123
     56        ${ILOG_ROOT_DIR}/cplex122 ${ILOG_ROOT_DIR}/cplex123
    3657  DOC "CPLEX root directory"
    37   NO_DEFAULT_PATH
    38 )
     58  NO_DEFAULT_PATH)
    3959
    40 find_path(ILOG_CONCERT_ROOT_DIR
     60find_path(
     61  ILOG_CONCERT_ROOT_DIR
    4162  NAMES include/ilconcert
    4263  HINTS ${ILOG_ROOT_DIR}/concert ${ILOG_ROOT_DIR}/concert29
    4364  DOC "CONCERT root directory"
    44   NO_DEFAULT_PATH
    45 )
     65  NO_DEFAULT_PATH)
    4666
    47 find_path(ILOG_CPLEX_INCLUDE_DIR
    48   ilcplex/cplex.h
     67find_path(
     68  ILOG_CPLEX_INCLUDE_DIR ilcplex/cplex.h
    4969  HINTS ${ILOG_CPLEX_ROOT_DIR}/include
    50   NO_DEFAULT_PATH
    51 )
     70  NO_DEFAULT_PATH)
    5271
    53 find_path(ILOG_CONCERT_INCLUDE_DIR
    54   ilconcert/ilobasic.h
     72find_path(
     73  ILOG_CONCERT_INCLUDE_DIR ilconcert/ilobasic.h
    5574  HINTS ${ILOG_CONCERT_ROOT_DIR}/include
    56   NO_DEFAULT_PATH
    57 )
     75  NO_DEFAULT_PATH)
    5876
    59 find_library(ILOG_CPLEX_LIBRARY
    60   cplex cplex121 cplex122 cplex123 cplex124
     77find_library(
     78  ILOG_CPLEX_LIBRARY cplex cplex121 cplex122 cplex123 cplex124
    6179  HINTS ${ILOG_CPLEX_ROOT_DIR}/lib/x86_sles10_4.1/static_pic
    62   ${ILOG_CPLEX_ROOT_DIR}/lib/x86-64_sles10_4.1/static_pic
    63   ${ILOG_CPLEX_ROOT_DIR}/lib/x86_debian4.0_4.1/static_pic
    64   ${ILOG_CPLEX_ROOT_DIR}/lib/x86-64_debian4.0_4.1/static_pic
    65   ${ILOG_CPLEX_ROOT_DIR}/lib/x86_linux/static_pic
    66   ${ILOG_CPLEX_ROOT_DIR}/lib/x86-64_linux/static_pic
    67   ${ILOG_CPLEX_ROOT_DIR}/lib/${ILOG_WIN_COMPILER}/stat_mda
    68   NO_DEFAULT_PATH
    69   )
     80        ${ILOG_CPLEX_ROOT_DIR}/lib/x86-64_sles10_4.1/static_pic
     81        ${ILOG_CPLEX_ROOT_DIR}/lib/x86_debian4.0_4.1/static_pic
     82        ${ILOG_CPLEX_ROOT_DIR}/lib/x86-64_debian4.0_4.1/static_pic
     83        ${ILOG_CPLEX_ROOT_DIR}/lib/x86_linux/static_pic
     84        ${ILOG_CPLEX_ROOT_DIR}/lib/x86-64_linux/static_pic
     85        ${ILOG_CPLEX_ROOT_DIR}/lib/${ILOG_WIN_COMPILER}/stat_mda
     86  NO_DEFAULT_PATH)
    7087
    71 find_library(ILOG_CONCERT_LIBRARY
    72   concert
     88find_library(
     89  ILOG_CONCERT_LIBRARY concert
    7390  HINTS ${ILOG_CONCERT_ROOT_DIR}/lib/x86_sles10_4.1/static_pic
    74   ${ILOG_CONCERT_ROOT_DIR}/lib/x86-64_sles10_4.1/static_pic
    75   ${ILOG_CONCERT_ROOT_DIR}/lib/x86_debian4.0_4.1/static_pic
    76   ${ILOG_CONCERT_ROOT_DIR}/lib/x86-64_debian4.0_4.1/static_pic
    77   ${ILOG_CONCERT_ROOT_DIR}/lib/x86_linux/static_pic
    78   ${ILOG_CONCERT_ROOT_DIR}/lib/x86-64_linux/static_pic
    79   ${ILOG_CONCERT_ROOT_DIR}/lib/${ILOG_WIN_COMPILER}/stat_mda
    80   NO_DEFAULT_PATH
    81   )
     91        ${ILOG_CONCERT_ROOT_DIR}/lib/x86-64_sles10_4.1/static_pic
     92        ${ILOG_CONCERT_ROOT_DIR}/lib/x86_debian4.0_4.1/static_pic
     93        ${ILOG_CONCERT_ROOT_DIR}/lib/x86-64_debian4.0_4.1/static_pic
     94        ${ILOG_CONCERT_ROOT_DIR}/lib/x86_linux/static_pic
     95        ${ILOG_CONCERT_ROOT_DIR}/lib/x86-64_linux/static_pic
     96        ${ILOG_CONCERT_ROOT_DIR}/lib/${ILOG_WIN_COMPILER}/stat_mda
     97  NO_DEFAULT_PATH)
    8298
    83 find_file(ILOG_CPLEX_DLL
    84   cplex121.dll cplex122.dll cplex123.dll cplex124.dll
     99find_file(
     100  ILOG_CPLEX_DLL cplex121.dll cplex122.dll cplex123.dll cplex124.dll
    85101  HINTS ${ILOG_CPLEX_ROOT_DIR}/bin/${ILOG_WIN_PLATFORM}
    86   NO_DEFAULT_PATH
    87   )
     102  NO_DEFAULT_PATH)
    88103
    89104include(FindPackageHandleStandardArgs)
    90 FIND_PACKAGE_HANDLE_STANDARD_ARGS(ILOG
    91   DEFAULT_MSG ILOG_CPLEX_LIBRARY ILOG_CPLEX_INCLUDE_DIR
    92   )
     105find_package_handle_standard_args(ILOG DEFAULT_MSG ILOG_CPLEX_LIBRARY
     106                                  ILOG_CPLEX_INCLUDE_DIR)
    93107
    94108if(ILOG_FOUND)
    95109  set(ILOG_INCLUDE_DIRS ${ILOG_CPLEX_INCLUDE_DIR} ${ILOG_CONCERT_INCLUDE_DIR})
    96110  set(ILOG_LIBRARIES ${ILOG_CPLEX_LIBRARY} ${ILOG_CONCERT_LIBRARY})
    97111  if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    98     # set(CPLEX_LIBRARIES "${CPLEX_LIBRARIES};m;pthread")
     112    # SET(CPLEX_LIBRARIES "${CPLEX_LIBRARIES};m;pthread")
    99113    set(ILOG_LIBRARIES ${ILOG_LIBRARIES} "m" "pthread" "dl")
    100114  endif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    101115endif(ILOG_FOUND)
    102116
    103 mark_as_advanced(
    104   ILOG_CPLEX_LIBRARY ILOG_CPLEX_INCLUDE_DIR ILOG_CPLEX_DLL
    105   ILOG_CONCERT_LIBRARY ILOG_CONCERT_INCLUDE_DIR ILOG_CONCERT_DLL
    106   )
     117mark_as_advanced(ILOG_CPLEX_LIBRARY ILOG_CPLEX_INCLUDE_DIR ILOG_CPLEX_DLL
     118                 ILOG_CONCERT_LIBRARY ILOG_CONCERT_INCLUDE_DIR ILOG_CONCERT_DLL)
  • cmake/FindSOPLEX.cmake

    diff --git a/cmake/FindSOPLEX.cmake b/cmake/FindSOPLEX.cmake
    a b  
    1 set(SOPLEX_ROOT_DIR "" CACHE PATH "SoPlex root directory")
     1#[[
     2This file is a part of LEMON, a generic C++ optimization library.
     3
     4Copyright (C) 2003-2021
     5Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6(Egervary Research Group on Combinatorial Optimization, EGRES).
     7
     8Permission to use, modify and distribute this software is granted
     9provided that this copyright notice appears in all copies. For
     10precise terms see the accompanying LICENSE file.
    211
    3 find_path(SOPLEX_INCLUDE_DIR
    4   soplex.h
    5   HINTS ${SOPLEX_ROOT_DIR}/src
    6 )
    7 find_library(SOPLEX_LIBRARY
    8   soplex
    9   HINTS ${SOPLEX_ROOT_DIR}/lib
    10 )
     12This software is provided "AS IS" with no warranty of any kind,
     13express or implied, and with no claim as to its suitability for any
     14purpose.
     15]]
     16
     17#[[
     18This file finds the necessary components for the SOPLEX solver.
     19]]
     20
     21find_path(SOPLEX_INCLUDE_DIR soplex.h HINTS ${SOPLEX_ROOT}/src)
     22find_library(SOPLEX_LIBRARY soplex HINTS ${SOPLEX_ROOT}/lib)
    1123
    1224include(FindPackageHandleStandardArgs)
    13 FIND_PACKAGE_HANDLE_STANDARD_ARGS(SOPLEX DEFAULT_MSG SOPLEX_LIBRARY SOPLEX_INCLUDE_DIR)
     25find_package_handle_standard_args(SOPLEX DEFAULT_MSG SOPLEX_LIBRARY
     26                                  SOPLEX_INCLUDE_DIR)
    1427
    1528if(SOPLEX_FOUND)
    1629  set(SOPLEX_INCLUDE_DIRS ${SOPLEX_INCLUDE_DIR})
  • cmake/LEMONConfig.cmake.in

    diff --git a/cmake/LEMONConfig.cmake.in b/cmake/LEMONConfig.cmake.in
    a b  
    1 set(LEMON_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include" CACHE PATH "LEMON include directory")
     1set(LEMON_INCLUDE_DIR
     2    "@CMAKE_INSTALL_PREFIX@/include"
     3    CACHE PATH "LEMON include directory")
    24set(LEMON_INCLUDE_DIRS "${LEMON_INCLUDE_DIR}")
    35
    46if(UNIX)
     
    79  set(LEMON_LIB_NAME "lemon.lib")
    810endif(UNIX)
    911
    10 set(LEMON_LIBRARY "@CMAKE_INSTALL_PREFIX@/lib/${LEMON_LIB_NAME}" CACHE FILEPATH "LEMON library")
     12set(LEMON_LIBRARY
     13    "@CMAKE_INSTALL_PREFIX@/lib/${LEMON_LIB_NAME}"
     14    CACHE FILEPATH "LEMON library")
    1115set(LEMON_LIBRARIES "${LEMON_LIBRARY}")
    1216
    1317mark_as_advanced(LEMON_LIBRARY LEMON_INCLUDE_DIR)
  • new file cmake/archive.cmake

    diff --git a/cmake/archive.cmake b/cmake/archive.cmake
    new file mode 100644
    - +  
     1#[[
     2This file is a part of LEMON, a generic C++ optimization library.
     3
     4Copyright (C) 2003-2021
     5Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6(Egervary Research Group on Combinatorial Optimization, EGRES).
     7
     8Permission to use, modify and distribute this software is granted
     9provided that this copyright notice appears in all copies. For
     10precise terms see the accompanying LICENSE file.
     11
     12This software is provided "AS IS" with no warranty of any kind,
     13express or implied, and with no claim as to its suitability for any
     14purpose.
     15]]
     16
     17#[[
     18This file creates compressed files of the current version and places them in the
     19PROJECT_BINARY_DIR as tar.gz and zip files.
     20]]
     21
     22set(ARCHIVE_BASE_NAME ${PROJECT_NAME})
     23string(TOLOWER ${ARCHIVE_BASE_NAME} ARCHIVE_BASE_NAME)
     24set(ARCHIVE_NAME ${ARCHIVE_BASE_NAME}-${PROJECT_VERSION})
     25add_custom_target(
     26  dist
     27  COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
     28  COMMAND hg archive ${ARCHIVE_NAME}
     29  COMMAND cmake -E copy ${PROJECT_NAME}ConfigVersion.cmake
     30          ${ARCHIVE_NAME}/cmake/${PROJECT_NAME}ConfigVersion.cmake
     31  COMMAND tar -czf ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.tar.gz
     32          ${ARCHIVE_NAME}
     33  COMMAND zip -r ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.zip
     34          ${ARCHIVE_NAME}
     35  COMMAND cmake -E copy_directory doc/html ${ARCHIVE_NAME}/doc/html
     36  COMMAND tar -czf ${ARCHIVE_NAME}.tar.gz ${ARCHIVE_NAME}
     37  COMMAND zip -r ${ARCHIVE_NAME}.zip ${ARCHIVE_NAME}
     38  COMMAND cmake -E copy_directory doc/html
     39          ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
     40  COMMAND tar -czf ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.tar.gz
     41          ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
     42  COMMAND zip -r ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.zip
     43          ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
     44  COMMAND cmake -E remove_directory ${ARCHIVE_NAME}
     45  COMMAND cmake -E remove_directory ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}
     46  DEPENDS html
     47  WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
  • new file cmake/base.cmake

    diff --git a/cmake/base.cmake b/cmake/base.cmake
    new file mode 100644
    - +  
     1#[[
     2This file is a part of LEMON, a generic C++ optimization library.
     3
     4Copyright (C) 2003-2021
     5Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6(Egervary Research Group on Combinatorial Optimization, EGRES).
     7
     8Permission to use, modify and distribute this software is granted
     9provided that this copyright notice appears in all copies. For
     10precise terms see the accompanying LICENSE file.
     11
     12This software is provided "AS IS" with no warranty of any kind,
     13express or implied, and with no claim as to its suitability for any
     14purpose.
     15]]
     16
     17#[[
     18This file sets up the necessary dependencies and flags required to build the
     19LEMON::LEMON alias (called from here). This includes:
     20
     21- Compile definitions for different architectures
     22- Solver finding if required
     23-
     24
     25Also defines main project install target.
     26]]
     27
     28if(DEFINED ENV{LEMON_CXX_WARNING})
     29  set(CXX_WARNING $ENV{LEMON_CXX_WARNING})
     30else()
     31  if(CMAKE_COMPILER_IS_GNUCXX)
     32    list(
     33      APPEND
     34      CXX_WARNING
     35      "-Wall"
     36      "-W"
     37      "-Wunused"
     38      "-Wformat=2"
     39      "-Wctor-dtor-privacy"
     40      "-Wnon-virtual-dtor"
     41      "-Wno-char-subscripts"
     42      "-Wwrite-strings"
     43      "-Wno-char-subscripts"
     44      "-Wreturn-type"
     45      "-Wcast-qual"
     46      "-Wcast-align"
     47      "-Wsign-promo"
     48      "-Woverloaded-virtual"
     49      "-fno-strict-aliasing"
     50      "-Wold-style-cast"
     51      "-Wno-unknown-pragmas"
     52      "-Wno-unused-local-typedefs")
     53    set(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb")
     54    set(CMAKE_C_FLAGS_DEBUG CACHE STRING "${CMAKE_CXX_FLAGS_DEBUG}")
     55    if(WIN32 AND MINGW)
     56      list(APPEND CXX_WARNING "-Wa,-mbig-obj" "-O2")
     57    endif()
     58  elseif(MSVC)
     59    # This part is unnecessary 'casue the same is set by the lemon/core.h. Still
     60    # keep it as an example.
     61    # Suppressed warnings:
     62    list(
     63      APPEND
     64      CXX_WARNING
     65      "/wd4250" # 'class1' : inherits 'class2::member' via dominance
     66      "/wd4355" # 'this' : used in base member initializer list
     67      "/wd4503" # 'function' : decorated name length exceeded, name truncated
     68      "/wd4800" # 'type' : forcing value to bool 'true' or 'false'
     69      # (performance warning)
     70      "/wd4996" # 'function': was declared deprecated
     71    )
     72  else()
     73    list(APPEND CXX_WARNING "-Wall")
     74  endif()
     75endif()
     76
     77add_definitions(${CXX_WARNING})
     78
     79if(MSVC)
     80  set(CMAKE_CXX_FLAGS_MAINTAINER
     81      "/WX ${CMAKE_CXX_FLAGS_DEBUG}"
     82      CACHE STRING "Flags used by the C++ compiler during maintainer builds.")
     83  set(CMAKE_C_FLAGS_MAINTAINER
     84      "/WX ${CMAKE_CXX_FLAGS_DEBUG}"
     85      CACHE STRING "Flags used by the C compiler during maintainer builds.")
     86  set(CMAKE_EXE_LINKER_FLAGS_MAINTAINER
     87      "${CMAKE_EXE_LINKER_FLAGS_DEBUG}"
     88      CACHE STRING "Flags used for linking binaries during maintainer builds.")
     89  set(CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
     90      "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}"
     91      CACHE
     92        STRING
     93        "Flags used by the shared libraries linker during maintainer builds.")
     94else()
     95  set(CMAKE_CXX_FLAGS_MAINTAINER
     96      "-Werror -ggdb -O0"
     97      CACHE STRING "Flags used by the C++ compiler during maintainer builds.")
     98  set(CMAKE_C_FLAGS_MAINTAINER
     99      "-Werror -O0"
     100      CACHE STRING "Flags used by the C compiler during maintainer builds.")
     101  set(CMAKE_EXE_LINKER_FLAGS_MAINTAINER
     102      "${CMAKE_EXE_LINKER_FLAGS_DEBUG}"
     103      CACHE STRING "Flags used for linking binaries during maintainer builds.")
     104  set(CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
     105      "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}"
     106      CACHE
     107        STRING
     108        "Flags used by the shared libraries linker during maintainer builds.")
     109endif()
     110
     111mark_as_advanced(
     112  CMAKE_CXX_FLAGS_MAINTAINER CMAKE_C_FLAGS_MAINTAINER
     113  CMAKE_EXE_LINKER_FLAGS_MAINTAINER CMAKE_SHARED_LINKER_FLAGS_MAINTAINER)
     114
     115include(CheckTypeSize)
     116check_type_size("long long" LONG_LONG)
     117set(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
     118
     119find_package(Threads)
     120
     121if(NOT LEMON_THREADING)
     122  if(CMAKE_USE_PTHREADS_INIT)
     123    set(LEMON_THREADING "Pthread")
     124  elseif(CMAKE_USE_WIN32_THREADS_INIT)
     125    set(LEMON_THREADING "Win32")
     126  else()
     127    set(LEMON_THREADING "None")
     128  endif()
     129endif()
     130
     131set(LEMON_THREADING
     132    "${LEMON_THREADING}"
     133    CACHE STRING
     134          "Choose the threading library, options are: Pthread Win32 None."
     135          FORCE)
     136
     137if(LEMON_THREADING STREQUAL "Pthread")
     138  set(LEMON_USE_PTHREAD ON)
     139elseif(LEMON_THREADING STREQUAL "Win32")
     140  set(LEMON_USE_WIN32_THREADS ON)
     141endif()
     142
     143# GLPK #
     144if(LEMON_ENABLE_GLPK)
     145  find_package(GLPK REQUIRED)
     146endif()
     147if(GLPK_FOUND)
     148  set(LEMON_HAVE_LP ON)
     149  set(LEMON_HAVE_MIP ON)
     150  set(LEMON_HAVE_GLPK ON)
     151endif()
     152
     153# ILOG #
     154if(LEMON_ENABLE_ILOG)
     155  find_package(ILOG REQUIRED)
     156endif()
     157if(ILOG_FOUND)
     158  set(LEMON_HAVE_LP ON)
     159  set(LEMON_HAVE_MIP ON)
     160  set(LEMON_HAVE_CPLEX ON)
     161endif()
     162
     163# COIN #
     164if(LEMON_ENABLE_COIN)
     165  find_package(COIN REQUIRED)
     166endif()
     167if(COIN_FOUND)
     168  set(LEMON_HAVE_LP ON)
     169  set(LEMON_HAVE_MIP ON)
     170  set(LEMON_HAVE_CLP ON)
     171  set(LEMON_HAVE_CBC ON)
     172endif()
     173
     174# SOPLEX #
     175if(LEMON_ENABLE_SOPLEX)
     176  find_package(SOPLEX REQUIRED)
     177endif()
     178if(SOPLEX_FOUND)
     179  set(LEMON_HAVE_LP ON)
     180  set(LEMON_HAVE_SOPLEX ON)
     181endif()
     182
     183# Set default LP + MIP solver string #
     184if(ILOG_FOUND)
     185  set(DEFAULT_LP "CPLEX")
     186  set(DEFAULT_MIP "CPLEX")
     187elseif(COIN_FOUND)
     188  set(DEFAULT_LP "CLP")
     189  set(DEFAULT_MIP "CBC")
     190elseif(GLPK_FOUND)
     191  set(DEFAULT_LP "GLPK")
     192  set(DEFAULT_MIP "GLPK")
     193elseif(SOPLEX_FOUND)
     194  set(DEFAULT_LP "SOPLEX")
     195endif()
     196
     197if(NOT LEMON_DEFAULT_LP
     198   OR (NOT ILOG_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CPLEX"))
     199   OR (NOT COIN_FOUND AND (LEMON_DEFAULT_LP STREQUAL "CLP"))
     200   OR (NOT GLPK_FOUND AND (LEMON_DEFAULT_LP STREQUAL "GLPK"))
     201   OR (NOT SOPLEX_FOUND AND (LEMON_DEFAULT_LP STREQUAL "SOPLEX")))
     202  set(LEMON_DEFAULT_LP
     203      ${DEFAULT_LP}
     204      CACHE STRING "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)"
     205            FORCE)
     206else()
     207  set(LEMON_DEFAULT_LP
     208      ${DEFAULT_LP}
     209      CACHE STRING "Default LP solver backend (GLPK, CPLEX, CLP or SOPLEX)")
     210endif()
     211
     212if(NOT LEMON_DEFAULT_MIP
     213   OR (NOT ILOG_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CPLEX"))
     214   OR (NOT COIN_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "CBC"))
     215   OR (NOT GLPK_FOUND AND (LEMON_DEFAULT_MIP STREQUAL "GLPK")))
     216  set(LEMON_DEFAULT_MIP
     217      ${DEFAULT_MIP}
     218      CACHE STRING "Default MIP solver backend (GLPK, CPLEX or CBC)" FORCE)
     219else()
     220  set(LEMON_DEFAULT_MIP
     221      ${DEFAULT_MIP}
     222      CACHE STRING "Default MIP solver backend (GLPK, CPLEX or CBC)")
     223endif()
     224
     225add_subdirectory(lemon)
     226
     227include(GNUInstallDirs)
     228
     229install(
     230  EXPORT ${PROJECT_NAME}Targets
     231  NAMESPACE LEMON::
     232  DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
     233
     234include(CMakePackageConfigHelpers)
     235
     236# Config file
     237configure_package_config_file(
     238  cmake/Config.cmake.in "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
     239  INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
     240
     241# Version file
     242configure_file(cmake/${PROJECT_NAME}Version.cmake.in
     243               "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Version.cmake" @ONLY)
     244
     245install(
     246  FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
     247        "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Version.cmake"
     248  DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
     249  COMPONENT Devel)
  • new file cmake/cpack.cmake

    diff --git a/cmake/cpack.cmake b/cmake/cpack.cmake
    new file mode 100644
    - +  
     1#[[
     2This file is a part of LEMON, a generic C++ optimization library.
     3
     4Copyright (C) 2003-2021
     5Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6(Egervary Research Group on Combinatorial Optimization, EGRES).
     7
     8Permission to use, modify and distribute this software is granted
     9provided that this copyright notice appears in all copies. For
     10precise terms see the accompanying LICENSE file.
     11
     12This software is provided "AS IS" with no warranty of any kind,
     13express or implied, and with no claim as to its suitability for any
     14purpose.
     15]]
     16
     17#[[
     18Defines options using in the Pkg config file.
     19]]
     20
     21include(CPack)
     22set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
     23set(CPACK_PACKAGE_VENDOR "EGRES")
     24set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
     25    "LEMON - Library for Efficient Modeling and Optimization in Networks")
     26set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
     27
     28set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
     29
     30set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME} ${PROJECT_VERSION}")
     31set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${PROJECT_NAME} ${PROJECT_VERSION}")
     32
     33set(CPACK_COMPONENTS_ALL headers library html_documentation bin)
     34
     35set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
     36set(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
     37set(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
     38set(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
     39
     40set(CPACK_COMPONENT_HEADERS_DESCRIPTION "C++ header files")
     41set(CPACK_COMPONENT_LIBRARY_DESCRIPTION "DLL and import library")
     42set(CPACK_COMPONENT_BIN_DESCRIPTION "Command line utilities")
     43set(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
     44    "Doxygen generated documentation")
     45
     46set(CPACK_COMPONENT_HEADERS_DEPENDS library)
     47
     48set(CPACK_COMPONENT_HEADERS_GROUP "Development")
     49set(CPACK_COMPONENT_LIBRARY_GROUP "Development")
     50set(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
     51
     52set(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
     53    "Components needed to develop software using LEMON")
     54set(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION "Documentation of LEMON")
     55
     56set(CPACK_ALL_INSTALL_TYPES Full Developer)
     57
     58set(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
     59set(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
     60set(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
     61
     62set(CPACK_GENERATOR "NSIS")
     63set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
     64set(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
     65# SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
     66set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
     67set(CPACK_NSIS_DISPLAY_NAME
     68    "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
     69set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
     70set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
     71set(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
     72set(CPACK_NSIS_CREATE_ICONS_EXTRA
     73    "
     74    CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
     75    ")
     76set(CPACK_NSIS_DELETE_ICONS_EXTRA
     77    "
     78    !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
     79    Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"
     80    ")
  • cmake/version.cmake.in

    diff --git a/cmake/version.cmake.in b/cmake/version.cmake.in
    a b  
    1 set(LEMON_VERSION "@LEMON_VERSION@" CACHE STRING "LEMON version string.")
     1SET(LEMON_VERSION "@LEMON_VERSION@" CACHE STRING "LEMON version string.")
  • contrib/CMakeLists.txt

    diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt
    a b  
    1 include_directories(
    2   ${PROJECT_SOURCE_DIR}
    3   ${PROJECT_BINARY_DIR}
    4 )
    5 
    6 link_directories(
    7   ${PROJECT_BINARY_DIR}/lemon
    8 )
    9 
    101# Uncomment (and adjust) the following two lines. 'myprog' is the name
    112# of the final executable ('.exe' will automatically be added to the
    123# name on Windows) and 'myprog-main.cc' is the source code it is
     
    145# whitespaces. Moreover, you can add multiple similar blocks if you
    156# want to build more than one executables.
    167
    17 # add_executable(myprog myprog-main.cc)
    18 # target_link_libraries(myprog lemon)
    19 
     8add_executable(myprog myprog-main.cc)
     9target_link_libraries(myprog LEMON::LEMON)
  • demo/CMakeLists.txt

    diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt
    a b  
    1 include_directories(
    2   ${PROJECT_SOURCE_DIR}
    3   ${PROJECT_BINARY_DIR}
    4 )
     1#[[
     2This file is a part of LEMON, a generic C++ optimization library.
     3
     4Copyright (C) 2003-2021
     5Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6(Egervary Research Group on Combinatorial Optimization, EGRES).
     7
     8Permission to use, modify and distribute this software is granted
     9provided that this copyright notice appears in all copies. For
     10precise terms see the accompanying LICENSE file.
     11
     12This software is provided "AS IS" with no warranty of any kind,
     13express or implied, and with no claim as to its suitability for any
     14purpose.
     15]]
     16
     17#[[
     18This file builds an example project consuming LEMON in three different ways:
     191. Using locally installed LEMON - find_package.
     202. Using add_subdirectory.
     213. Using FetchContent.
     22]]
    523
    6 link_directories(
    7   ${PROJECT_BINARY_DIR}/lemon
    8 )
     24cmake_minimum_required(VERSION 3.15)
     25project(
     26  demo
     27  VERSION 0.1.0
     28  LANGUAGES CXX)
     29
     30# Option 1.
     31# find_package(LEMON REQUIRED)
     32
     33# Option 2.
     34# add_subdirectory(path-to-lemon)
    935
    10 set(DEMOS
    11   arg_parser_demo
    12   graph_to_eps_demo
    13   lgf_demo
    14 )
     36# Option 3. (works with updated repo)
     37# include(FetchContent)
     38# find_package(Hg)
     39# if(HG_FOUND)
     40#   FetchContent_Declare(
     41#     LEMON
     42#     HG_REPOSITORY "https://lemon.cs.elte.hu/hg/lemon/"
     43#     )
     44# else()
     45#   FetchContent_Declare(
     46#     LEMON
     47#     SOURCE_DIR "path-to-lemon-src")
     48# endif()
     49# FetchContent_MakeAvailable(LEMON)
     50
     51set(DEMOS arg_parser_demo graph_to_eps_demo lgf_demo)
    1552
    1653foreach(DEMO_NAME ${DEMOS})
    1754  add_executable(${DEMO_NAME} ${DEMO_NAME}.cc)
    18   target_link_libraries(${DEMO_NAME} lemon)
     55  target_link_libraries(${DEMO_NAME} LEMON::LEMON)
    1956endforeach()
  • doc/CMakeLists.txt

    diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
    a b  
     1#[[
     2This file is a part of LEMON, a generic C++ optimization library.
     3
     4Copyright (C) 2003-2021
     5Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6(Egervary Research Group on Combinatorial Optimization, EGRES).
     7
     8Permission to use, modify and distribute this software is granted
     9provided that this copyright notice appears in all copies. For
     10precise terms see the accompanying LICENSE file.
     11
     12This software is provided "AS IS" with no warranty of any kind,
     13express or implied, and with no claim as to its suitability for any
     14purpose.
     15]]
     16
     17#[[
     18This file orchestrates the build of the docs.
     19]]
     20
     21find_package(Doxygen REQUIRED)
     22find_package(Ghostscript REQUIRED)
     23find_package(PythonInterp REQUIRED)
     24find_package(Wget REQUIRED)
     25
    126set(PACKAGE_NAME ${PROJECT_NAME})
    227set(PACKAGE_VERSION ${PROJECT_VERSION})
    328set(abs_top_srcdir ${PROJECT_SOURCE_DIR})
    429set(abs_top_builddir ${PROJECT_BINARY_DIR})
    530
    6 set(LEMON_DOC_SOURCE_BROWSER "NO" CACHE STRING "Include source into the doc (YES/NO).")
    7 set(LEMON_DOC_USE_MATHJAX "NO" CACHE STRING "Use MathJax to display math formulae (YES/NO).")
    8 set(LEMON_DOC_MATHJAX_RELPATH "http://www.mathjax.org/mathjax" CACHE STRING "MathJax library location.")
     31set(LEMON_DOC_SOURCE_BROWSER
     32    OFF
     33    CACHE BOOL "Include source into the doc.")
     34set(LEMON_DOC_USE_MATHJAX
     35    OFF
     36    CACHE BOOL "Use MathJax to display math formulae.")
     37set(LEMON_DOC_MATHJAX_RELPATH
     38    "http://www.mathjax.org/mathjax"
     39    CACHE STRING "MathJax library location.")
    940
    1041set(LEMON_DOC_LIBSTDC++_URL
    11   "http://gcc.gnu.org/onlinedocs/gcc-4.7.3/libstdc++/api"
    12   CACHE STRING "GCC libstdc++ doxygen doc url.")
    13 
     42    "http://gcc.gnu.org/onlinedocs/gcc-4.7.3/libstdc++/api"
     43    CACHE STRING "GCC libstdc++ doxygen doc url.")
    1444
    15 configure_file(
    16   ${PROJECT_SOURCE_DIR}/doc/Doxyfile.in
    17   ${PROJECT_BINARY_DIR}/doc/Doxyfile
    18   @ONLY
    19 )
     45configure_file(${PROJECT_SOURCE_DIR}/doc/Doxyfile.in
     46               ${PROJECT_BINARY_DIR}/doc/Doxyfile @ONLY)
    2047
    21 configure_file(
    22   ${PROJECT_SOURCE_DIR}/doc/mainpage.dox.in
    23   ${PROJECT_BINARY_DIR}/doc/mainpage.dox
    24   @ONLY
    25 )
     48configure_file(${PROJECT_SOURCE_DIR}/doc/mainpage.dox.in
     49               ${PROJECT_BINARY_DIR}/doc/mainpage.dox @ONLY)
    2650
    2751# Copy doc from source (if exists)
    28 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/html AND
    29     NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/html/index.html)
     52if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/html
     53   AND NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/html/index.html)
    3054  message(STATUS "Copy doc from source tree")
    3155  execute_process(
    32     COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/html ${CMAKE_CURRENT_BINARY_DIR}/html
    33     )
     56    COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/html
     57            ${CMAKE_CURRENT_BINARY_DIR}/html)
    3458endif()
    3559
    36 if(DOXYGEN_EXECUTABLE AND PYTHONINTERP_FOUND AND GHOSTSCRIPT_EXECUTABLE)
     60if(DOXYGEN_EXECUTABLE
     61   AND PYTHONINTERP_FOUND
     62   AND GHOSTSCRIPT_EXECUTABLE)
    3763  file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/)
    38   set(GHOSTSCRIPT_OPTIONS -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha)
    39   add_custom_target(html
     64  set(GHOSTSCRIPT_OPTIONS
     65      "-dNOPAUSE"
     66      "-dBATCH"
     67      "-q"
     68      "-dEPSCrop"
     69      "-dTextAlphaBits=4"
     70      "-dGraphicsAlphaBits=4"
     71      "-sDEVICE=pngalpha")
     72  add_custom_target(
     73    html
    4074    COMMAND ${CMAKE_COMMAND} -E remove_directory gen-images
    4175    COMMAND ${CMAKE_COMMAND} -E make_directory gen-images
    42     COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r20 -sOutputFile=gen-images/grid_graph.png ${CMAKE_CURRENT_SOURCE_DIR}/images/grid_graph.eps
    43     COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r32 -sOutputFile=gen-images/adaptors2.png ${CMAKE_CURRENT_SOURCE_DIR}/images/adaptors2.eps
    44     COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r32 -sOutputFile=gen-images/connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/connected_components.eps
    45     COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r32 -sOutputFile=gen-images/strongly_connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/strongly_connected_components.eps
    46     COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r32 -sOutputFile=gen-images/node_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/node_biconnected_components.eps
    47     COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r32 -sOutputFile=gen-images/edge_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/edge_biconnected_components.eps
    48     COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r32 -sOutputFile=gen-images/bipartite_partitions.png ${CMAKE_CURRENT_SOURCE_DIR}/images/bipartite_partitions.eps
    49     COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r24 -sOutputFile=gen-images/matching.png ${CMAKE_CURRENT_SOURCE_DIR}/images/matching.eps
    50     COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r24 -sOutputFile=gen-images/bipartite_matching.png ${CMAKE_CURRENT_SOURCE_DIR}/images/bipartite_matching.eps
    51     COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r40 -sOutputFile=gen-images/planar.png ${CMAKE_CURRENT_SOURCE_DIR}/images/planar.eps
    52     COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r24 -sOutputFile=gen-images/tsp.png ${CMAKE_CURRENT_SOURCE_DIR}/images/tsp.eps
    53     COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r8 -sOutputFile=gen-images/nodeshape_0.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_0.eps
    54     COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r8 -sOutputFile=gen-images/nodeshape_1.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_1.eps
    55     COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r8 -sOutputFile=gen-images/nodeshape_2.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_2.eps
    56     COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r8 -sOutputFile=gen-images/nodeshape_3.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_3.eps
    57     COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r8 -sOutputFile=gen-images/nodeshape_4.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_4.eps
     76    COMMAND
     77      ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r20
     78      -sOutputFile=gen-images/grid_graph.png
     79      ${CMAKE_CURRENT_SOURCE_DIR}/images/grid_graph.eps
     80    COMMAND
     81      ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r32
     82      -sOutputFile=gen-images/adaptors2.png
     83      ${CMAKE_CURRENT_SOURCE_DIR}/images/adaptors2.eps
     84    COMMAND
     85      ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r32
     86      -sOutputFile=gen-images/connected_components.png
     87      ${CMAKE_CURRENT_SOURCE_DIR}/images/connected_components.eps
     88    COMMAND
     89      ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r32
     90      -sOutputFile=gen-images/strongly_connected_components.png
     91      ${CMAKE_CURRENT_SOURCE_DIR}/images/strongly_connected_components.eps
     92    COMMAND
     93      ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r32
     94      -sOutputFile=gen-images/node_biconnected_components.png
     95      ${CMAKE_CURRENT_SOURCE_DIR}/images/node_biconnected_components.eps
     96    COMMAND
     97      ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r32
     98      -sOutputFile=gen-images/edge_biconnected_components.png
     99      ${CMAKE_CURRENT_SOURCE_DIR}/images/edge_biconnected_components.eps
     100    COMMAND
     101      ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r32
     102      -sOutputFile=gen-images/bipartite_partitions.png
     103      ${CMAKE_CURRENT_SOURCE_DIR}/images/bipartite_partitions.eps
     104    COMMAND
     105      ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r24
     106      -sOutputFile=gen-images/matching.png
     107      ${CMAKE_CURRENT_SOURCE_DIR}/images/matching.eps
     108    COMMAND
     109      ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r24
     110      -sOutputFile=gen-images/bipartite_matching.png
     111      ${CMAKE_CURRENT_SOURCE_DIR}/images/bipartite_matching.eps
     112    COMMAND
     113      ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r40
     114      -sOutputFile=gen-images/planar.png
     115      ${CMAKE_CURRENT_SOURCE_DIR}/images/planar.eps
     116    COMMAND
     117      ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r24
     118      -sOutputFile=gen-images/tsp.png ${CMAKE_CURRENT_SOURCE_DIR}/images/tsp.eps
     119    COMMAND
     120      ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r8
     121      -sOutputFile=gen-images/nodeshape_0.png
     122      ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_0.eps
     123    COMMAND
     124      ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r8
     125      -sOutputFile=gen-images/nodeshape_1.png
     126      ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_1.eps
     127    COMMAND
     128      ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r8
     129      -sOutputFile=gen-images/nodeshape_2.png
     130      ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_2.eps
     131    COMMAND
     132      ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r8
     133      -sOutputFile=gen-images/nodeshape_3.png
     134      ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_3.eps
     135    COMMAND
     136      ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r8
     137      -sOutputFile=gen-images/nodeshape_4.png
     138      ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_4.eps
    58139    COMMAND ${CMAKE_COMMAND} -E remove_directory html
    59140    COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
    60     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    61   )
    62 
    63   set_target_properties(html PROPERTIES PROJECT_LABEL BUILD_DOC)
    64 
     141    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
     142  # set_target_properties(html PROPERTIES PROJECT_LABEL BUILD_DOC)
    65143  if(UNIX)
    66144    install(
    67145      DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
    68146      DESTINATION share/doc/lemon/html
    69       COMPONENT html_documentation
    70     )
     147      COMPONENT html_documentation)
    71148  elseif(WIN32)
    72149    install(
    73150      DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
    74151      DESTINATION doc
    75       COMPONENT html_documentation
    76     )
     152      COMPONENT html_documentation)
    77153  endif()
    78 
    79154endif()
    80155
    81156if(WGET_FOUND)
    82 add_custom_target(update-external-tags
    83   COMMAND ${WGET_EXECUTABLE} -N ${LEMON_DOC_LIBSTDC++_URL}/libstdc++.tag
    84   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    85   )
     157  add_custom_target(
     158    update-external-tags
     159    COMMAND ${WGET_EXECUTABLE} -N ${LEMON_DOC_LIBSTDC++_URL}/libstdc++.tag
     160    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
    86161endif()
  • lemon/CMakeLists.txt

    diff --git a/lemon/CMakeLists.txt b/lemon/CMakeLists.txt
    a b  
    1 include_directories(
    2   ${PROJECT_SOURCE_DIR}
    3   ${PROJECT_BINARY_DIR}
    4 )
     1#[[
     2This file is a part of LEMON, a generic C++ optimization library.
     3
     4Copyright (C) 2003-2021
     5Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6(Egervary Research Group on Combinatorial Optimization, EGRES).
     7
     8Permission to use, modify and distribute this software is granted
     9provided that this copyright notice appears in all copies. For
     10precise terms see the accompanying LICENSE file.
    511
    6 configure_file(
    7   ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
    8   ${CMAKE_CURRENT_BINARY_DIR}/config.h
    9 )
     12This software is provided "AS IS" with no warranty of any kind,
     13express or implied, and with no claim as to its suitability for any
     14purpose.
     15]]
     16
     17#[[
     18This file defines the lemon target and LEMON::LEMON alias.
     19]]
    1020
    11 configure_file(
    12   ${CMAKE_CURRENT_SOURCE_DIR}/lemon.pc.in
    13   ${CMAKE_CURRENT_BINARY_DIR}/lemon.pc
    14   @ONLY
    15 )
     21set(NAME lemon)
     22
     23# Configure
     24configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
     25               ${CMAKE_CURRENT_BINARY_DIR}/config.h)
     26# Configure lemon package file
     27configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lemon.pc.in
     28               ${CMAKE_CURRENT_BINARY_DIR}/lemon.pc @ONLY)
    1629
    1730set(LEMON_SOURCES
    18   arg_parser.cc
    19   base.cc
    20   color.cc
    21   lp_base.cc
    22   lp_skeleton.cc
    23   random.cc
    24   bits/windows.cc
    25 )
     31    arg_parser.cc
     32    base.cc
     33    color.cc
     34    lp_base.cc
     35    lp_skeleton.cc
     36    random.cc
     37    bits/windows.cc)
    2638
    2739if(LEMON_HAVE_GLPK)
    2840  set(LEMON_SOURCES ${LEMON_SOURCES} glpk.cc)
     
    5466  include_directories(${SOPLEX_INCLUDE_DIRS})
    5567endif()
    5668
    57 add_library(lemon ${LEMON_SOURCES})
     69file(GLOB _HDRS "*.h" "bits/*h" "concepts/*.h")
     70
     71add_library(${NAME} ${LEMON_SOURCES} ${_HDRS})
    5872
    59 target_link_libraries(lemon
    60   ${GLPK_LIBRARIES} ${COIN_LIBRARIES} ${ILOG_LIBRARIES} ${SOPLEX_LIBRARIES}
    61   )
     73# Compile options (needed for MacOS)
     74set_target_properties(
     75  ${NAME}
     76  PROPERTIES CXX_STANDARD 17
     77             CXX_STANDARD_REQUIRED ON
     78             CXX_EXTENSIONS OFF
     79             POSITION_INDEPENDENT_CODE ON)
     80
     81target_compile_features(${NAME} PUBLIC cxx_std_17)
     82
     83target_link_libraries(${NAME} ${GLPK_LIBRARIES} ${COIN_LIBRARIES}
     84                      ${ILOG_LIBRARIES} ${SOPLEX_LIBRARIES})
    6285
    63 if(UNIX)
    64   set_target_properties(lemon PROPERTIES OUTPUT_NAME emon VERSION ${LEMON_VERSION} SOVERSION ${LEMON_VERSION})
    65 endif()
     86# Target output name depends on OS: libemon if on UNIX (LINUX and MacOS),
     87# liblemon if on WIN32.
     88set_target_properties(
     89  ${NAME}
     90  PROPERTIES PUBLIC_HEADER "${_HDRS};${CMAKE_CURRENT_BINARY_DIR}/config.h"
     91             OUTPUT_NAME $<IF:$<BOOL:${UNIX}>,emon,${NAME}>
     92             VERSION ${PROJECT_VERSION}
     93             SOVERSION ${PROJECT_VERSION_MAJOR})
    6694
    67 install(
    68   TARGETS lemon
    69   ARCHIVE DESTINATION lib
    70   LIBRARY DESTINATION lib
    71   COMPONENT library
    72 )
     95target_include_directories(
     96  ${NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
     97                 $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>)
     98# Add alias
     99add_library(LEMON::LEMON ALIAS ${NAME})
    73100
     101# Install targets
     102include(GNUInstallDirs)
    74103install(
    75   DIRECTORY . bits concepts
    76   DESTINATION include/lemon
    77   COMPONENT headers
    78   FILES_MATCHING PATTERN "*.h"
    79 )
     104  TARGETS ${NAME}
     105  EXPORT ${PROJECT_NAME}Targets
     106  PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lemon
     107  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
     108  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
    80109
    81 install(
    82   FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h
    83   DESTINATION include/lemon
    84   COMPONENT headers
    85 )
    86 
    87 install(
    88   FILES ${CMAKE_CURRENT_BINARY_DIR}/lemon.pc
    89   DESTINATION lib/pkgconfig
    90 )
    91 
     110# Pkg-config
     111install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lemon.pc DESTINATION lib/pkgconfig)
  • test/CMakeLists.txt

    diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
    a b  
    1 include_directories(
    2   ${PROJECT_SOURCE_DIR}
    3   ${PROJECT_BINARY_DIR}
    4 )
     1#[[
     2This file is a part of LEMON, a generic C++ optimization library.
     3
     4Copyright (C) 2003-2021
     5Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6(Egervary Research Group on Combinatorial Optimization, EGRES).
     7
     8Permission to use, modify and distribute this software is granted
     9provided that this copyright notice appears in all copies. For
     10precise terms see the accompanying LICENSE file.
    511
    6 link_directories(
    7   ${PROJECT_BINARY_DIR}/lemon
    8 )
     12This software is provided "AS IS" with no warranty of any kind,
     13express or implied, and with no claim as to its suitability for any
     14purpose.
     15]]
    916
    10 set(TEST_WITH_VALGRIND "NO" CACHE STRING
    11   "Run the test with valgrind (YES/NO).")
    12 set(VALGRIND_FLAGS "" CACHE STRING "Valgrind flags used by the tests.")
     17#[[
     18This file defines all the test targets for ctest.
     19Can also be used to run valgrind
     20]]
     21
     22if(LEMON_TEST_WITH_VALGRIND)
     23  set(VALGRIND_FLAGS
     24      "--leak-check=full"
     25      CACHE STRING "Valgrind flags used by the tests.")
     26endif()
    1327
    1428set(TESTS
    15   adaptors_test
    16   arc_look_up_test
    17   bellman_ford_test
    18   bfs_test
    19   bpgraph_test
    20   circulation_test
    21   connectivity_test
    22   counter_test
    23   dfs_test
    24   digraph_test
    25   dijkstra_test
    26   dim_test
    27   edge_set_test
    28   error_test
    29   euler_test
    30   fractional_matching_test
    31   gomory_hu_test
    32   graph_copy_test
    33   graph_test
    34   graph_utils_test
    35   hao_orlin_test
    36   heap_test
    37   kruskal_test
    38   lgf_reader_writer_test
    39   lgf_test
    40   maps_test
    41   matching_test
    42   max_cardinality_search_test
    43   max_clique_test
    44   max_flow_test
    45   min_cost_arborescence_test
    46   min_cost_flow_test
    47   min_mean_cycle_test
    48   nagamochi_ibaraki_test
    49   path_test
    50   planarity_test
    51   radix_sort_test
    52   random_test
    53   suurballe_test
    54   time_measure_test
    55   tsp_test
    56   unionfind_test
    57   vf2_test
    58 )
     29    adaptors_test
     30    arc_look_up_test
     31    bellman_ford_test
     32    bfs_test
     33    bpgraph_test
     34    circulation_test
     35    connectivity_test
     36    counter_test
     37    dfs_test
     38    digraph_test
     39    dijkstra_test
     40    dim_test
     41    edge_set_test
     42    error_test
     43    euler_test
     44    fractional_matching_test
     45    gomory_hu_test
     46    graph_copy_test
     47    graph_test
     48    graph_utils_test
     49    hao_orlin_test
     50    heap_test
     51    kruskal_test
     52    lgf_reader_writer_test
     53    lgf_test
     54    maps_test
     55    matching_test
     56    max_cardinality_search_test
     57    max_clique_test
     58    max_flow_test
     59    min_cost_arborescence_test
     60    min_cost_flow_test
     61    min_mean_cycle_test
     62    multicommodity_flow_test
     63    nagamochi_ibaraki_test
     64    path_test
     65    planarity_test
     66    radix_sort_test
     67    random_test
     68    suurballe_test
     69    time_measure_test
     70    tsp_test
     71    unionfind_test
     72    vf2_test)
    5973
    6074if(LEMON_HAVE_LP)
    61   if(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
     75  if(LEMON_MAINTAINER)
    6276    add_executable(lp_test lp_test.cc)
    6377  else()
    6478    add_executable(lp_test EXCLUDE_FROM_ALL lp_test.cc)
     
    8195
    8296  target_link_libraries(lp_test ${LP_TEST_LIBS})
    8397  add_test(lp_test lp_test)
    84   add_dependencies(check lp_test)
     98  # add_dependencies(check lp_test)
    8599
    86100  if(WIN32 AND LEMON_HAVE_GLPK)
    87     add_custom_command(TARGET lp_test POST_BUILD
    88       COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll $<TARGET_FILE_DIR:lp_test>
    89       COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll $<TARGET_FILE_DIR:lp_test>
    90       COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll $<TARGET_FILE_DIR:lp_test>
    91     )
     101    get_target_property(TARGET_LOC lp_test LOCATION)
     102    get_filename_component(TARGET_PATH ${TARGET_LOC} PATH)
     103    add_custom_command(
     104      TARGET lp_test
     105      POST_BUILD
     106      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
     107      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll
     108              ${TARGET_PATH}
     109      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH})
    92110  endif()
    93111
    94112  if(WIN32 AND LEMON_HAVE_CPLEX)
    95113    get_target_property(TARGET_LOC lp_test LOCATION)
    96114    get_filename_component(TARGET_PATH ${TARGET_LOC} PATH)
    97     add_custom_command(TARGET lp_test POST_BUILD
    98       COMMAND ${CMAKE_COMMAND} -E copy ${ILOG_CPLEX_DLL} ${TARGET_PATH}
    99     )
     115    add_custom_command(
     116      TARGET lp_test
     117      POST_BUILD
     118      COMMAND ${CMAKE_COMMAND} -E copy ${ILOG_CPLEX_DLL} ${TARGET_PATH})
    100119  endif()
    101120endif()
    102121
    103122if(LEMON_HAVE_MIP)
    104   if(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
     123  if(LEMON_MAINTAINER)
    105124    add_executable(mip_test mip_test.cc)
    106125  else()
    107126    add_executable(mip_test EXCLUDE_FROM_ALL mip_test.cc)
     
    126145  if(WIN32 AND LEMON_HAVE_GLPK)
    127146    get_target_property(TARGET_LOC mip_test LOCATION)
    128147    get_filename_component(TARGET_PATH ${TARGET_LOC} PATH)
    129     add_custom_command(TARGET mip_test POST_BUILD
     148    add_custom_command(
     149      TARGET mip_test
     150      POST_BUILD
    130151      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
    131       COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
    132       COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
    133     )
     152      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll
     153              ${TARGET_PATH}
     154      COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH})
    134155  endif()
    135156
    136157  if(WIN32 AND LEMON_HAVE_CPLEX)
    137158    get_target_property(TARGET_LOC mip_test LOCATION)
    138159    get_filename_component(TARGET_PATH ${TARGET_LOC} PATH)
    139     add_custom_command(TARGET mip_test POST_BUILD
    140       COMMAND ${CMAKE_COMMAND} -E copy ${ILOG_CPLEX_DLL} ${TARGET_PATH}
    141     )
     160    add_custom_command(
     161      TARGET mip_test
     162      POST_BUILD
     163      COMMAND ${CMAKE_COMMAND} -E copy ${ILOG_CPLEX_DLL} ${TARGET_PATH})
    142164  endif()
    143165endif()
    144166
    145167foreach(TEST_NAME ${TESTS})
    146   if(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
    147     add_executable(${TEST_NAME} ${TEST_NAME}.cc)
    148   else()
    149     add_executable(${TEST_NAME} EXCLUDE_FROM_ALL ${TEST_NAME}.cc)
     168  add_executable(${TEST_NAME} ${TEST_NAME}.cc)
     169  target_link_libraries(${TEST_NAME} LEMON::LEMON)
     170  target_include_directories(
     171    ${TEST_NAME}
     172    PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
     173           $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
     174           $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
     175           $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
     176           $<INSTALL_INTERFACE:include/lemon>)
     177  # Inherit lemon target properties (flags, cxx standard)
     178  if(APPLE)
     179    set_target_properties(
     180      ${TEST_NAME} PROPERTIES INSTALL_RPATH
     181                              "@loader_path/../${CMAKE_INSTALL_LIBDIR}")
     182  elseif(UNIX AND NOT APPLE)
     183    set_target_properties(
     184      ${TEST_NAME} PROPERTIES INSTALL_RPATH
     185                              "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
    150186  endif()
    151   target_link_libraries(${TEST_NAME} lemon)
    152     if(TEST_WITH_VALGRIND)
    153       add_test(${TEST_NAME}
    154         valgrind --error-exitcode=1 ${VALGRIND_FLAGS}
    155         ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} )
    156     else()
    157       add_test(${TEST_NAME} ${TEST_NAME})
    158     endif()
     187
     188  if(LEMON_TEST_WITH_VALGRIND)
     189    add_test(${TEST_NAME} valgrind --error-exitcode=1 ${VALGRIND_FLAGS}
     190             ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME})
     191  else()
     192    add_test(${TEST_NAME} ${TEST_NAME})
     193  endif()
    159194  add_dependencies(check ${TEST_NAME})
    160195endforeach()
  • tools/CMakeLists.txt

    diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
    a b  
    1 include_directories(
    2   ${PROJECT_SOURCE_DIR}
    3   ${PROJECT_BINARY_DIR}
    4 )
     1#[[
     2This file is a part of LEMON, a generic C++ optimization library.
     3
     4Copyright (C) 2003-2021
     5Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6(Egervary Research Group on Combinatorial Optimization, EGRES).
    57
    6 link_directories(
    7   ${PROJECT_BINARY_DIR}/lemon
    8 )
     8Permission to use, modify and distribute this software is granted
     9provided that this copyright notice appears in all copies. For
     10precise terms see the accompanying LICENSE file.
     11
     12This software is provided "AS IS" with no warranty of any kind,
     13express or implied, and with no claim as to its suitability for any
     14purpose.
     15]]
     16
     17#[[
     18This file builds some optional tools.
     19]]
    920
    1021add_executable(lgf-gen lgf-gen.cc)
    11 target_link_libraries(lgf-gen lemon)
     22target_link_libraries(lgf-gen LEMON::LEMON)
    1223
    1324add_executable(dimacs-to-lgf dimacs-to-lgf.cc)
    14 target_link_libraries(dimacs-to-lgf lemon)
     25target_link_libraries(dimacs-to-lgf LEMON::LEMON)
    1526
    1627add_executable(dimacs-solver dimacs-solver.cc)
    17 target_link_libraries(dimacs-solver lemon)
     28target_link_libraries(dimacs-solver LEMON::LEMON)
    1829
    19 install(
    20   TARGETS lgf-gen dimacs-to-lgf dimacs-solver
    21   RUNTIME DESTINATION bin
    22   COMPONENT bin
    23 )
     30install(TARGETS lgf-gen dimacs-to-lgf dimacs-solver RUNTIME DESTINATION bin
     31                                                            COMPONENT bin)
    2432
     33# TODO: Check
    2534if(NOT WIN32)
    2635  install(
    2736    PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/lemon-0.x-to-1.x.sh
    2837    DESTINATION bin
    29     COMPONENT bin
    30   )
     38    COMPONENT bin)
    3139endif()