--- a/CMakeLists.txt Sun Dec 09 19:40:17 2018 +0100
+++ b/CMakeLists.txt Tue Dec 18 21:18:12 2018 +0100
@@ -14,6 +14,21 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-project (relpipe-lib-cli.cpp)
-cmake_minimum_required(VERSION 2.8)
+
+set(PROJECT_CODE "relpipe-lib-cli")
+set(PROJECT_TITLE "Relational pipes - lib - CLI (C++)")
+set(PROJECT_DESCRIPTION "C++ header-only library for command line programs")
+
+
+# The project version should be specified as "cmake -DPROJECT_VERSION=x.y.z" or is derived from current mercurial tag. If current revision has no tag, default version is set:
+if(NOT DEFINED PROJECT_VERSION)
+ execute_process(
+ COMMAND bash -c "hg log -r '.' --template '{latesttag}:{latesttagdistance}:{branch}\\n' | sed -E -e 's/v(.*):0:.*/\\1/g' -e 's/.*:.*:v_(.*)/\\1.9999/g' | grep -E '^[0-9.]+$'"
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE PROJECT_VERSION RESULT_VARIABLE VERSION_ERROR_CODE OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+endif()
+
+cmake_policy(SET CMP0048 NEW)
+project (${PROJECT_CODE}.cpp VERSION ${PROJECT_VERSION})
+cmake_minimum_required(VERSION 3.10.2)
add_subdirectory (src)
--- a/src/CMakeLists.txt Sun Dec 09 19:40:17 2018 +0100
+++ b/src/CMakeLists.txt Tue Dec 18 21:18:12 2018 +0100
@@ -14,11 +14,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-set(LIBRARY_FILE "relpipe-lib-cli")
+set(LIBRARY_FILE ${PROJECT_CODE}.cpp)
+
+configure_file("pkg-config.cpp.pc.in" "${PROJECT_CODE}.cpp.pc" @ONLY)
# Library output:
add_library(
${LIBRARY_FILE} SHARED
- relpipe-lib-cli.cpp
+ ${PROJECT_CODE}.cpp
)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_CODE}.cpp.pc" DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/)
+install(DIRECTORY ../include/ DESTINATION include)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pkg-config.cpp.pc.in Tue Dec 18 21:18:12 2018 +0100
@@ -0,0 +1,12 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=${prefix}/lib/relpipe/
+includedir=${prefix}/include/
+
+Name: @PROJECT_TITLE@
+Description: @PROJECT_DESCRIPTION@
+Version: @PROJECT_VERSION@
+
+# this is header-only library, so no .so
+# Libs: -L${libdir} -l@LIBRARY_FILE@
+
+Cflags: -I${includedir}