Fix quantifiers variable elimination for parametric datatypes (#7358)
[cvc5.git] / cmake / FindDummy.cmake.template
1 ###############################################################################
2 # Top contributors (to current version):
3 # Gereon Kremer
4 #
5 # This file is part of the cvc5 project.
6 #
7 # Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
8 # in the top-level source directory and their institutional affiliations.
9 # All rights reserved. See the file COPYING in the top-level source
10 # directory for licensing information.
11 # #############################################################################
12 #
13 # This file serves as a template for how the FindX.cmake scripts should work.
14 #
15 # Find Dummy library
16 # Exported variables:
17 # Dummy_FOUND - we have the Dummy lib, always true
18 # Dummy_FOUND_SYSTEM - we use the system version
19 # Exported targets:
20 # Dummy - an imported library target
21 ##
22
23 # provides some utility definitions
24 include(deps-helper)
25
26 # initial setup, for example load Java, Python, ...
27
28 # first look for the library using the standard procedures
29 find_path(Dummy_INCLUDE_DIR NAMES dummy/dummy.h)
30 find_library(Dummy_LIBRARIES NAMES dummy)
31
32 # check whether we found something
33 set(Dummy_FOUND_SYSTEM FALSE)
34 if(Dummy_INCLUDE_DIR AND Dummy_LIBRARIES)
35 # was installed system wide
36 set(Dummy_FOUND_SYSTEM TRUE)
37
38 # parse the version
39 file(STRINGS ${Dummy_INCLUDE_DIR}/dummy/dummy.h Dummy_VERSION REGEX "^#define DUMMY_VERSION .*")
40 string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" Dummy_VERSION "${Dummy_VERSION}")
41
42 # check whether the version satisfies the version requirement
43 # this may reset the Dummy_FOUND_SYSTEM variable
44 check_system_version("Dummy")
45 endif()
46
47 # not found or version too old
48 if(NOT Dummy_FOUND_SYSTEM)
49 # we install the library with an external project
50 include(ExternalProject)
51
52 # check for cases where the external project is known to fail
53 # it might make sense to specify a reason
54 fail_if_cross_compiling("Windows" "" "Dummy" "some reason")
55 fail_if_cross_compiling("" "arm" "Dummy" "some reason")
56
57 # declare some release, version, tag, commit
58 set(Dummy_VERSION "1.2.3")
59 # do whatever is necessary
60 # - use some common config
61 # - prefer URL to GIT (to avoid rebuilds)
62 # - only build / install static versions if possible
63 # - pass ${TOOLCHAIN_PREFIX}
64 ExternalProject_Add(
65 Dummy-EP
66 ${COMMON_EP_CONFIG}
67 URL https://dummy.org/download/dummy-${Dummy_VERSION}.tar.bz2
68 URL_HASH SHA1=abc123
69 CMAKE_ARGS
70 -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
71 -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
72 )
73 # we may have dependencies on some other library
74 add_dependencies(Dummy-EP Foo)
75
76 # set the variables like the find_* commands at the top
77 set(Dummy_INCLUDE_DIR "${DEPS_BASE}/include/")
78 set(Dummy_LIBRARIES "${DEPS_BASE}/lib/libdummy.a")
79 endif()
80
81 # just set this to true
82 set(Dummy_FOUND TRUE)
83
84 # now create a target for the library
85 add_library(Dummy STATIC IMPORTED GLOBAL)
86 set_target_properties(Dummy PROPERTIES IMPORTED_LOCATION "${Dummy_LIBRARIES}")
87 set_target_properties(Dummy PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Dummy_INCLUDE_DIR}")
88
89 # mark all variables as advanced
90 mark_as_advanced(Dummy_FOUND)
91 mark_as_advanced(Dummy_FOUND_SYSTEM)
92 mark_as_advanced(Dummy_INCLUDE_DIR)
93 mark_as_advanced(Dummy_LIBRARIES)
94
95 # print an appropriate message
96 if(Dummy_FOUND_SYSTEM)
97 message(STATUS "Found Dummy ${Dummy_VERSION}: ${Dummy_LIBRARIES}")
98 else()
99 message(STATUS "Building Dummy ${Dummy_VERSION}: ${Dummy_LIBRARIES}")
100 # make sure the external project is actually build
101 add_dependencies(Dummy Dummy-EP)
102 endif()