This repository has been archived by the owner on Nov 20, 2021. It is now read-only.
forked from NathanFrench/buildem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindCplex.cmake
155 lines (126 loc) · 5.81 KB
/
FindCplex.cmake
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
# This module finds cplex.
#
# User can give CPLEX_ROOT_DIR as a hint stored in the cmake cache.
#
# It sets the following variables:
# CPLEX_FOUND - Set to false, or undefined, if cplex isn't found.
# CPLEX_INCLUDE_DIRS - include directory
# CPLEX_LIBRARIES - library files
if(WIN32)
execute_process(COMMAND cmd /C set CPLEX_STUDIO_DIR OUTPUT_VARIABLE CPLEX_STUDIO_DIR_VAR ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT CPLEX_STUDIO_DIR_VAR)
MESSAGE(FATAL_ERROR "Unable to find CPLEX: environment variable CPLEX_STUDIO_DIR<VERSION> not set.")
endif()
STRING(REGEX REPLACE "^CPLEX_STUDIO_DIR" "" CPLEX_STUDIO_DIR_VAR ${CPLEX_STUDIO_DIR_VAR})
STRING(REGEX MATCH "^[0-9]+" CPLEX_WIN_VERSION ${CPLEX_STUDIO_DIR_VAR})
STRING(REGEX REPLACE "^[0-9]+=" "" CPLEX_STUDIO_DIR_VAR ${CPLEX_STUDIO_DIR_VAR})
file(TO_CMAKE_PATH "${CPLEX_STUDIO_DIR_VAR}" CPLEX_ROOT_DIR_GUESS)
set(CPLEX_WIN_VERSION ${CPLEX_WIN_VERSION} CACHE STRING "CPLEX version to be used.")
set(CPLEX_ROOT_DIR "${CPLEX_ROOT_DIR_GUESS}" CACHE PATH "CPLEX root directory.")
MESSAGE(STATUS "Found CLPEX version ${CPLEX_WIN_VERSION} at '${CPLEX_ROOT_DIR}'")
STRING(REGEX REPLACE "/VC/bin/.*" "" VISUAL_STUDIO_PATH ${CMAKE_C_COMPILER})
STRING(REGEX MATCH "Studio [0-9]+" CPLEX_WIN_VS_VERSION ${VISUAL_STUDIO_PATH})
STRING(REGEX REPLACE "Studio " "" CPLEX_WIN_VS_VERSION ${CPLEX_WIN_VS_VERSION})
if(${CPLEX_WIN_VS_VERSION} STREQUAL "9")
set(CPLEX_WIN_VS_VERSION 2008)
elseif(${CPLEX_WIN_VS_VERSION} STREQUAL "10")
set(CPLEX_WIN_VS_VERSION 2010)
elseif(${CPLEX_WIN_VS_VERSION} STREQUAL "11")
set(CPLEX_WIN_VS_VERSION 2012)
else()
MESSAGE(FATAL_ERROR "CPLEX: unknown Visual Studio version at '${VISUAL_STUDIO_PATH}'.")
endif()
set(CPLEX_WIN_VS_VERSION ${CPLEX_WIN_VS_VERSION} CACHE STRING "Visual Studio Version")
if("${CMAKE_C_COMPILER}" MATCHES "amd64")
set(CPLEX_WIN_BITNESS x64)
else()
set(CPLEX_WIN_BITNESS x86)
endif()
set(CPLEX_WIN_BITNESS ${CPLEX_WIN_BITNESS} CACHE STRING "On Windows: x86 or x64 (32bit resp. 64bit)")
MESSAGE(STATUS "CPLEX: using Visual Studio ${CPLEX_WIN_VS_VERSION} ${CPLEX_WIN_BITNESS} at '${VISUAL_STUDIO_PATH}'")
if(NOT CPLEX_WIN_LINKAGE)
set(CPLEX_WIN_LINKAGE mda CACHE STRING "CPLEX linkage variant on Windows. One of these: mda (dll, release), mdd (dll, debug), mta (static, release), mtd (static, debug)")
endif(NOT CPLEX_WIN_LINKAGE)
# now, generate platform string
set(CPLEX_WIN_PLATFORM "${CPLEX_WIN_BITNESS}_windows_vs${CPLEX_WIN_VS_VERSION}/stat_${CPLEX_WIN_LINKAGE}")
else()
set(CPLEX_ROOT_DIR "" CACHE PATH "CPLEX root directory.")
set(CPLEX_WIN_PLATFORM "")
endif()
FIND_PATH(CPLEX_INCLUDE_DIR
ilcplex/cplex.h
HINTS ${CPLEX_ROOT_DIR}/cplex/include
${CPLEX_ROOT_DIR}/include
PATHS ENV C_INCLUDE_PATH
ENV C_PLUS_INCLUDE_PATH
ENV INCLUDE_PATH
)
FIND_PATH(CPLEX_CONCERT_INCLUDE_DIR
ilconcert/iloenv.h
HINTS ${CPLEX_ROOT_DIR}/concert/include
${CPLEX_ROOT_DIR}/include
PATHS ENV C_INCLUDE_PATH
ENV C_PLUS_INCLUDE_PATH
ENV INCLUDE_PATH
)
FIND_LIBRARY(CPLEX_LIBRARY
NAMES cplex${CPLEX_WIN_VERSION} cplex
HINTS ${CPLEX_ROOT_DIR}/cplex/lib/${CPLEX_WIN_PLATFORM} #windows
${CPLEX_ROOT_DIR}/cplex/lib/x86-64_debian4.0_4.1/static_pic #unix
${CPLEX_ROOT_DIR}/cplex/lib/x86-64_sles10_4.1/static_pic #unix
${CPLEX_ROOT_DIR}/cplex/lib/x86-64_osx/static_pic #osx
${CPLEX_ROOT_DIR}/cplex/lib/x86-64_darwin/static_pic #osx
PATHS ENV LIBRARY_PATH #unix
ENV LD_LIBRARY_PATH #unix
)
message(STATUS "CPLEX Library: ${CPLEX_LIBRARY}")
FIND_LIBRARY(CPLEX_ILOCPLEX_LIBRARY
ilocplex
HINTS ${CPLEX_ROOT_DIR}/cplex/lib/${CPLEX_WIN_PLATFORM} #windows
${CPLEX_ROOT_DIR}/cplex/lib/x86-64_debian4.0_4.1/static_pic #unix
${CPLEX_ROOT_DIR}/cplex/lib/x86-64_sles10_4.1/static_pic #unix
${CPLEX_ROOT_DIR}/cplex/lib/x86-64_osx/static_pic #osx
${CPLEX_ROOT_DIR}/cplex/lib/x86-64_darwin/static_pic #osx
PATHS ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH
)
message(STATUS "ILOCPLEX Library: ${CPLEX_ILOCPLEX_LIBRARY}")
FIND_LIBRARY(CPLEX_CONCERT_LIBRARY
concert
HINTS ${CPLEX_ROOT_DIR}/concert/lib/${CPLEX_WIN_PLATFORM} #windows
${CPLEX_ROOT_DIR}/concert/lib/x86-64_debian4.0_4.1/static_pic #unix
${CPLEX_ROOT_DIR}/concert/lib/x86-64_sles10_4.1/static_pic #unix
${CPLEX_ROOT_DIR}/concert/lib/x86-64_osx/static_pic #osx
${CPLEX_ROOT_DIR}/concert/lib/x86-64_darwin/static_pic #osx
PATHS ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH
)
message(STATUS "CONCERT Library: ${CPLEX_CONCERT_LIBRARY}")
if(WIN32)
FIND_PATH(CPLEX_BIN_DIR
cplex${CPLEX_WIN_VERSION}.dll
HINTS ${CPLEX_ROOT_DIR}/cplex/bin/${CPLEX_WIN_PLATFORM} #windows
)
else()
FIND_PATH(CPLEX_BIN_DIR
cplex
HINTS ${CPLEX_ROOT_DIR}/cplex/bin/x86-64_sles10_4.1 #unix
${CPLEX_ROOT_DIR}/cplex/bin/x86-64_debian4.0_4.1 #unix
${CPLEX_ROOT_DIR}/cplex/bin/x86-64_osx #osx
${CPLEX_ROOT_DIR}/cplex/bin/x86-64_darwin #osx
ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH
)
endif()
message(STATUS "CPLEX Bin Dir: ${CPLEX_BIN_DIR}")
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPLEX DEFAULT_MSG
CPLEX_LIBRARY CPLEX_INCLUDE_DIR CPLEX_ILOCPLEX_LIBRARY CPLEX_CONCERT_LIBRARY CPLEX_CONCERT_INCLUDE_DIR)
IF(CPLEX_FOUND)
SET(CPLEX_INCLUDE_DIRS ${CPLEX_INCLUDE_DIR} ${CPLEX_CONCERT_INCLUDE_DIR})
SET(CPLEX_LIBRARIES ${CPLEX_CONCERT_LIBRARY} ${CPLEX_ILOCPLEX_LIBRARY} ${CPLEX_LIBRARY} )
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
SET(CPLEX_LIBRARIES "${CPLEX_LIBRARIES};m;pthread")
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
ENDIF(CPLEX_FOUND)
MARK_AS_ADVANCED(CPLEX_LIBRARY CPLEX_INCLUDE_DIR CPLEX_ILOCPLEX_LIBRARY CPLEX_CONCERT_INCLUDE_DIR CPLEX_CONCERT_LIBRARY)