diff --git a/CMakeLists.txt b/CMakeLists.txt index 01af5c4b0..c2b11a3b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,6 +103,7 @@ set(MAPNIK_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING "Install directory for l set(MAPNIK_ARCHIVE_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING "Install directory for archives") set(MAPNIK_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE STRING "Install directory for the headers") set(MAPNIK_CMAKE_DIR ${MAPNIK_LIB_DIR}/cmake/mapnik CACHE STRING "Install directory of the cmake targets") +set(MAPNIK_PKGCONF_DIR ${MAPNIK_LIB_DIR}/pkgconfig CACHE STRING "Install directory for the .pc files for pkg-config") if(WIN32) set(DEFAULT_PLUGINS_INSTALL_DIR ${MAPNIK_BIN_DIR}/mapnik/input) @@ -374,6 +375,7 @@ endif() # start package mapnik include(MapnikExport) +include(MapnikExportPkgConfig) install(DIRECTORY include/ DESTINATION ${MAPNIK_INCLUDE_DIR}) install(DIRECTORY deps/agg/include/ DESTINATION ${MAPNIK_INCLUDE_DIR}) diff --git a/cmake/MapnikExportPkgConfig.cmake b/cmake/MapnikExportPkgConfig.cmake new file mode 100644 index 000000000..e054de9f2 --- /dev/null +++ b/cmake/MapnikExportPkgConfig.cmake @@ -0,0 +1,57 @@ +function(create_pkg_config_file _lib_name _description) + string(CONFIGURE [[ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +includedir=${prefix}/include +libdir=${exec_prefix}/lib + +Name: @_lib_name@ +Description: @_description@ +Version: @MAPNIK_VERSION@ +Libs: -L"${libdir}" -l@_lib_name@ +Cflags: -I"${includedir}" ]] + _contents @ONLY) + + file(GENERATE + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_lib_name}.pc + CONTENT "${_contents}" + ) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${_lib_name}.pc + DESTINATION ${MAPNIK_PKGCONF_DIR} + ) +endfunction() + +function(create_pkg_config_file_mapnik _lib_name _description) + get_target_property(_compile_defs core INTERFACE_COMPILE_DEFINITIONS) + string(JOIN " -D" _str_compile_defs ${_compile_defs}) + if(_str_compile_defs) + set(_str_compile_defs "-D${_str_compile_defs}") + endif() + string(CONFIGURE [[ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +includedir=${prefix}/include +libdir=${exec_prefix}/lib + +Name: @_lib_name@ +Description: @_description@ +Version: @MAPNIK_VERSION@ +Requires: libmapnikwkt libmapnikjson +Libs: -L"${libdir}" -l@_lib_name@ -llibmapnikwkt -llibmapnikjson +Cflags: -I"${includedir}" @_str_compile_defs@]] + _contents @ONLY) + file(GENERATE + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_lib_name}.pc + CONTENT "${_contents}" + ) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${_lib_name}.pc + DESTINATION ${MAPNIK_PKGCONF_DIR} + ) +endfunction() + + +create_pkg_config_file(libmapnikwkt "wkt library") +create_pkg_config_file(libmapnikjson "json library") +create_pkg_config_file_mapnik("libmapnik" "mapnik library") diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index 0c334c2a3..01efdb819 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -28,7 +28,7 @@ set_target_properties(json PROPERTIES POSITION_INDEPENDENT_CODE ON DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}" OUTPUT_NAME "json" - PREFIX "libmapnik-" + PREFIX "libmapnik" VERSION ${MAPNIK_VERSION} # see mapnik target for explanation SOVERSION ${MAPNIK_VERSION} diff --git a/src/wkt/CMakeLists.txt b/src/wkt/CMakeLists.txt index 7b1815705..7aef814ad 100644 --- a/src/wkt/CMakeLists.txt +++ b/src/wkt/CMakeLists.txt @@ -20,7 +20,7 @@ set_target_properties(wkt PROPERTIES POSITION_INDEPENDENT_CODE ON DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}" OUTPUT_NAME "wkt" - PREFIX "libmapnik-" + PREFIX "libmapnik" VERSION ${MAPNIK_VERSION} # see mapnik target for explanation SOVERSION ${MAPNIK_VERSION}