author | Wuzzy <Wuzzy2@mail.ru> |
Mon, 03 Sep 2018 21:19:15 +0200 | |
changeset 13754 | 5525f69bf76b |
parent 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}") |
9339
14f5f3a1e2f7
some work on cmake_pascal files to better support flags we use, make engine compile as library again
koda
parents:
9274
diff
changeset
|
40 |
#executables |
14f5f3a1e2f7
some work on cmake_pascal files to better support flags we use, make engine compile as library again
koda
parents:
9274
diff
changeset
|
41 |
add_flag_append(CMAKE_C_LINK_FLAGS "-Wl,${_FLAG}") |
14f5f3a1e2f7
some work on cmake_pascal files to better support flags we use, make engine compile as library again
koda
parents:
9274
diff
changeset
|
42 |
add_flag_append(CMAKE_CXX_LINK_FLAGS "-Wl,${_FLAG}") |
14f5f3a1e2f7
some work on cmake_pascal files to better support flags we use, make engine compile as library again
koda
parents:
9274
diff
changeset
|
43 |
add_flag_append(CMAKE_Pascal_LINK_FLAGS "-k${_FLAG}") |
14f5f3a1e2f7
some work on cmake_pascal files to better support flags we use, make engine compile as library again
koda
parents:
9274
diff
changeset
|
44 |
#libraries |
9227 | 45 |
add_flag_append(CMAKE_SHARED_LIBRARY_C_FLAGS "-Wl,${_FLAG}") |
46 |
add_flag_append(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-Wl,${_FLAG}") |
|
9339
14f5f3a1e2f7
some work on cmake_pascal files to better support flags we use, make engine compile as library again
koda
parents:
9274
diff
changeset
|
47 |
#CMAKE_SHARED_LIBRARY_Pascal_FLAGS is already set by CMAKE_Pascal_LINK_FLAGS |
9225
d8d929f92633
use target name instead of the resulting library, use more macros around
koda
parents:
9224
diff
changeset
|
48 |
endmacro(add_linker_flag _FLAG) |
d8d929f92633
use target name instead of the resulting library, use more macros around
koda
parents:
9224
diff
changeset
|
49 |
|
d8d929f92633
use target name instead of the resulting library, use more macros around
koda
parents:
9224
diff
changeset
|
50 |
#TODO: find_package_or_bundle |
d8d929f92633
use target name instead of the resulting library, use more macros around
koda
parents:
9224
diff
changeset
|
51 |
|
d8d929f92633
use target name instead of the resulting library, use more macros around
koda
parents:
9224
diff
changeset
|
52 |
|
d8d929f92633
use target name instead of the resulting library, use more macros around
koda
parents:
9224
diff
changeset
|
53 |