|
| 1 | +cmake_minimum_required( VERSION 3.6 ) |
| 2 | + |
| 3 | +set( project_name png ) |
| 4 | +project( ${project_name} ) |
| 5 | + |
| 6 | +if( MSVC ) |
| 7 | + add_definitions(/MP) |
| 8 | +endif() |
| 9 | + |
| 10 | +set( source_dir ${CMAKE_CURRENT_SOURCE_DIR}/jni ) |
| 11 | + |
| 12 | +set( headers |
| 13 | + ${source_dir}/pnginfo.h |
| 14 | + ${source_dir}/config.h |
| 15 | + ${source_dir}/png.h |
| 16 | + ${source_dir}/pngconf.h |
| 17 | + ${source_dir}/pngdebug.h |
| 18 | + ${source_dir}/pnglibconf.h |
| 19 | + ${source_dir}/pngprefix.h |
| 20 | + ${source_dir}/pngpriv.h |
| 21 | + ${source_dir}/pngstruct.h |
| 22 | +) |
| 23 | + |
| 24 | +set( sources |
| 25 | + ${source_dir}/arm/arm_init.c |
| 26 | + ${source_dir}/arm/filter_neon.S |
| 27 | + ${source_dir}/arm/filter_neon_intrinsics.c |
| 28 | + ${source_dir}/png.c |
| 29 | + ${source_dir}/pngerror.c |
| 30 | + ${source_dir}/pngget.c |
| 31 | + ${source_dir}/pngmem.c |
| 32 | + ${source_dir}/pngpread.c |
| 33 | + ${source_dir}/pngread.c |
| 34 | + ${source_dir}/pngrio.c |
| 35 | + ${source_dir}/pngrtran.c |
| 36 | + ${source_dir}/pngrutil.c |
| 37 | + ${source_dir}/pngset.c |
| 38 | + ${source_dir}/pngtest.c |
| 39 | + ${source_dir}/pngtrans.c |
| 40 | + ${source_dir}/pngwio.c |
| 41 | + ${source_dir}/pngwrite.c |
| 42 | + ${source_dir}/pngwtran.c |
| 43 | + ${source_dir}/pngwutil.c |
| 44 | +) |
| 45 | + |
| 46 | +find_package( zlib REQUIRED ) |
| 47 | + |
| 48 | +# If you want a shared library instead of static, specify the BUILD_SHARED_LIBS |
| 49 | +# variable (which is a built-in CMake option). |
| 50 | +add_library( ${project_name} ${sources} ${headers} ) |
| 51 | +target_link_libraries( ${project_name} PUBLIC ZLIB::ZLIB ) |
| 52 | +target_include_directories( ${project_name} PUBLIC |
| 53 | + $<BUILD_INTERFACE:${source_dir}> |
| 54 | + $<INSTALL_INTERFACE:include> |
| 55 | +) |
| 56 | + |
| 57 | +############################################################ |
| 58 | +## INSTALL |
| 59 | +############################################################ |
| 60 | + |
| 61 | +include( CMakePackageConfigHelpers ) |
| 62 | + |
| 63 | +set( PNG_VERSION 1.6.29 ) |
| 64 | +set( PNG_EXPORT_DIR share/png-${PNG_VERSION}/cmake ) |
| 65 | +set( PNG_EXPORT_NAME png-export ) |
| 66 | + |
| 67 | +install( TARGETS png EXPORT ${PNG_EXPORT_NAME} |
| 68 | + RUNTIME DESTINATION bin |
| 69 | + LIBRARY DESTINATION lib |
| 70 | + ARCHIVE DESTINATION lib |
| 71 | + INCLUDES DESTINATION include |
| 72 | +) |
| 73 | + |
| 74 | +install( FILES ${headers} DESTINATION include ) |
| 75 | +install( EXPORT ${PNG_EXPORT_NAME} DESTINATION ${PNG_EXPORT_DIR} ) |
| 76 | + |
| 77 | +configure_file( png-config.cmake.in png-config.cmake @ONLY ) |
| 78 | + |
| 79 | +write_basic_package_version_file( |
| 80 | + png-config-version.cmake |
| 81 | + VERSION ${PNG_VERSION} |
| 82 | + COMPATIBILITY AnyNewerVersion |
| 83 | +) |
| 84 | + |
| 85 | +install( |
| 86 | + FILES |
| 87 | + ${CMAKE_CURRENT_BINARY_DIR}/png-config.cmake |
| 88 | + ${CMAKE_CURRENT_BINARY_DIR}/png-config-version.cmake |
| 89 | + DESTINATION ${PNG_EXPORT_DIR} |
| 90 | +) |
0 commit comments