summaryrefslogtreecommitdiff
path: root/cmake/modules/CustomMacros.txt
blob: d779238c3897d5ee879cb95a5ed6bd93685f879f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
############################################################################
#
# Copyright 2010-2012 BMW Car IT GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
############################################################################

MACRO(add_subdirectory_once path)
    get_filename_component(subdir ${path} NAME)
    if (NOT ${subdir}_already_built)
        set(${subdir}_already_built 1)
        add_subdirectory(${path})
    endif (NOT ${subdir}_already_built)
ENDMACRO(add_subdirectory_once)

MACRO(project_type mode)
    string(TOUPPER ${mode} mode_capital)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS_${mode_capital}}")
    set(CMAKE_C_FLAGS   "${CMAKE_CXX_FLAGS}")

    if (mode_capital STREQUAL "PLUGIN" AND WITH_STATIC_LIBRARIES)
        set (STATICALLY_LINKED_PLUGINS ${STATICALLY_LINKED_PLUGINS}
             ${PROJECT_NAME} CACHE INTERNAL "list of static plugins")
    endif (mode_capital STREQUAL "PLUGIN" AND WITH_STATIC_LIBRARIES)

ENDMACRO(project_type)

MACRO(export_build_flag name description)
    set (descLine "/* ${description} */")
    set (nameLine "#cmakedefine ${name}")
    SET(BUILD_FLAG_LIST  "${BUILD_FLAG_LIST};${descLine};${nameLine}; " CACHE INTERNAL "")
    SET(BUILD_FLAG_ARRAY "${BUILD_FLAG_ARRAY};${name}" CACHE INTERNAL "")
ENDMACRO(export_build_flag)

MACRO(build_flag name description defaultvalue)
    export_build_flag(${name} "${description}")
    option (${name} "${description}" ${defaultvalue})
ENDMACRO(build_flag)