Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMake based build support on stable/0.60 #51

Open
wants to merge 3 commits into
base: stable/0.60
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions .dockerignore
@@ -0,0 +1,21 @@
# Project Files unneeded by docker
ci/cache
ci/docker
.git
.gitignore
.github
.dockerignore
.travis.yml
.clang-format
AUTHORS
INSTALL
install-sh
missing
README
README.md

build/

# Editor directories and files
*.user
*.swp
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
*.swp
.vs/
build/
cache/
110 changes: 110 additions & 0 deletions CMakeLists.txt
@@ -0,0 +1,110 @@
cmake_minimum_required(VERSION 3.15)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# option() honors normal variables.
if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()

# MSVC runtime library flags are selected by an abstraction.
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()

include(ParseAc)
parse_ac(VERSION MAJOR MINOR PATCH)

project(Cgl VERSION ${VERSION})

# config options
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)

option(BUILD_SHARED_LIBS "" ON)
if(BUILD_SHARED_LIBS AND MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif(BUILD_SHARED_LIBS AND MSVC)

# config options
if(MSVC)
# Build with multiple processes
add_definitions(/MP)
add_definitions(/D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE)
# MSVC warning suppressions
add_definitions(
/wd4018 # 'expression' : signed/unsigned mismatch
/wd4065 # switch statement contains 'default' but no 'case' labels
/wd4101 # 'identifier' : unreferenced local variable
/wd4102 # 'label' : unreferenced label
/wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data
/wd4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data
/wd4309 # 'conversion' : truncation of constant value
/wd4805 # 'operation' : unsafe mix of type 'type1' and type 'type2' in operation.
/wd4996 # The compiler encountered a deprecated declaration.
)
endif()
if(APPLE)
set(
CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override -Wno-unused-command-line-argument -Wno-unused-result -Wno-exceptions"
)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
endif(APPLE)

# ZLIB
if(NOT TARGET ZLIB::ZLIB)
find_package(ZLIB)
endif()
if(ZLIB_FOUND OR TARGET ZLIB::ZLIB)
message(STATUS "Use zlib")
set(HAVE_ZLIB_H "1" CACHE INTERNAL "Use zlib")
set(COIN_HAS_ZLIB "1" CACHE INTERNAL "Use zlib")
endif()

# PThread
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads)
if(CMAKE_USE_PTHREADS_INIT)
set(PTHREADS_FOUND TRUE)
else()
set(PTHREADS_FOUND FALSE)
endif()

# CoinUtils
if(NOT TARGET Coin::CoinUtils)
find_package(CoinUtils REQUIRED CONFIG)
endif()
# Osi
if(NOT TARGET Coin::Osi)
find_package(Osi REQUIRED CONFIG)
endif()
# Clp
if(NOT TARGET Coin::Clp)
find_package(Clp REQUIRED CONFIG)
endif()

include(CheckEnv)
include(CTest)

add_subdirectory(Cgl)

include(GNUInstallDirs)
install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE Coin::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
include(CMakePackageConfigHelpers)
configure_package_config_file(cmake/Config.cmake.in
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
COMPATIBILITY SameMajorVersion)
install(
FILES
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT Devel)
153 changes: 153 additions & 0 deletions Cgl/CMakeLists.txt
@@ -0,0 +1,153 @@
set(NAME "CGL")

# PTHREAD
if(PTHREADS_FOUND)
set(${NAME}_PTHREADS "1" CACHE INTERNAL "Use pthread")
endif()

set(COIN_${NAME}_CHECKLEVEL "0" CACHE INTERNAL
"${NAME} check level")
set(COIN_${NAME}_VERBOSITY "0" CACHE INTERNAL
"${NAME} verbosity level")
configure_file(config.h.cmake.in config.h)
configure_file(config_cgl.h.cmake.in config_cgl.h)

set(_SRCS
src/CglMixedIntegerRounding/CglMixedIntegerRoundingTest.cpp
src/CglMixedIntegerRounding/CglMixedIntegerRounding.cpp
src/CglDuplicateRow/CglDuplicateRow.cpp
src/CglCutGenerator.cpp
src/CglPreProcess/CglPreProcess.cpp
src/CglProbing/CglProbing.cpp
src/CglProbing/CglProbingTest.cpp
src/CglMixedIntegerRounding2/CglMixedIntegerRounding2.cpp
src/CglMixedIntegerRounding2/CglMixedIntegerRounding2Test.cpp
src/CglLandP/CglLandPUtils.cpp
src/CglLandP/CglLandPTest.cpp
src/CglLandP/CglLandPTabRow.cpp
src/CglLandP/CglLandPSimplex.cpp
src/CglLandP/CglLandPValidator.cpp
src/CglLandP/CglLandPMessages.cpp
src/CglLandP/CglLandP.cpp
src/CglOddHole/CglOddHoleTest.cpp
src/CglOddHole/CglOddHole.cpp
src/CglRedSplit/CglRedSplitParam.cpp
src/CglRedSplit/CglRedSplit.cpp
src/CglRedSplit/CglRedSplitTest.cpp
src/CglAllDifferent/CglAllDifferent.cpp
src/CglKnapsackCover/CglKnapsackCoverTest.cpp
src/CglKnapsackCover/CglKnapsackCover.cpp
src/CglSimpleRounding/CglSimpleRoundingTest.cpp
src/CglSimpleRounding/CglSimpleRounding.cpp
src/CglZeroHalf/CglZeroHalfTest.cpp
src/CglZeroHalf/Cgl012cut.cpp
src/CglZeroHalf/CglZeroHalf.cpp
src/CglRedSplit2/CglRedSplit2Test.cpp
src/CglRedSplit2/CglRedSplit2Param.cpp
src/CglRedSplit2/CglRedSplit2.cpp
src/CglMessage.cpp
src/CglStored.cpp
src/CglParam.cpp
src/CglResidualCapacity/CglResidualCapacity.cpp
src/CglResidualCapacity/CglResidualCapacityTest.cpp
src/CglTwomir/CglTwomirTest.cpp
src/CglTwomir/CglTwomir.cpp
src/CglFlowCover/CglFlowCoverTest.cpp
src/CglFlowCover/CglFlowCover.cpp
src/CglClique/CglCliqueHelper.cpp
src/CglClique/CglCliqueTest.cpp
src/CglClique/CglClique.cpp
src/CglTreeInfo.cpp
src/CglLiftAndProject/CglLiftAndProject.cpp
src/CglGomory/CglGomoryTest.cpp
src/CglGomory/CglGomory.cpp
src/CglGMI/CglGMI.cpp
src/CglGMI/CglGMIParam.cpp)

set(_HDRS
src/CglConfig.h
src/CglMixedIntegerRounding/CglMixedIntegerRounding.hpp
src/CglDuplicateRow/CglDuplicateRow.hpp
src/CglStored.hpp
src/CglPreProcess/CglPreProcess.hpp
src/CglProbing/CglProbing.hpp
src/CglMixedIntegerRounding2/CglMixedIntegerRounding2.hpp
src/CglLandP/CglLandP.hpp
src/CglLandP/CglLandPUtils.hpp
src/CglLandP/CglLandPValidator.hpp
src/CglLandP/CglLandPTabRow.hpp
src/CglLandP/CglLandPMessages.hpp
src/CglLandP/CglLandPSimplex.hpp
src/CglOddHole/CglOddHole.hpp
src/CglRedSplit/CglRedSplitParam.hpp
src/CglRedSplit/CglRedSplit.hpp
src/CglAllDifferent/CglAllDifferent.hpp
src/CglKnapsackCover/CglKnapsackCover.hpp
src/CglSimpleRounding/CglSimpleRounding.hpp
src/CglMessage.hpp
src/CglZeroHalf/CglZeroHalf.hpp
src/CglZeroHalf/Cgl012cut.hpp
src/CglRedSplit2/CglRedSplit2Param.hpp
src/CglRedSplit2/CglRedSplit2.hpp
src/CglCutGenerator.hpp
src/CglResidualCapacity/CglResidualCapacity.hpp
src/CglTwomir/CglTwomir.hpp
src/CglFlowCover/CglFlowCover.hpp
src/CglClique/CglClique.hpp
src/CglLiftAndProject/CglLiftAndProject.hpp
src/CglGomory/CglGomory.hpp
src/CglGMI/CglGMIParam.hpp
src/CglGMI/CglGMI.hpp
src/CglParam.hpp
src/CglTreeInfo.hpp)

add_library(Cgl ${_SRCS} ${_HDRS})
target_include_directories(Cgl PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglClique>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglDuplicateRow>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglFlowCover>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglGMI>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglGomory>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglKnapsackCover>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglLandP>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglMixedIntegerRounding>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglMixedIntegerRounding2>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglPreProcess>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglProbing>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglOddHole>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglRedSplit>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglRedSplit2>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglResidualCapacity>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglSimpleRounding>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglTwomir>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/CglZeroHalf>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include/coin>)
target_compile_definitions(Cgl
PUBLIC HAVE_CONFIG_H
PRIVATE CGL_BUILD)
if(CMAKE_VERSION VERSION_LESS "3.8.2")
set_property(TARGET Cgl PROPERTY CXX_STANDARD 11)
set_property(TARGET Cgl PROPERTY CXX_STANDARD_REQUIRED ON)
else()
target_compile_features(Cgl PUBLIC cxx_std_11)
endif()
target_link_libraries(Cgl PUBLIC
Coin::CoinUtils
Coin::Osi
Coin::OsiClp)
set_target_properties(Cgl PROPERTIES
PUBLIC_HEADER "${_HDRS};${CMAKE_CURRENT_BINARY_DIR}/config_cgl.h"
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})
add_library(Coin::Cgl ALIAS Cgl)

# Install
include(GNUInstallDirs)
install(TARGETS Cgl
EXPORT ${PROJECT_NAME}Targets
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/coin
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)