| Index: cmake/CMakeLists.txt
|
| diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
|
| index f87b5f836b276868974cf1060ee525f9ebe8ccc6..5f0049bdad609443a0267329c49a88c8b6eda028 100644
|
| --- a/cmake/CMakeLists.txt
|
| +++ b/cmake/CMakeLists.txt
|
| @@ -8,17 +8,6 @@ if (NOT CMAKE_BUILD_TYPE)
|
| 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)
|
|
|
| @@ -39,6 +28,7 @@ find_include_dirs(public_includes ../include/*.h)
|
| 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.
|
| @@ -215,7 +205,6 @@ if (OSMESA_LIBRARIES AND OSMESA_INCLUDE_DIRS)
|
| 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()
|
| @@ -260,6 +249,59 @@ file(GLOB c_headers "../include/c/*.h")
|
| 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})
|
|
|