cmake: make maa a proper dynamic library and install it correctly
authorBrendan Le Foll <brendan.le.foll@intel.com>
Wed, 23 Apr 2014 16:28:14 +0000 (17:28 +0100)
committerBrendan Le Foll <brendan.le.foll@intel.com>
Wed, 23 Apr 2014 16:28:14 +0000 (17:28 +0100)
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
CMakeLists.txt
src/CMakeLists.txt
src/maa.pc.cmake [new file with mode: 0644]

index cd442a4..f54e3de 100644 (file)
@@ -1,13 +1,21 @@
 cmake_minimum_required (VERSION 2.8)
 project (maa)
 
-set(SWIG_EXECUTABLE /usr/bin/swig)
-FIND_PACKAGE(SWIG REQUIRED)
-INCLUDE(${SWIG_USE_FILE})
+set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
+set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
 
-SET(CMAKE_SWIG_FLAGS "")
+set(maa_VERSION_MAJOR 0)
+set(maa_VERSION_MINOR 1)
+set(maa_VERSION_PATCH 1)
+set(maa_VERSION_STRING ${maa_VERSION_MAJOR}.${maa_VERSION_MINOR}.${maa_VERSION_PATCH})
 
-option(test "Build all tests." OFF)
+set (SWIG_EXECUTABLE /usr/bin/swig)
+FIND_PACKAGE (SWIG REQUIRED)
+INCLUDE (${SWIG_USE_FILE})
+
+SET (CMAKE_SWIG_FLAGS "")
+
+option (test "Build all tests." OFF)
 
 add_subdirectory (src)
 add_subdirectory (examples)
@@ -15,4 +23,4 @@ add_subdirectory (examples)
 if (test)
   enable_testing ()
   add_subdirectory (tests)
-endif()
+endif ()
index c77b504..2c912b0 100644 (file)
@@ -12,7 +12,23 @@ set (maa_LIB_SRCS
   ${PROJECT_SOURCE_DIR}/src/pwm/pwm.cxx
 )
 
-add_library (maa STATIC ${maa_LIB_SRCS})
+add_library (maa SHARED ${maa_LIB_SRCS})
 
-add_subdirectory(python)
-add_subdirectory(javascript)
+set_target_properties(                                                                                                                                         
+   maa
+   PROPERTIES
+   SOVERSION ${maa_VERSION_MAJOR}
+   VERSION ${maa_VERSION_STRING}
+)
+install (FILES ${maa_LIB_HEADERS} DESTINATION include/maa)
+
+macro(maa_CREATE_INSTALL_PKGCONFIG generated_file install_location)
+  configure_file(${generated_file}.cmake ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} @ONLY)
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location})
+endmacro(maa_CREATE_INSTALL_PKGCONFIG)
+maa_create_install_pkgconfig(maa.pc lib${LIB_SUFFIX}/pkgconfig)
+
+install (TARGETS maa DESTINATION lib)
+
+add_subdirectory (python)
+add_subdirectory (javascript)
diff --git a/src/maa.pc.cmake b/src/maa.pc.cmake
new file mode 100644 (file)
index 0000000..a5e6f75
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib@LIB_SUFFIX@
+includedir=${prefix}/include
+
+Name: maa
+Description: Low Level Skeleton Library for Communication
+Version: @maa_VERSION_STRING@
+
+Libs: -L${libdir} -lmaa
+Cflags: -I${includedir}/maa -lpthread