diff lib/CMakeLists.txt @ 74:35ef15100de8

CMake: install pkg-config file, #440
author David Demelier <markand@malikania.fr>
date Sat, 26 Mar 2016 14:41:53 +0100
parents 98ac3c79009f
children f8160d515a76
line wrap: on
line diff
--- a/lib/CMakeLists.txt	Fri Mar 25 13:58:12 2016 +0100
+++ b/lib/CMakeLists.txt	Sat Mar 26 14:41:53 2016 +0100
@@ -1,8 +1,25 @@
+#
+# CMakeLists.txt -- CMake build system for irccd
+#
+# Copyright (c) 2013-2016 David Demelier <markand@malikania.fr>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
 project(lib)
 
 include(irccd/CMakeSources.cmake)
 
-# TMP
 add_library(libirccd ${HEADERS} ${SOURCES})
 
 target_include_directories(
@@ -20,6 +37,38 @@
 endif ()
 
 target_link_libraries(libirccd extern-duktape extern-ircclient extern-jansson ${LIBRARIES})
-set_target_properties(libirccd PROPERTIES PREFIX "")
+
+set_target_properties(
+	libirccd
+	PROPERTIES
+		PREFIX ""
+		OUTPUT_NAME_DEBUG libirccd2d
+		VERSION ${IRCCD_VERSION}
+		SOVERSION ${IRCCD_VERSION_SHLIB}
+)
+
+install(
+	TARGETS libirccd
+	RUNTIME DESTINATION bin
+	LIBRARY DESTINATION lib
+	ARCHIVE DESTINATION lib
+)
 
-# TODO: install with export stuff and all
+# pkg-config
+if (WITH_PKGCONFIG)
+	# Configure the pkg-config file.
+	configure_file(
+		${CMAKE_SOURCE_DIR}/cmake/internal/irccd2.pc.in
+		${CMAKE_BINARY_DIR}/irccd2.pc.tmp
+		@ONLY
+	)
+
+	# Adjust the library output name if debug.
+	file(
+		GENERATE
+		OUTPUT ${CMAKE_BINARY_DIR}/irccd2.pc
+		INPUT ${CMAKE_BINARY_DIR}/irccd2.pc.tmp
+	)
+
+	install(FILES ${CMAKE_BINARY_DIR}/irccd2.pc DESTINATION ${WITH_PKGCONFIGDIR})
+endif ()