Skip to content

Commit

Permalink
Add CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslo committed Mar 23, 2018
1 parent 29b019f commit 55cd69e
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
102 changes: 102 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
)

# 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}"
)

# }
4 changes: 4 additions & 0 deletions cmake/template/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
check_required_components("@PROJECT_NAME@")

0 comments on commit 55cd69e

Please sign in to comment.