1 ###############################################################################
2 # Top contributors (to current version):
5 # This file is part of the cvc5 project.
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 # #############################################################################
13 # This file serves as a template for how the FindX.cmake scripts should work.
17 # Dummy_FOUND - we have the Dummy lib, always true
18 # Dummy_FOUND_SYSTEM - we use the system version
20 # Dummy - an imported library target
23 # provides some utility definitions
26 # initial setup, for example load Java, Python, ...
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)
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)
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}")
42 # check whether the version satisfies the version requirement
43 # this may reset the Dummy_FOUND_SYSTEM variable
44 check_system_version("Dummy")
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)
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")
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}
67 URL https://dummy.org/download/dummy-${Dummy_VERSION}.tar.bz2
70 -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
71 -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
73 # we may have dependencies on some other library
74 add_dependencies(Dummy-EP Foo)
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")
81 # just set this to true
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}")
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)
95 # print an appropriate message
96 if(Dummy_FOUND_SYSTEM)
97 message(STATUS "Found Dummy ${Dummy_VERSION}: ${Dummy_LIBRARIES}")
99 message(STATUS "Building Dummy ${Dummy_VERSION}: ${Dummy_LIBRARIES}")
100 # make sure the external project is actually build
101 add_dependencies(Dummy Dummy-EP)