diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..eb40a20a1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,102 @@ +cmake_minimum_required(VERSION 3.2) +project(lcms VERSION 2.9) + +set(lcms_headers include/lcms2.h include/lcms2_plugin.h) + +add_library( + lcms + ${lcms_headers} + src/cmsalpha.c + src/cmscam02.c + src/cmscgats.c + src/cmscnvrt.c + src/cmserr.c + src/cmsgamma.c + src/cmsgmt.c + src/cmshalf.c + src/cmsintrp.c + src/cmsio0.c + src/cmsio1.c + src/cmslut.c + src/cmsmd5.c + src/cmsmtrx.c + src/cmsnamed.c + src/cmsopt.c + src/cmspack.c + src/cmspcs.c + src/cmsplugin.c + src/cmsps2.c + src/cmssamp.c + src/cmssm.c + src/cmstypes.c + src/cmsvirt.c + src/cmswtpnt.c + src/cmsxform.c + src/lcms2_internal.h +) + +target_include_directories( + lcms PUBLIC + "$" +) + +# Installation (https://github.com/forexample/package-example) { + +# Introduce variables: +# * CMAKE_INSTALL_LIBDIR +# * CMAKE_INSTALL_BINDIR +# * CMAKE_INSTALL_INCLUDEDIR +include(GNUInstallDirs) + +set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") + +set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") + +set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") +set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") +set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") +set(namespace "${PROJECT_NAME}::") + +include(CMakePackageConfigHelpers) + +# Use: +# * PROJECT_VERSION +write_basic_package_version_file( + "${version_config}" COMPATIBILITY SameMajorVersion +) + +# Use variables: +# * TARGETS_EXPORT_NAME +# * PROJECT_NAME +configure_package_config_file( + "cmake/template/Config.cmake.in" + "${project_config}" + INSTALL_DESTINATION "${config_install_dir}" +) + +install( + TARGETS lcms + EXPORT "${TARGETS_EXPORT_NAME}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) + +install( + FILES ${lcms_headers} + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) + +install( + FILES "${project_config}" "${version_config}" + DESTINATION "${config_install_dir}" +) + +install( + EXPORT "${TARGETS_EXPORT_NAME}" + NAMESPACE "${namespace}" + DESTINATION "${config_install_dir}" +) + +# } diff --git a/cmake/template/Config.cmake.in b/cmake/template/Config.cmake.in new file mode 100644 index 000000000..38bbde7b3 --- /dev/null +++ b/cmake/template/Config.cmake.in @@ -0,0 +1,4 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake") +check_required_components("@PROJECT_NAME@")