From 5169eaf0eefd635f18a04e4d403e6beb97c5b679 Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Fri, 24 Mar 2017 20:39:23 +0100
Subject: [PATCH] Fix cmake rules to install executable, libraries and headers

I should note that I don't have much experience with CMake, so I'm not
sure if this solution is _correct_. However, it works as expected.

Fixes #58
---
 CMakeLists.txt        | 7 ++++++-
 src/libmtex2MML.pc.in | 2 +-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a19eab4..f4d6bcc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,7 +42,7 @@ set(MTEX2MML_VERSION_STRING "${MTEX2MML_VERSION_MAJOR}.${MTEX2MML_VERSION_MINOR}
 #
 set(BIN_INSTALL_DIR bin CACHE PATH "Where to install binaries to.")
 set(LIB_INSTALL_DIR lib CACHE PATH "Where to install libraries to.")
-set(INCLUDE_INSTALL_DIR include CACHE PATH "Where to install headers to.")
+set(INCLUDE_INSTALL_DIR include/${PROJECT_NAME} CACHE PATH "Where to install headers to.")
 
 #
 #
@@ -107,6 +107,11 @@ add_library(${STATICLIBRARY} STATIC
 )
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/libmtex2MML.pc.in
 ${CMAKE_CURRENT_BINARY_DIR}/libmtex2MML.pc @ONLY)
+
+install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${BIN_INSTALL_DIR})
+install(TARGETS ${LIBRARY} LIBRARY DESTINATION ${LIB_INSTALL_DIR})
+install(TARGETS ${STATICLIBRARY} ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
+install(FILES ${SRC_H} DESTINATION ${INCLUDE_INSTALL_DIR})
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libmtex2MML.pc
   DESTINATION lib/pkgconfig)
 
diff --git a/src/libmtex2MML.pc.in b/src/libmtex2MML.pc.in
index 0bc2557..b49c75f 100644
--- a/src/libmtex2MML.pc.in
+++ b/src/libmtex2MML.pc.in
@@ -1,10 +1,10 @@ Name: libmtex2MML
 prefix=@CMAKE_INSTALL_PREFIX@
-exec_prefix=@CMAKE_INSTALL_PREFIX@
-libdir=@CMAKE_INSTALL_PREFIX@/lib
-includedir=@CMAKE_INSTALL_PREFIX@/include
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
 
 Name: libmtex2MML
 Description: A Bison grammar to convert TeX math into MathML.
 Version: @PROJECT_VERSION@
 Libs: -L${libdir} -lmtex2MML
-Cflags: -I${includedir}
+Cflags: -I${includedir}/mtex2MML
