summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-03-28 20:57:22 +0200
committerKonstantin Käfer <mail@kkaefer.com>2017-03-28 21:24:12 +0200
commita9896fa01b72f260940c3b5df4eec0c1b73dce26 (patch)
treed446118ec178a61f5be73e4f1662866c80c0c141 /cmake
parentc86b492bf7df62f8c09ec565b7ccfb4cd2bfcc79 (diff)
downloadqtlocation-mapboxgl-a9896fa01b72f260940c3b5df4eec0c1b73dce26.tar.gz
[build] generate .xcconfig files with configure_file
We previously used incremental `file(WRITE ...)` commands that gradually recreated the file on every CMake invocation. This sometimes lead to Xcode parsing a partially written file, which in turn breaks building dependend targets. Instead, we're now using a templated configuration file, which ensure that the file is created in one go and hopefully reduces the race condition between CMake and Xcode's automatic project updating.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/core.cmake1
-rw-r--r--cmake/loop-darwin.cmake1
-rw-r--r--cmake/loop-uv.cmake1
-rw-r--r--cmake/mbgl.cmake23
4 files changed, 12 insertions, 14 deletions
diff --git a/cmake/core.cmake b/cmake/core.cmake
index 78800a4838..616e43028c 100644
--- a/cmake/core.cmake
+++ b/cmake/core.cmake
@@ -29,4 +29,3 @@ target_add_mason_package(mbgl-core PRIVATE wagyu)
mbgl_platform_core()
create_source_groups(mbgl-core)
-target_append_xcconfig(mbgl-core)
diff --git a/cmake/loop-darwin.cmake b/cmake/loop-darwin.cmake
index c16d0de3ac..92ea631809 100644
--- a/cmake/loop-darwin.cmake
+++ b/cmake/loop-darwin.cmake
@@ -17,4 +17,3 @@ target_include_directories(mbgl-loop-darwin
)
create_source_groups(mbgl-loop-darwin)
-target_append_xcconfig(mbgl-loop-darwin)
diff --git a/cmake/loop-uv.cmake b/cmake/loop-uv.cmake
index b7757c719a..0f55fce64c 100644
--- a/cmake/loop-uv.cmake
+++ b/cmake/loop-uv.cmake
@@ -15,4 +15,3 @@ target_include_directories(mbgl-loop-uv
)
create_source_groups(mbgl-loop-uv)
-target_append_xcconfig(mbgl-loop-uv)
diff --git a/cmake/mbgl.cmake b/cmake/mbgl.cmake
index 8c9aa0fe8f..429e4d6172 100644
--- a/cmake/mbgl.cmake
+++ b/cmake/mbgl.cmake
@@ -85,27 +85,28 @@ macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE)
set_property(TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE})
endmacro (set_xcode_property)
-function(_write_xcconfig_var target var)
+function(_get_xcconfig_property target var)
get_property(result TARGET ${target} PROPERTY INTERFACE_${var} SET)
if (result)
get_property(result TARGET ${target} PROPERTY INTERFACE_${var})
string(REPLACE ";" "\" \"" result "${result}")
string(REPLACE "-" "_" target "${target}")
- file(APPEND "${CMAKE_BINARY_DIR}/config.xcconfig" "${target}_${var} = \"${result}\"\n")
+ set(${target}_${var} "${result}" PARENT_SCOPE)
endif()
endfunction()
-function(target_append_xcconfig target)
- file(APPEND "${CMAKE_BINARY_DIR}/config.xcconfig" "\n// ${target}\n")
- _write_xcconfig_var(${target} INCLUDE_DIRECTORIES)
- _write_xcconfig_var(${target} COMPILE_DEFINITIONS)
- _write_xcconfig_var(${target} COMPILE_OPTIONS)
- _write_xcconfig_var(${target} LINK_LIBRARIES)
+function(write_xcconfig_target_properties)
+ foreach(target ${ARGN})
+ _get_xcconfig_property(${target} INCLUDE_DIRECTORIES)
+ _get_xcconfig_property(${target} LINK_LIBRARIES)
+ endforeach()
+ configure_file(
+ "${CMAKE_SOURCE_DIR}/scripts/config.xcconfig.in"
+ "${CMAKE_BINARY_DIR}/config.xcconfig"
+ @ONLY
+ )
endfunction()
-# Start a new file when we're running CMake
-file(WRITE "${CMAKE_BINARY_DIR}/config.xcconfig" "// Do not edit -- generated by CMake\n")
-
# CMake 3.1 does not have this yet.
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14")
set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14")