this repo has no description
1# - Try to find Gecode
2# Once done this will define
3# GECODE_FOUND - System has Gecode
4# GECODE_INCLUDE_DIRS - The Gecode include directories
5# GECODE_LIBRARIES - The libraries needed to use Gecode
6# GECODE_TARGETS - The names of imported targets created for gecode
7# User can set Gecode_ROOT to the preferred installation prefix
8
9find_path(GECODE_INCLUDE gecode/kernel.hh
10 PATH_SUFFIXES include)
11
12find_file(GECODE_CONFIG_LOC gecode/support/config.hpp
13 HINTS ${GECODE_INCLUDE}
14 PATH_SUFFIXES include)
15
16if(NOT "${GECODE_CONFIG_LOC}" STREQUAL "GECODE_CONFIG_LOC-NOTFOUND")
17 file(READ "${GECODE_CONFIG_LOC}" GECODE_CONFIG)
18 string(REGEX MATCH "\#define GECODE_VERSION \"([0-9]+.[0-9]+.[0-9]+)\"" _ "${GECODE_CONFIG}")
19 set(GECODE_VERSION "${CMAKE_MATCH_1}")
20 string(REGEX MATCH "\#define GECODE_LIBRARY_VERSION \"([0-9]+-[0-9]+-[0-9]+)\"" _ "${GECODE_CONFIG}")
21 set(GECODE_LIBRARY_VERSION "${CMAKE_MATCH_1}")
22 string(REGEX MATCH "\#define GECODE_STATIC_LIBS ([0-9]+)" _ "${GECODE_CONFIG}")
23 set(GECODE_STATIC_LIBS "${CMAKE_MATCH_1}")
24 string(REGEX MATCH "\#define GECODE_HAS_GIST" GECODE_HAS_GIST "${GECODE_CONFIG}")
25 string(REGEX MATCH "\#define GECODE_HAS_MPFR" GECODE_HAS_MPFR "${GECODE_CONFIG}")
26 unset(GECODE_CONFIG)
27endif()
28unset(GECODE_CONFIG_LOC)
29
30set(GECODE_COMPONENTS Driver Flatzinc Float Int Kernel Minimodel Search Set Support)
31if(GECODE_HAS_GIST)
32 list(APPEND GECODE_COMPONENTS Gist)
33endif()
34
35foreach(GECODE_COMP ${GECODE_COMPONENTS})
36 # Try to find gecode library
37 string(TOLOWER "gecode${GECODE_COMP}" GECODE_LIB)
38 set(GECODE_LIB_LOC "GECODE_LIB_LOC-NOTFOUND")
39 find_library(GECODE_LIB_LOC NAMES ${GECODE_LIB} lib${GECODE_LIB} ${GECODE_LIB}-${GECODE_LIBRARY_VERSION}-r-x64 ${GECODE_LIB}-${GECODE_LIBRARY_VERSION}-d-x64
40 HINTS ${GECODE_INCLUDE}
41 PATH_SUFFIXES lib)
42 if(NOT "${GECODE_LIB_LOC}" STREQUAL "GECODE_LIB_LOC-NOTFOUND")
43 list(APPEND GECODE_LIBRARY ${GECODE_LIB_LOC})
44 add_library(Gecode::${GECODE_COMP} UNKNOWN IMPORTED)
45 set_target_properties(Gecode::${GECODE_COMP} PROPERTIES
46 IMPORTED_LOCATION ${GECODE_LIB_LOC}
47 INTERFACE_INCLUDE_DIRECTORIES ${GECODE_INCLUDE})
48 set(Gecode_FIND_REQUIRED_${GECODE_COMP} TRUE)
49 set(Gecode_${GECODE_COMP}_FOUND TRUE)
50 endif()
51endforeach(GECODE_COMP)
52
53if(WIN32 AND GECODE_HAS_GIST AND GECODE_STATIC_LIBS)
54 find_package(Qt5 QUIET COMPONENTS Core Gui Widgets PrintSupport)
55 set_target_properties(Gecode::Gist PROPERTIES
56 INTERFACE_LINK_LIBRARIES "Qt5::Core;Qt5::Gui;Qt5::Widgets;Qt5::PrintSupport")
57endif()
58
59unset(GECODE_REQ_LIBS)
60unset(GECODE_LIB_WIN)
61unset(GECODE_LIB_LOC)
62
63if(GECODE_LIBRARY AND GECODE_HAS_MPFR)
64 find_package(MPFR)
65 list(APPEND GECODE_LIBRARY ${MPFR_LIBRARIES})
66 list(APPEND GECODE_TARGETS ${MPFR_LIBRARIES})
67endif()
68
69include(FindPackageHandleStandardArgs)
70# handle the QUIETLY and REQUIRED arguments and set GECODE_FOUND to TRUE
71# if all listed variables are TRUE
72find_package_handle_standard_args(
73 Gecode
74 REQUIRED_VARS GECODE_INCLUDE GECODE_LIBRARY
75 VERSION_VAR GECODE_VERSION
76 HANDLE_COMPONENTS
77 FAIL_MESSAGE "Could NOT find Gecode, use Gecode_ROOT to hint its location"
78)
79
80mark_as_advanced(GECODE_INCLUDE GECODE_LIBRARY)
81
82set(GECODE_LIBRARIES ${GECODE_LIBRARY})
83set(GECODE_INCLUDE_DIRS ${GECODE_INCLUDE})