cmake_modules/utils.cmake
author koda
Thu, 13 Jun 2013 14:44:28 +0200
changeset 9219 0a4b6bb69f99
parent 8688 88a6114a318c
child 8772 c9583cf8e10d
child 9220 5e7db24f3489
permissions -rw-r--r--
bring windows fixes from main repo
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8686
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
     1
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
     2
macro(find_package_or_fail _PKG_NAME)
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
     3
    find_package(${_PKG_NAME})
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
     4
    string(TOUPPER ${_PKG_NAME} _PKG_NAME_UP)
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
     5
    if(NOT ${_PKG_NAME_UP}_FOUND)
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
     6
        message(SEND_ERROR "Missing ${_PKG_NAME}! Please install it and rerun cmake.")
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
     7
    endif(NOT ${_PKG_NAME_UP}_FOUND)
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
     8
endmacro(find_package_or_fail _PKG_NAME)
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
     9
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
    10
macro(find_package_or_disable _PKG_NAME _VAR_NAME)
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
    11
    find_package(${_PKG_NAME})
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
    12
    string(TOUPPER ${_PKG_NAME} _PKG_NAME_UP)
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
    13
    if(NOT ${_PKG_NAME_UP}_FOUND)
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
    14
        message(SEND_ERROR "Missing ${_PKG_NAME}! Rerun cmake with -D${_VAR_NAME}=1 to build without it.")
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
    15
    endif(NOT ${_PKG_NAME_UP}_FOUND)
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
    16
endmacro(find_package_or_disable _PKG_NAME _VAR_NAME)
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
    17
8688
88a6114a318c even more wrapping with find_package_or_disable_msg
koda
parents: 8686
diff changeset
    18
macro(find_package_or_disable_msg _PKG_NAME _VAR_NAME _MSG)
88a6114a318c even more wrapping with find_package_or_disable_msg
koda
parents: 8686
diff changeset
    19
    if(NOT ${_VAR_NAME})
88a6114a318c even more wrapping with find_package_or_disable_msg
koda
parents: 8686
diff changeset
    20
        find_package_or_disable(${_PKG_NAME} ${_VAR_NAME})
88a6114a318c even more wrapping with find_package_or_disable_msg
koda
parents: 8686
diff changeset
    21
    else(NOT ${_VAR_NAME})
88a6114a318c even more wrapping with find_package_or_disable_msg
koda
parents: 8686
diff changeset
    22
        message(STATUS "${_PKG_NAME} disabled. ${_MSG}")
88a6114a318c even more wrapping with find_package_or_disable_msg
koda
parents: 8686
diff changeset
    23
        string(TOUPPER ${_PKG_NAME} _PKG_NAME_UP)
88a6114a318c even more wrapping with find_package_or_disable_msg
koda
parents: 8686
diff changeset
    24
        set(${_PKG_NAME_UP}_FOUND false)
88a6114a318c even more wrapping with find_package_or_disable_msg
koda
parents: 8686
diff changeset
    25
    endif(NOT ${_VAR_NAME})
88a6114a318c even more wrapping with find_package_or_disable_msg
koda
parents: 8686
diff changeset
    26
endmacro(find_package_or_disable_msg _PKG_NAME _VAR_NAME _MSG)
88a6114a318c even more wrapping with find_package_or_disable_msg
koda
parents: 8686
diff changeset
    27
88a6114a318c even more wrapping with find_package_or_disable_msg
koda
parents: 8686
diff changeset
    28
8686
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
    29
#TODO: find_package_or_bundle
d303da4568b7 introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff changeset
    30