1 ############################################################################
3 # Copyright 2010-2012 BMW Car IT GmbH
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 ############################################################################
19 MACRO(add_subdirectory_once path)
20 get_filename_component(subdir ${path} NAME)
21 if (NOT ${subdir}_already_built)
22 set(${subdir}_already_built 1)
23 add_subdirectory(${path})
24 endif (NOT ${subdir}_already_built)
25 ENDMACRO(add_subdirectory_once)
27 MACRO(project_type mode)
28 string(TOUPPER ${mode} mode_capital)
29 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS_${mode_capital}}")
30 set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
32 if (mode_capital STREQUAL "PLUGIN" AND WITH_STATIC_LIBRARIES)
33 set (STATICALLY_LINKED_PLUGINS ${STATICALLY_LINKED_PLUGINS}
34 ${PROJECT_NAME} CACHE INTERNAL "list of static plugins")
35 endif (mode_capital STREQUAL "PLUGIN" AND WITH_STATIC_LIBRARIES)
37 ENDMACRO(project_type)
39 MACRO(export_build_flag name description)
40 set (descLine "/* ${description} */")
41 set (nameLine "#cmakedefine ${name}")
42 SET(BUILD_FLAG_LIST "${BUILD_FLAG_LIST};${descLine};${nameLine}; " CACHE INTERNAL "")
43 SET(BUILD_FLAG_ARRAY "${BUILD_FLAG_ARRAY};${name}" CACHE INTERNAL "")
44 ENDMACRO(export_build_flag)
46 MACRO(build_flag name description defaultvalue)
47 export_build_flag(${name} "${description}")
48 option (${name} "${description}" ${defaultvalue})