Skip to content

Commit ac79a6e

Browse files
committed
[BUILD] switched to proper find module for coin
* fixed compile issue in LPWrapper
1 parent c14d635 commit ac79a6e

File tree

5 files changed

+131
-129
lines changed

5 files changed

+131
-129
lines changed

cmake/build_system_macros.cmake

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
1-
#------------------------------------------------------------------------------
2-
## fills ${varname} with the names of Debug and Release libraries (which usually only differ on MSVC)
3-
## @param varname Name of the variable which will hold the result string (e.g. "optimized myLib.so debug myLibDebug.so")
4-
## @param libnames List of library names which are searched (release libs)
5-
## @param libnames_d List of library names which are searched (debug libs)
6-
## @param human_libname Name of the library (for display only)
7-
macro (OPENMS_CHECKLIB varname libnames libnames_d human_libname)
8-
# force find_library to run again
9-
set(${varname}_OPT "${varname}_OPT-NOTFOUND" CACHE FILEPATH "Cleared." FORCE)
10-
find_library(${varname}_OPT NAMES ${libnames} PATHS ${CONTRIB_LIB_DIR} DOC "${human_libname} library dir" NO_DEFAULT_PATH)
11-
if ("${varname}_OPT" STREQUAL "${varname}_OPT-NOTFOUND")
12-
message(FATAL_ERROR "Unable to find ${human_libname} library! Searched names are: [${libnames}]\nPlease make sure it is part of the contrib (which we assume to be in either of these directories: ${CONTRIB_LIB_DIR}). Set custom contrib paths using the CMAKE_PREFIX_PATH variable in CMake.")
13-
else()
14-
message(STATUS "Found ${human_libname} library (Release) at: " ${${varname}_OPT})
15-
endif()
16-
# force find_library to run again
17-
set(${varname}_DBG "${varname}_DBG-NOTFOUND" CACHE FILEPATH "Cleared." FORCE)
18-
find_library(${varname}_DBG NAMES ${libnames_d} PATHS ${CONTRIB_LIB_DIR} DOC "${human_libname} (Debug) library dir" NO_DEFAULT_PATH)
19-
if ("${varname}_DBG" STREQUAL "${varname}_DBG-NOTFOUND")
20-
message(FATAL_ERROR "Unable to find ${human_libname} (Debug) library! Searched names are: [${libnames}]\nPlease make sure it is part of the contrib (which we assume to be in either of these directories: ${CONTRIB_LIB_DIR}). Set custom contrib paths using the CMAKE_PREFIX_PATH variable in CMake.")
21-
else()
22-
message(STATUS "Found ${human_libname} library (Debug) at: " ${${varname}_DBG})
23-
endif()
24-
## combine result and include "optimized" and "debug" keywords which are essential for target_link_libraries()
25-
set(${varname} optimized ${${varname}_OPT} debug ${${varname}_DBG})
26-
endmacro (OPENMS_CHECKLIB)
1+
# --------------------------------------------------------------------------
2+
# OpenMS -- Open-Source Mass Spectrometry
3+
# --------------------------------------------------------------------------
4+
# Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5+
# ETH Zurich, and Freie Universitaet Berlin 2002-2012.
6+
#
7+
# This software is released under a three-clause BSD license:
8+
# * Redistributions of source code must retain the above copyright
9+
# notice, this list of conditions and the following disclaimer.
10+
# * Redistributions in binary form must reproduce the above copyright
11+
# notice, this list of conditions and the following disclaimer in the
12+
# documentation and/or other materials provided with the distribution.
13+
# * Neither the name of any author or any participating institution
14+
# may be used to endorse or promote products derived from this software
15+
# without specific prior written permission.
16+
# For a full list of authors, refer to the file AUTHORS.
17+
# --------------------------------------------------------------------------
18+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
# ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22+
# INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25+
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27+
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
#
30+
# --------------------------------------------------------------------------
31+
# $Maintainer: Stephan Aiche, Chris Bielow $
32+
# $Authors: Chris Bielow, Stephan Aiche $
33+
# --------------------------------------------------------------------------
2734

2835
#------------------------------------------------------------------------------
2936
## export a single option indicating if boost static libs should be preferred

cmake/modules/FindCOIN.cmake

Lines changed: 88 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,111 @@
1-
SET(COIN_ROOT_DIR "" CACHE PATH "COIN root directory")
1+
# - Try to find COIN
2+
# Once done this will define
3+
#
4+
# COIN_FOUND - system has XercesC
5+
# COIN_INCLUDE_DIRS - the XercesC include directory
6+
# COIN_LIBRARIES - Link these to use XercesC
7+
#
8+
# Inspired by LEMON's FindCOIN
9+
# https://lemon.cs.elte.hu/trac/lemon/browser/lemon/cmake/FindCOIN.cmake
10+
#
11+
#=============================================================================
12+
# Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
13+
# ETH Zurich, and Freie Universitaet Berlin 2002-2013.
14+
#
15+
# This software is released under a three-clause BSD license:
16+
# * Redistributions of source code must retain the above copyright
17+
# notice, this list of conditions and the following disclaimer.
18+
# * Redistributions in binary form must reproduce the above copyright
19+
# notice, this list of conditions and the following disclaimer in the
20+
# documentation and/or other materials provided with the distribution.
21+
# * Neither the name of any author or any participating institution
22+
# may be used to endorse or promote products derived from this software
23+
# without specific prior written permission.
24+
# For a full list of authors, refer to the file AUTHORS.
25+
# --------------------------------------------------------------------------
26+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29+
# ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
30+
# INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
33+
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
34+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
35+
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN if
36+
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37+
#=============================================================================
238

3-
FIND_PATH(COIN_INCLUDE_DIR coin/CoinUtilsConfig.h
39+
# required scripts
40+
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
41+
42+
# hint from the user
43+
set(COIN_ROOT_DIR "" CACHE PATH "COIN root directory")
44+
45+
# find the coin include directory
46+
find_path(COIN_INCLUDE_DIR coin/CoinUtilsConfig.h
447
HINTS ${COIN_ROOT_DIR}/include
548
)
6-
FIND_LIBRARY(COIN_CBC_LIBRARY
7-
NAMES Cbc libCbc
8-
HINTS ${COIN_ROOT_DIR}/lib/coin
9-
HINTS ${COIN_ROOT_DIR}/lib
10-
)
11-
FIND_LIBRARY(COIN_CBC_SOLVER_LIBRARY
12-
NAMES CbcSolver libCbcSolver
13-
HINTS ${COIN_ROOT_DIR}/lib/coin
14-
HINTS ${COIN_ROOT_DIR}/lib
15-
)
16-
FIND_LIBRARY(COIN_CGL_LIBRARY
17-
NAMES Cgl libCgl
18-
HINTS ${COIN_ROOT_DIR}/lib/coin
19-
HINTS ${COIN_ROOT_DIR}/lib
20-
)
21-
FIND_LIBRARY(COIN_CLP_LIBRARY
22-
NAMES Clp libClp
23-
HINTS ${COIN_ROOT_DIR}/lib/coin
24-
HINTS ${COIN_ROOT_DIR}/lib
25-
)
26-
FIND_LIBRARY(COIN_COIN_UTILS_LIBRARY
27-
NAMES CoinUtils libCoinUtils
28-
HINTS ${COIN_ROOT_DIR}/lib/coin
29-
HINTS ${COIN_ROOT_DIR}/lib
30-
)
31-
FIND_LIBRARY(COIN_OSI_LIBRARY
32-
NAMES Osi libOsi
33-
HINTS ${COIN_ROOT_DIR}/lib/coin
34-
HINTS ${COIN_ROOT_DIR}/lib
35-
)
36-
FIND_LIBRARY(COIN_OSI_CBC_LIBRARY
37-
NAMES OsiCbc libOsiCbc
38-
HINTS ${COIN_ROOT_DIR}/lib/coin
39-
HINTS ${COIN_ROOT_DIR}/lib
40-
)
41-
FIND_LIBRARY(COIN_OSI_CLP_LIBRARY
42-
NAMES OsiClp libOsiClp
43-
HINTS ${COIN_ROOT_DIR}/lib/coin
44-
HINTS ${COIN_ROOT_DIR}/lib
45-
)
46-
FIND_LIBRARY(COIN_OSI_VOL_LIBRARY
47-
NAMES OsiVol libOsiVol
48-
HINTS ${COIN_ROOT_DIR}/lib/coin
49-
HINTS ${COIN_ROOT_DIR}/lib
50-
)
51-
FIND_LIBRARY(COIN_VOL_LIBRARY
52-
NAMES Vol libVol
53-
HINTS ${COIN_ROOT_DIR}/lib/coin
54-
HINTS ${COIN_ROOT_DIR}/lib
55-
)
5649

57-
FIND_LIBRARY(COIN_ZLIB_LIBRARY
58-
NAMES z libz
59-
HINTS ${COIN_ROOT_DIR}/lib/coin
60-
HINTS ${COIN_ROOT_DIR}/lib
61-
)
62-
FIND_LIBRARY(COIN_BZ2_LIBRARY
63-
NAMES bz2 libbz2
64-
HINTS ${COIN_ROOT_DIR}/lib/coin
65-
HINTS ${COIN_ROOT_DIR}/lib
66-
)
50+
# helper macro to find specific coind sub-libraries
51+
macro(_coin_find_lib _libname _lib_file_names _lib_file_names_debug)
52+
if(NOT COIN_${_libname})
53+
# find release version
54+
find_library(COIN_${_libname}_LIBRARY_RELEASE
55+
NAMES ${_lib_file_names}
56+
HINTS ${COIN_ROOT_DIR}/lib/coin
57+
HINTS ${COIN_ROOT_DIR}/lib
58+
)
59+
# .. and debug version
60+
find_library(COIN_${_libname}_LIBRARY_DEBUG
61+
NAMES ${_lib_file_names_debug}
62+
HINTS ${COIN_ROOT_DIR}/lib/coin
63+
HINTS ${COIN_ROOT_DIR}/lib
64+
)
65+
66+
# create final library to be exported
67+
select_library_configurations(COIN_${_libname})
68+
endif()
69+
endmacro()
6770

68-
INCLUDE(FindPackageHandleStandardArgs)
69-
FIND_PACKAGE_HANDLE_STANDARD_ARGS(COIN DEFAULT_MSG
71+
# actually find the required libs
72+
_coin_find_lib("CBC" "libCbc;Cbc" "libCbcd;Cbc")
73+
_coin_find_lib("CGL" "libCgl;Cgl" "libCgld;Cgl")
74+
_coin_find_lib("CLP" "libClp;Clp" "libClpd;Clp")
75+
_coin_find_lib("COIN_UTILS" "libCoinUtils;CoinUtils" "libCoinUtilsd;CoinUtils")
76+
_coin_find_lib("OSI" "libOsi;Osi" "libOsid;Osi")
77+
_coin_find_lib("OSI_CLP" "libOsiClp;OsiClp" "libOsiClpd;OsiClp")
78+
79+
include(FindPackageHandleStandardArgs)
80+
find_package_handle_standard_args(COIN DEFAULT_MSG
7081
COIN_INCLUDE_DIR
7182
COIN_CBC_LIBRARY
72-
COIN_CBC_SOLVER_LIBRARY
7383
COIN_CGL_LIBRARY
7484
COIN_CLP_LIBRARY
7585
COIN_COIN_UTILS_LIBRARY
7686
COIN_OSI_LIBRARY
77-
COIN_OSI_CBC_LIBRARY
7887
COIN_OSI_CLP_LIBRARY
79-
# COIN_OSI_VOL_LIBRARY
80-
# COIN_VOL_LIBRARY
8188
)
8289

83-
IF(COIN_FOUND)
84-
SET(COIN_INCLUDE_DIRS ${COIN_INCLUDE_DIR})
85-
SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARY};${COIN_COIN_UTILS_LIBRARY};${COIN_ZLIB_LIBRARY};${COIN_BZ2_LIBRARY}")
86-
IF(COIN_ZLIB_LIBRARY)
87-
SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARIES};${COIN_ZLIB_LIBRARY}")
88-
ENDIF(COIN_ZLIB_LIBRARY)
89-
IF(COIN_BZ2_LIBRARY)
90-
SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARIES};${COIN_BZ2_LIBRARY}")
91-
ENDIF(COIN_BZ2_LIBRARY)
92-
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_ZLIB_LIBRARY};${COIN_BZ2_LIBRARY};${COIN_CLP_LIBRARIES}")
93-
SET(COIN_LIBRARIES ${COIN_CBC_LIBRARIES})
94-
ENDIF(COIN_FOUND)
90+
# export the libraries
91+
if(COIN_FOUND)
92+
set(COIN_INCLUDE_DIRS ${COIN_INCLUDE_DIR})
93+
set(COIN_LIBRARIES
94+
${COIN_CBC_LIBRARY}
95+
${COIN_CGL_LIBRARY}
96+
${COIN_CLP_LIBRARY}
97+
${COIN_COIN_UTILS_LIBRARY}
98+
${COIN_OSI_LIBRARY}
99+
${COIN_OSI_CLP_LIBRARY}
100+
)
101+
endif(COIN_FOUND)
95102

96-
MARK_AS_ADVANCED(
103+
mark_as_advanced(
97104
COIN_INCLUDE_DIR
98105
COIN_CBC_LIBRARY
99-
COIN_CBC_SOLVER_LIBRARY
100106
COIN_CGL_LIBRARY
101107
COIN_CLP_LIBRARY
102108
COIN_COIN_UTILS_LIBRARY
103109
COIN_OSI_LIBRARY
104-
COIN_OSI_CBC_LIBRARY
105110
COIN_OSI_CLP_LIBRARY
106-
COIN_OSI_VOL_LIBRARY
107-
COIN_VOL_LIBRARY
108-
COIN_ZLIB_LIBRARY
109-
COIN_BZ2_LIBRARY
110111
)
111-
112-
IF(COIN_FOUND)
113-
SET(LEMON_HAVE_LP TRUE)
114-
SET(LEMON_HAVE_MIP TRUE)
115-
SET(LEMON_HAVE_CLP TRUE)
116-
SET(LEMON_HAVE_CBC TRUE)
117-
ENDIF(COIN_FOUND)

src/openms/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ include (${PROJECT_SOURCE_DIR}/includes.cmake)
7272

7373
#------------------------------------------------------------------------------
7474
# all the dependency libraries are linked into libOpenMS.so, except Qt
75-
set(OPENMS_DEP_LIBRARIES ${CONTRIB_CBC}
75+
set(OPENMS_DEP_LIBRARIES ${COIN_LIBRARIES}
7676
${GSL_LIBRARIES}
7777
${GSL_CBLAS_LIBRARIES}
7878
${LIBSVM_LIBRARIES}
@@ -118,6 +118,7 @@ openms_add_library(TARGET_NAME OpenMS
118118
${OpenSwathAlgo_INCLUDE_DIRECTORIES}
119119
${CRAWDAD_INCLUDE_DIRS}
120120
${XercesC_INCLUDE_DIRS}
121+
${COIN_INCLUDE_DIRS}
121122
LINK_LIBRARIES OpenSwathAlgo
122123
${APPLE_EXTRA_LIBS}
123124
${QT_LIBRARIES}

src/openms/cmake_findExternalLibs.cmake

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,7 @@ endif()
8888
# COIN-OR
8989
if (${USE_COINOR})
9090
set(CF_USECOINOR 1)
91-
OPENMS_CHECKLIB(CONTRIB_CBC1 "libCbc;Cbc" "libCbcd;Cbc" "COIN-OR Cbc")
92-
OPENMS_CHECKLIB(CONTRIB_CBC2 "libCgl;Cgl" "libCgld;Cgl" "COIN-OR Cgl")
93-
OPENMS_CHECKLIB(CONTRIB_CBC3 "libClp;Clp" "libClpd;Clp" "COIN-OR Clp")
94-
OPENMS_CHECKLIB(CONTRIB_CBC4 "libCoinUtils;CoinUtils" "libCoinUtilsd;CoinUtils" "COIN-OR Utils")
95-
OPENMS_CHECKLIB(CONTRIB_CBC5 "libOsi;Osi" "libOsid;Osi" "COIN-OR Osi")
96-
OPENMS_CHECKLIB(CONTRIB_CBC6 "libOsiClp;OsiClp" "libOsiClpd;OsiClp" "COIN-OR OsiClp")
97-
set(CONTRIB_CBC ${CONTRIB_CBC1} ${CONTRIB_CBC2} ${CONTRIB_CBC3} ${CONTRIB_CBC4} ${CONTRIB_CBC5} ${CONTRIB_CBC6} )
91+
find_package(COIN REQUIRED)
9892
else()
9993
set(CF_USECOINOR 0)
10094
set(CONTRIB_CBC)

src/openms/source/DATASTRUCTURES/LPWrapper.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,13 @@ namespace OpenMS
621621
#endif
622622
}
623623

624-
Int LPWrapper::solve(SolverParam& solver_param, const Size /* verbose_level */)
624+
Int LPWrapper::solve(SolverParam& solver_param, const Size
625+
#if COINOR_SOLVER == 1
626+
verbose_level
627+
#else
628+
/* verbose_level */
629+
#endif
630+
)
625631
{
626632
LOG_INFO << "Using solver '" << (solver_ == LPWrapper::SOLVER_GLPK ? "glpk" : "coinor") << "' ...\n";
627633
if (solver_ == LPWrapper::SOLVER_GLPK)

0 commit comments

Comments
 (0)