From 0deb2f52d50e7f06e39e557e08e87d57c7da9893 Mon Sep 17 00:00:00 2001
From: Andrea Censi <andrea@cds.caltech.edu>
Date: Mon, 24 May 2010 02:42:21 +0000
Subject: [PATCH]

---
 docs/example-linking-cmake/CMakeLists.txt | 23 +++++++++++++++++++++++
 docs/example-linking-cmake/myprogram.c    |  5 +++++
 2 files changed, 28 insertions(+)
 create mode 100644 docs/example-linking-cmake/CMakeLists.txt
 create mode 100644 docs/example-linking-cmake/myprogram.c

diff --git a/docs/example-linking-cmake/CMakeLists.txt b/docs/example-linking-cmake/CMakeLists.txt
new file mode 100644
index 0000000..c9bae75
--- /dev/null
+++ b/docs/example-linking-cmake/CMakeLists.txt
@@ -0,0 +1,23 @@
+cmake_minimum_required(VERSION 2.4)
+project(myproject)
+
+# Require we have pkgconfig installed
+find_package(PkgConfig REQUIRED)
+# Tell pkgconfig to look for CSM
+pkg_check_modules(CSM REQUIRED csm)
+
+IF(${CSM_FOUND})
+	MESSAGE("CSM_LIBRARY_DIRS: ${CSM_LIBRARY_DIRS}")
+	MESSAGE("CSM_LIBRARIES: ${CSM_LIBRARIES}")
+	MESSAGE("CSM_INCLUDE_DIRS: ${CSM_INCLUDE_DIRS}")
+
+	INCLUDE_DIRECTORIES(${CSM_INCLUDE_DIRS}) # important! 
+	LINK_DIRECTORIES(${CSM_LIBRARY_DIRS})    # important! 
+ELSE(${CSM_FOUND})	
+	MESSAGE(FATAL_ERROR "CSM not found. Check that the environment variable PKG_CONFIG_PATH includes the path containing the file 'csm.pc'.")
+ENDIF(${CSM_FOUND})		
+
+add_executable(myprogram myprogram.c)
+
+target_link_libraries(myprogram ${CSM_LIBRARIES}) # important! 
+
diff --git a/docs/example-linking-cmake/myprogram.c b/docs/example-linking-cmake/myprogram.c
new file mode 100644
index 0000000..d07f1f0
--- /dev/null
+++ b/docs/example-linking-cmake/myprogram.c
@@ -0,0 +1,5 @@
+#include <csm/csm_all.h>
+
+int main() {
+	
+}
\ No newline at end of file
-- 
GitLab