aboutsummaryrefslogtreecommitdiff
path: root/cmake/VendorConfig.cmake
blob: 1e12b3397f0ed5366f614a3c71425a72760f6e40 (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
50
51
string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME)

if (NOT EXISTS "${PROJECT_SOURCE_DIR}/${SYSTEM_NAME}/.config")
    message(FATAL_ERROR "No vendor config for ${SYSTEM_NAME}: ${PROJECT_SOURCE_DIR}/${SYSTEM_NAME}/.config is missing")
endif()

# the .config has been found

# read .config entries that start with CONFIG_ to a list of strings
file(STRINGS ${PROJECT_SOURCE_DIR}/${SYSTEM_NAME}/.config vendor_config REGEX "^CONFIG_")

# for every item in the list, turn it into a list and set it
foreach(item IN LISTS vendor_config)
    #message("${item}")
    string(REPLACE "\"" "" item ${item})
    string(REGEX REPLACE "(^CONFIG_[^=]*)=(.*$)" "\\1;\\2" item_list ${item})
    #message("${item_list}")
    set(${item_list})
endforeach()

# Compiler settings
# Compiler flags
set(CMAKE_CXX_FLAGS_DEBUG   "${CMAKE_CXX_FLAGS_DEBUG} ${CONFIG_CXX_FLAGS} ${CONFIG_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CONFIG_CXX_FLAGS} ${CONFIG_CXX_FLAGS_RELEASE}")

# Install paths
if(NOT CONFIG_INSTALL_PREFIX STREQUAL "")
    set(CMAKE_INSTALL_PREFIX ${CONFIG_INSTALL_PREFIX})
endif()

## Version information, used in src/version.h.in
if (EXISTS "${PROJECT_SOURCE_DIR}/.git")
    execute_process(COMMAND git rev-list --count HEAD       WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VerRevision OUTPUT_STRIP_TRAILING_WHITESPACE)
    execute_process(COMMAND git rev-parse --short HEAD      WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VerShortId  OUTPUT_STRIP_TRAILING_WHITESPACE)
    execute_process(COMMAND git rev-parse HEAD              WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VerCommit   OUTPUT_STRIP_TRAILING_WHITESPACE)
    execute_process(COMMAND git rev-parse --abbrev-ref HEAD WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE VerBranch   OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()

set(poi_Version     "r${VerRevision}"               CACHE STRING "Short version string")
set(poi_Describe    "r${VerRevision}-${VerShortId}" CACHE STRING "Long version string")
set(poi_Build       "${VerBranch}-${VerCommit}"     CACHE STRING "Build string")

# linking to libc++ doesn't work
if (CONFIG_LLVMLIBCPP)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
endif (CONFIG_LLVMLIBCPP)

if(CONFIG_QTWARNINGS)
    add_definitions(-DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050900)
endif(CONFIG_QTWARNINGS)