blob: bf2ed3527dc76a7358c15bb296e809b50d526b55 (
plain) (
blame)
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
|
#Find NLopt library.
#The following variables are set
#
#NLopt_FOUND
#NLopt_INCLUDE_DIRS
#NLopt_LIBRARIES
#
#It searches the environment variable $NLopt_PATH automatically.
unset(NLopt_FOUND CACHE)
unset(NLopt_INCLUDE_DIRS CACHE)
unset(NLopt_LIBRARIES CACHE)
unset(NLopt_LIBRARIES_RELEASE CACHE)
unset(NLopt_LIBRARIES_DEBUG CACHE)
if($<LOWER_CASE:${CMAKE_BUILD_TYPE}> EQUAL "debug")
set(NLopt_BUILD_TYPE DEBUG)
else()
set(NLopt_BUILD_TYPE RELEASE)
endif()
find_path(NLopt_INCLUDE_DIRS nlopt.hpp
$ENV{NLopt_PATH}
$ENV{NLopt_PATH}/cpp/
$ENV{NLopt_PATH}/include/
${CMAKE_PREFIX_PATH}/include/nlopt
${CMAKE_PREFIX_PATH}/include/
/opt/local/include/
/opt/local/include/nlopt/
/usr/local/include/
/usr/local/include/nlopt/
/usr/include
/usr/include/nlopt/
)
set(LIB_SEARCHDIRS
$ENV{NLopt_PATH}
$ENV{NLopt_PATH}/cpp/
$ENV{NLopt_PATH}/cpp/build/
$ENV{NLopt_PATH}/lib/
$ENV{NLopt_PATH}/lib/nlopt/
${CMAKE_PREFIX_PATH}/lib/
${CMAKE_PREFIX_PATH}/lib/nlopt/
/opt/local/lib/
/opt/local/lib/nlopt/
/usr/local/lib/
/usr/local/lib/nlopt/
/usr/lib/nlopt
)
set(_deb_postfix "d")
find_library(NLopt_LIBRARIES_RELEASE nlopt ${LIB_SEARCHDIRS})
find_library(NLopt_LIBRARIES_DEBUG nlopt${_deb_postfix} ${LIB_SEARCHDIRS})
if(NLopt_LIBRARIES_${NLopt_BUILD_TYPE})
set(NLopt_LIBRARIES "${NLopt_LIBRARIES_${NLopt_BUILD_TYPE}}")
else()
set(NLopt_LIBRARIES "${NLopt_LIBRARIES_RELEASE}")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NLopt
"NLopt library cannot be found. Consider set NLopt_PATH environment variable"
NLopt_INCLUDE_DIRS
NLopt_LIBRARIES
)
mark_as_advanced(NLopt_INCLUDE_DIRS NLopt_LIBRARIES)
if(NLopt_FOUND)
add_library(NLopt::nlopt UNKNOWN IMPORTED)
set_target_properties(NLopt::nlopt PROPERTIES IMPORTED_LOCATION ${NLopt_LIBRARIES})
set_target_properties(NLopt::nlopt PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${NLopt_INCLUDE_DIRS})
if(NLopt_LIBRARIES_RELEASE AND NLopt_LIBRARIES_DEBUG)
set_target_properties(NLopt::nlopt PROPERTIES
IMPORTED_LOCATION_DEBUG ${NLopt_LIBRARIES_DEBUG}
IMPORTED_LOCATION_RELWITHDEBINFO ${NLopt_LIBRARIES_RELEASE}
IMPORTED_LOCATION_RELEASE ${NLopt_LIBRARIES_RELEASE}
IMPORTED_LOCATION_MINSIZEREL ${NLopt_LIBRARIES_RELEASE}
)
endif()
endif()
|