source: trunk/cmake/optional_package.cmake @ 2771

Last change on this file since 2771 was 2771, checked in by bradbell, 7 years ago

Separate optional_package macro and improve its documentation.

  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1# $Id: optional_package.cmake 2771 2013-03-08 14:53:54Z bradbell $
2# -----------------------------------------------------------------------------
3# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell
4#
5# CppAD is distributed under multiple licenses. This distribution is under
6# the terms of the
7#                     Eclipse Public License Version 1.0.
8#
9# A copy of this license is included in the COPYING file of this distribution.
10# Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
11# -----------------------------------------------------------------------------
12# optional_package(prefix_variable description)
13#
14# prefix_variable: (out)
15# is a PATH variable that holds the prefix for this optional package.
16# If this variable is not set by the cmake command line (or gui),
17# it is set to the default value NOTFOUND.
18# If this variable is set by the cmake command line, the following is done:
19# 1. All the valid include subdirectories are added using INCLUDE_DIRECTORIES.
20# 2. All the valid library subdirectories are added using LINK_DIRECTORIES.
21# where the valid include and library directories are determined by
22# cmake_install_includedirs and cmakd_install_libdirs respectively.
23#
24# description: (in)
25# is a description for the install prefix for this optional package.
26#
27MACRO(optional_package prefix_variable description) 
28        SET(${prefix_variable} NOTFOUND CACHE PATH "${description}")
29        SET(prefix ${${prefix_variable}} )
30        MESSAGE(STATUS "${prefix_variable} = ${prefix}")
31        IF ( prefix )
32                # List of preprocessor include file search directories
33                FOREACH(dir ${cmake_install_includedirs})
34                        IF(IS_DIRECTORY ${prefix}/${dir} )
35                                INCLUDE_DIRECTORIES( ${prefix}/${dir} )
36                                MESSAGE(STATUS "Found ${prefix}/${dir}")
37                        ENDIF(IS_DIRECTORY ${prefix}/${dir} )
38                ENDFOREACH(dir)
39                # Paths in which the linker will search for libraries,
40                # only applies to targets created after it is called
41                FOREACH(dir ${cmake_install_libdirs})
42                        IF(IS_DIRECTORY ${prefix}/${dir} )
43                                LINK_DIRECTORIES( ${prefix}/${dir} )
44                                MESSAGE(STATUS "Found ${prefix}/${dir}")
45                        ENDIF(IS_DIRECTORY ${prefix}/${dir} )
46                ENDFOREACH(dir)
47        ENDIF ( prefix )
48ENDMACRO(optional_package)
Note: See TracBrowser for help on using the repository browser.