C++QED  v2 Milestone 10
a framework for simulating open quantum dynamics
Findblitz.cmake
1 # Copyright Raimar Sandner 2012–2014. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.txt)
2 
3 #! \file
4 #! \ingroup FindPackage
5 #! \brief Find blitz++.
6 #!
7 #! Once done, this will define
8 #!
9 #! - `blitz_FOUND`: system has blitz
10 #! - `blitz_INCLUDE_DIRS`: the blitz include directories
11 #! - `blitz_LIBRARIES`: link these to use blitz
12 #! - `blitz_SERIALIZATION_FOUND`: true if blitz was configured with `--enable-serialization`
13 #!
14 #! Not that blitz will only be considered found if it is the [C++QED patched version](http://sourceforge.net/p/cppqed/blitz/ci/default/tree/).
15 #! This is checked by looking if it has `BLITZ_ARRAY_LARGEST_RANK`.
16 
17 include(LibFindMacros)
18 include(CheckIncludeFiles)
19 include(CheckSymbolExists)
20 
21 if (UNIX)
22  find_package(PkgConfig QUIET)
23  pkg_check_modules(blitz_PKGCONF QUIET blitz)
24 endif()
25 
26 # Include dir
27 find_path(blitz_INCLUDE_DIR
28  NAMES blitz/tinyvec2.h
29  HINTS ${blitz_PKGCONF_INCLUDE_DIRS}
30 )
31 
32 # Finally the library itself
33 find_library(blitz_LIBRARY
34  NAMES blitz
35  HINTS ${blitz_PKGCONF_LIBRARY_DIRS}
36 )
37 
38 # Set the include dir variables and the libraries and let libfind_process do the rest.
39 # NOTE: Singular variables for this library, plural for libraries this this lib depends on.
40 set(blitz_PROCESS_INCLUDES blitz_INCLUDE_DIR)
41 set(blitz_PROCESS_LIBS blitz_LIBRARY)
42 libfind_process(blitz)
43 
44 file(READ ${blitz_INCLUDE_DIR}/blitz/blitz.h BLITZ_H)
45 string(REGEX MATCH BLITZ_ARRAY_LARGEST_RANK blitz_IS_CPPQED_VERSION ${BLITZ_H})
46 if(NOT blitz_IS_CPPQED_VERSION)
47  message(FATAL_ERROR "You need the C++QED version of blitz++. The repository is at http://sourceforge.net/p/cppqed/blitz/ci/default/tree/")
48 endif(NOT blitz_IS_CPPQED_VERSION)
49 
50 file(GLOB BZCONFIG ${blitz_INCLUDE_DIR}/blitz/*/bzconfig.h)
51 CHECK_SYMBOL_EXISTS(BZ_HAVE_BOOST_SERIALIZATION ${BZCONFIG} blitz_SERIALIZATION_FOUND)