CMake: generate SkUserConfig.h with configure_file
1) It's simpler.
2) It should cache correctly (and not trigger total rebuilds everytime we re-run CMake.)
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1544493002
CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-x86_64-Release-CMake-Trybot,Build-Mac10.9-Clang-x86_64-Release-CMake-Trybot
Review URL: https://codereview.chromium.org/1544493002
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index fcbce4f..adc4150 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -216,6 +216,7 @@
list (APPEND libs ${OSMESA_LIBRARIES})
list (APPEND private_includes ${OSMESA_INCLUDE_DIRS})
list (APPEND public_defines "-DSK_MESA=1")
+ set (SK_MESA 1)
else()
remove_srcs(../src/gpu/gl/mesa/*)
endif()
@@ -261,21 +262,10 @@
install(TARGETS skia DESTINATION lib)
# SkUserConfig.h
-set (userconfig_path ${userconfig_directory}/SkUserConfig.h)
-file(WRITE ${userconfig_path} "// SkUserConfig generated by CMake.\n")
-file(APPEND ${userconfig_path} "#ifndef SkUserConfig_DEFINED\n")
-file(APPEND ${userconfig_path} "#define SkUserConfig_DEFINED\n")
if (CMAKE_BUILD_TYPE STREQUAL Release)
- file(APPEND ${userconfig_path} "#define SK_RELEASE\n")
- file(APPEND ${userconfig_path} "#undef SK_DEBUG\n")
-else ()
- file(APPEND ${userconfig_path} "#define SK_DEBUG\n")
- file(APPEND ${userconfig_path} "#undef SK_RELEASE\n")
-endif ()
-if (OSMESA_LIBRARIES AND OSMESA_INCLUDE_DIRS)
- file (APPEND ${userconfig_path} "#define SK_MESA 1\n")
+ set (SK_RELEASE 1)
endif()
-file(APPEND ${userconfig_path} "#endif // SkUserConfig_DEFINED\n")
+configure_file ("SkUserConfig.h.in" "${userconfig_directory}/SkUserConfig.h")
# skia_link_arguments.txt
set (link_arguments ${CMAKE_BINARY_DIR}/skia_link_arguments.txt)
diff --git a/cmake/SkUserConfig.h.in b/cmake/SkUserConfig.h.in
new file mode 100644
index 0000000..0649656
--- /dev/null
+++ b/cmake/SkUserConfig.h.in
@@ -0,0 +1,15 @@
+// SkUserConfig generated by CMake.
+#ifndef SkUserConfig_DEFINED
+#define SkUserConfig_DEFINED
+
+#if ${SK_RELEASE}
+ #define SK_RELEASE
+ #undef SK_DEBUG
+#else
+ #define SK_DEBUG
+ #undef SK_RELEASE
+#endif
+
+#cmakedefine01 SK_MESA
+
+#endif