File: FindNLopt.cmake

package info (click to toggle)
libnest2d 5.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,016 kB
  • sloc: cpp: 12,037; python: 73; makefile: 2
file content (83 lines) | stat: -rw-r--r-- 2,437 bytes parent folder | download | duplicates (3)
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(CMAKE_BUILD_TYPE MATCHES "(Debug|DEBUG|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()