author | koda |
Mon, 08 Jul 2013 01:50:00 +0200 | |
changeset 9331 | 26f0bf0de172 |
parent 9274 | 9749524d1767 |
child 9339 | 14f5f3a1e2f7 |
permissions | -rw-r--r-- |
8686
d303da4568b7
introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff
changeset
|
1 |
|
9225
d8d929f92633
use target name instead of the resulting library, use more macros around
koda
parents:
9224
diff
changeset
|
2 |
#find package helpers |
8686
d303da4568b7
introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff
changeset
|
3 |
macro(find_package_or_fail _PKG_NAME) |
d303da4568b7
introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff
changeset
|
4 |
find_package(${_PKG_NAME}) |
d303da4568b7
introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff
changeset
|
5 |
string(TOUPPER ${_PKG_NAME} _PKG_NAME_UP) |
d303da4568b7
introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff
changeset
|
6 |
if(NOT ${_PKG_NAME_UP}_FOUND) |
d303da4568b7
introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff
changeset
|
7 |
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
|
8 |
endif(NOT ${_PKG_NAME_UP}_FOUND) |
d303da4568b7
introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff
changeset
|
9 |
endmacro(find_package_or_fail _PKG_NAME) |
d303da4568b7
introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff
changeset
|
10 |
|
d303da4568b7
introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff
changeset
|
11 |
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
|
12 |
find_package(${_PKG_NAME}) |
d303da4568b7
introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff
changeset
|
13 |
string(TOUPPER ${_PKG_NAME} _PKG_NAME_UP) |
d303da4568b7
introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff
changeset
|
14 |
if(NOT ${_PKG_NAME_UP}_FOUND) |
9274 | 15 |
message(SEND_ERROR "Missing ${_PKG_NAME}! Rerun cmake with -D${_VAR_NAME}=1 to skip this error.") |
8686
d303da4568b7
introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff
changeset
|
16 |
endif(NOT ${_PKG_NAME_UP}_FOUND) |
d303da4568b7
introduce find_package_or_fail/disable to group together similar cmake code
koda
parents:
diff
changeset
|
17 |
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
|
18 |
|
8688 | 19 |
macro(find_package_or_disable_msg _PKG_NAME _VAR_NAME _MSG) |
20 |
if(NOT ${_VAR_NAME}) |
|
21 |
find_package_or_disable(${_PKG_NAME} ${_VAR_NAME}) |
|
22 |
else(NOT ${_VAR_NAME}) |
|
23 |
message(STATUS "${_PKG_NAME} disabled. ${_MSG}") |
|
24 |
string(TOUPPER ${_PKG_NAME} _PKG_NAME_UP) |
|
25 |
set(${_PKG_NAME_UP}_FOUND false) |
|
26 |
endif(NOT ${_VAR_NAME}) |
|
27 |
endmacro(find_package_or_disable_msg _PKG_NAME _VAR_NAME _MSG) |
|
28 |
||
9225
d8d929f92633
use target name instead of the resulting library, use more macros around
koda
parents:
9224
diff
changeset
|
29 |
#variable manipulation macros |
8772 | 30 |
macro(add_flag_append _VAR_NAME _FLAG) |
31 |
set(${_VAR_NAME} "${${_VAR_NAME}} ${_FLAG}") |
|
32 |
endmacro(add_flag_append _VAR_NAME _FLAG) |
|
33 |
||
34 |
macro(add_flag_prepend _VAR_NAME _FLAG) |
|
8794 | 35 |
set(${_VAR_NAME} "${_FLAG} ${${_VAR_NAME}}") |
8772 | 36 |
endmacro(add_flag_prepend _VAR_NAME _FLAG) |
37 |
||
9225
d8d929f92633
use target name instead of the resulting library, use more macros around
koda
parents:
9224
diff
changeset
|
38 |
macro(add_linker_flag _FLAG) |
9253
90ea56f4f2f5
oops, fix setting linker flags for haskell executables
koda
parents:
9227
diff
changeset
|
39 |
list(APPEND haskell_flags "-optl" "-Wl,${_FLAG}") |
9227 | 40 |
add_flag_append(CMAKE_Pascal_FLAGS "-k${_FLAG}") |
41 |
add_flag_append(CMAKE_EXE_LINKER_FLAGS "-Wl,${_FLAG}") |
|
42 |
add_flag_append(CMAKE_SHARED_LIBRARY_C_FLAGS "-Wl,${_FLAG}") |
|
43 |
add_flag_append(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-Wl,${_FLAG}") |
|
9225
d8d929f92633
use target name instead of the resulting library, use more macros around
koda
parents:
9224
diff
changeset
|
44 |
endmacro(add_linker_flag _FLAG) |
d8d929f92633
use target name instead of the resulting library, use more macros around
koda
parents:
9224
diff
changeset
|
45 |
|
d8d929f92633
use target name instead of the resulting library, use more macros around
koda
parents:
9224
diff
changeset
|
46 |
#TODO: find_package_or_bundle |
d8d929f92633
use target name instead of the resulting library, use more macros around
koda
parents:
9224
diff
changeset
|
47 |
|
d8d929f92633
use target name instead of the resulting library, use more macros around
koda
parents:
9224
diff
changeset
|
48 |
|
d8d929f92633
use target name instead of the resulting library, use more macros around
koda
parents:
9224
diff
changeset
|
49 |