forked from coin-or/Osi
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
161 lines (128 loc) · 5.09 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Copyright (c) Microsoft Corporation
#
# All rights reserved.
#
# MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is furnished to do
# so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.11)
project(Osi LANGUAGES C CXX VERSION 0.108.7)
set(CMAKE_CXX_STANDARD 14)
include(GNUInstallDirs)
set(INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/Coin)
set(INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
find_package(CoinUtils REQUIRED)
find_package(Mosek)
set(OSI_SOURCES
src/Osi/OsiAuxInfo.cpp
src/Osi/OsiBranchingObject.cpp
src/Osi/OsiChooseVariable.cpp
src/Osi/OsiColCut.cpp
src/Osi/OsiCut.cpp
src/Osi/OsiCuts.cpp
src/Osi/OsiFeatures.cpp
src/Osi/OsiNames.cpp
src/Osi/OsiPresolve.cpp
src/Osi/OsiRowCut.cpp
src/Osi/OsiRowCutDebugger.cpp
src/Osi/OsiSolverBranch.cpp
src/Osi/OsiSolverInterface.cpp
)
set(OSI_HEADERS
src/Osi/config_osi_default.h
src/Osi/OsiAuxInfo.hpp
src/Osi/OsiBranchingObject.hpp
src/Osi/OsiChooseVariable.hpp
src/Osi/OsiColCut.hpp
src/Osi/OsiCollections.hpp
src/Osi/OsiConfig.h
src/Osi/OsiCut.hpp
src/Osi/OsiCuts.hpp
src/Osi/OsiFeatures.hpp
src/Osi/OsiPresolve.hpp
src/Osi/OsiRowCutDebugger.hpp
src/Osi/OsiRowCut.hpp
src/Osi/OsiSolverBranch.hpp
src/Osi/OsiSolverInterface.hpp
src/Osi/OsiSolverParameters.hpp
)
add_library(${PROJECT_NAME} ${OSI_SOURCES})
set(MSVC_OPTIONS /bigobj /MP /wd4996 /wd4819 /wd4251 /wd4267 /wd4244 /wd4275)
set(APPLE_OPTIONS
-Wno-inconsistent-missing-override
-Wno-unused-command-line-argument
-Wno-unused-result
-Wno-exceptions
)
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE ${MSVC_OPTIONS})
target_compile_definitions(${PROJECT_NAME} PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
if(APPLE)
target_compile_options(${PROJECT_NAME} PRIVATE ${APPLE_OPTIONS})
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9"
CACHE STRING "Minimum OS X deployment version")
endif()
target_include_directories(${PROJECT_NAME} PUBLIC $<INSTALL_INTERFACE:${INSTALL_INCLUDE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/Osi>)
target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_CMATH)
target_link_libraries(${PROJECT_NAME} PRIVATE Coin::CoinUtils)
install(FILES ${OSI_HEADERS} DESTINATION ${INSTALL_INCLUDE_DIR})
set(INSTALL_TARGETS ${PROJECT_NAME})
if (${MOSEK_FOUND})
set(OSIMSK_SOURCES
src/OsiMsk/OsiMskSolverInterface.cpp
)
set(OSIMSK_HEADERS
src/OsiMsk/OsiMskSolverInterface.hpp
src/OsiMsk/OsiMskConfig.h
)
add_library(OsiMsk ${OSIMSK_SOURCES})
if(MSVC)
target_compile_options(OsiMsk PRIVATE ${MSVC_OPTIONS})
target_compile_definitions(OsiMsk PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
if(APPLE)
target_compile_options(OsiMsk PRIVATE ${APPLE_OPTIONS})
endif()
target_include_directories(OsiMsk PUBLIC $<INSTALL_INTERFACE:${INSTALL_INCLUDE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/OsiMsk> ${MOSEK_INCLUDE})
target_compile_definitions(OsiMsk PRIVATE HAVE_CMATH)
target_link_libraries(OsiMsk PRIVATE Coin::CoinUtils ${MOSEK_LIB})
install(FILES ${OSIMSK_HEADERS} DESTINATION ${INSTALL_INCLUDE_DIR})
list(APPEND INSTALL_TARGETS OsiMsk)
endif()
install(TARGETS ${INSTALL_TARGETS}
EXPORT "${PROJECT_NAME}Targets"
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin)
include(CMakePackageConfigHelpers)
set(version_config "${CMAKE_CURRENT_BINARY_DIR}/temp/${PROJECT_NAME}ConfigVersion.cmake")
set(project_config "${CMAKE_CURRENT_BINARY_DIR}/temp/${PROJECT_NAME}Config.cmake")
set(namespace "Coin::")
write_basic_package_version_file("${version_config}"
COMPATIBILITY SameMajorVersion)
configure_package_config_file("Config.cmake.in"
"${project_config}"
INSTALL_DESTINATION
"${INSTALL_CMAKE_DIR}")
install(FILES "${project_config}" "${version_config}"
DESTINATION "${INSTALL_CMAKE_DIR}")
install(EXPORT "${PROJECT_NAME}Targets"
NAMESPACE "${namespace}"
DESTINATION "${INSTALL_CMAKE_DIR}")