set (CMAKE_BUILD_TYPE Release)
endif ()
-set (userconfig_directory ${CMAKE_BINARY_DIR}/include)
-set (userconfig_path ${userconfig_directory}/SkUserConfig.h)
-file(WRITE ${userconfig_path} "// SkUserConfig generated by CMake.\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 ()
-
# To first approximation, the Skia library comprises all .cpp files under src/.
file (GLOB_RECURSE srcs ../src/*.cpp)
list (REMOVE_ITEM public_includes ${private_includes}) # Easiest way to exclude private.
file (GLOB default_include_config "../include/config")
list (REMOVE_ITEM public_includes ${default_include_config})
+set (userconfig_directory ${CMAKE_BINARY_DIR}/include)
list (APPEND public_includes ${userconfig_directory})
# These guys are third_party but provided by a Skia checkout.
list (APPEND libs ${OSMESA_LIBRARIES})
list (APPEND private_includes ${OSMESA_INCLUDE_DIRS})
list (APPEND public_defines "-DSK_MESA=1")
- file (APPEND ${userconfig_path} "#define SK_MESA 1\n")
else()
remove_srcs(../src/gpu/gl/mesa/*)
endif()
install(FILES ${c_headers} DESTINATION include)
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")
+endif()
+file(APPEND ${userconfig_path} "#endif // SkUserConfig_DEFINED\n")
+
+# skia_link_arguments.txt
+set (link_arguments ${CMAKE_BINARY_DIR}/skia_link_arguments.txt)
+file (WRITE ${link_arguments} "-L${CMAKE_BINARY_DIR}\n")
+file (APPEND ${link_arguments} "-lskia\n")
+file (APPEND ${link_arguments} "-Wl,-rpath,${CMAKE_BINARY_DIR}\n")
+
+# skia_compile_arguments.txt
+set (compile_arguments ${CMAKE_BINARY_DIR}/skia_compile_arguments.txt)
+file (WRITE ${compile_arguments} "--std=c++11\n")
+foreach (include ${public_includes})
+ get_filename_component (abs_include ${include} ABSOLUTE)
+ file (APPEND ${compile_arguments} "-I${abs_include}\n")
+endforeach()
+
+# cmake .
+# cmake --build . --target skia
+# c++ -c @skia_compile_arguments.txt example.cpp
+# c++ example.o @skia_link_arguments.txt
+
+# skia.h
+set (skia_h_path ${userconfig_directory}/skia.h)
+file (WRITE ${skia_h_path} "// skia.h generated by CMake.\n")
+file(APPEND ${skia_h_path} "#ifndef skia_DEFINED\n")
+file(APPEND ${skia_h_path} "#define skia_DEFINED\n")
+foreach (include ${public_includes})
+ if (NOT include STREQUAL userconfig_directory)
+ file (APPEND ${skia_h_path} "\n")
+ file (GLOB all_public_headers ${include}/*.h)
+ foreach (public_header ${all_public_headers})
+ get_filename_component (filename_component ${public_header} NAME)
+ file (APPEND ${skia_h_path} "#include \"${filename_component}\"\n")
+ endforeach()
+ endif()
+endforeach()
+file(APPEND ${skia_h_path} "\n#endif // skia_DEFINED\n")
+
# Now build a simple example app that uses Skia via libskia.so.
add_executable(example example.cpp)
target_link_libraries(example skia ${OPENGL_LIBRARIES})