summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Dritschler <timo.dritschler@kit.edu>2014-11-21 14:11:27 +0100
committerTimo Dritschler <timo.dritschler@kit.edu>2014-11-21 14:15:01 +0100
commita0351b722ae0bdbc5ed44eeab21daa230362f6e8 (patch)
treed78e0f678cf4ebc075be5f19a5402ab6e96218a9
parent65c2326592b7b1496c468459689904843e443b26 (diff)
downloadkiro-a0351b722ae0bdbc5ed44eeab21daa230362f6e8.tar.gz
kiro-a0351b722ae0bdbc5ed44eeab21daa230362f6e8.tar.bz2
kiro-a0351b722ae0bdbc5ed44eeab21daa230362f6e8.tar.xz
kiro-a0351b722ae0bdbc5ed44eeab21daa230362f6e8.zip
Fix #5: Changed build process to use ConfigurePaths instead of static paths
-rw-r--r--CMakeLists.txt22
-rw-r--r--common/cmake/ConfigurePaths.cmake90
-rw-r--r--common/cmake/FindGObjectIntrospection.cmake61
-rw-r--r--src/CMakeLists.txt5
-rw-r--r--test/CMakeLists.txt6
5 files changed, 163 insertions, 21 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 98893f3..a2491de 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,12 +10,13 @@ set(LIBKIRO_VERSION_PATCH "0")
set(LIBKIRO_VERSION_RELEASE "1")
set(LIBKIRO_VERSION_STRING "${LIBKIRO_VERSION_MAJOR}.${LIBKIRO_VERSION_MINOR}.${LIBKIRO_VERSION_PATCH}")
set(VERSION "${LIBKIRO_VERSION_STRING}")
-set(LIBKIRO_DESCRIPTION "Tango Device wrapper for an InfiniBand Server and Client")
+set(LIBKIRO_DESCRIPTION "Small InfiniBand communication Server and Client")
set(LIBKIRO_ABI_VERSION "${LIBKIRO_VERSION_MAJOR}.${LIBKIRO_VERSION_MINOR}")
-
set(LIBKIRO_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
+set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/common/cmake")
+
message(STATUS "checking for rdmacm-devel library")
find_path(RDMACM_DIR rdma/rdma_verbs.h)
if(NOT RDMACM_DIR)
@@ -36,17 +37,11 @@ include_directories(
add_definitions(-Wall -Wextra -std=c99)
-# check for 64 bit
-if (CMAKE_SIZEOF_VOID_P EQUAL 8)
- set(LIB_INSTALL_DIR "lib64")
-else()
- set(LIB_INSTALL_DIR "lib")
-endif()
+include(ConfigurePaths)
+configure_paths(KIRO)
-set(HEADER_INSTALL_DIR include/kiro)
add_subdirectory(src)
-
add_subdirectory(test)
set(CPACK_PACKAGE_DESCRIPTION ${LIBKIRO_DESCRIPTION})
@@ -66,14 +61,9 @@ set(CPACK_SOURCE_PACKAGE_FILE_NAME "LIBKIRO-${LIBKIRO_VERSION_STRING}" CACHE INT
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")
-set(LIBKIRO_PKG_PREFIX ${CMAKE_INSTALL_PREFIX})
-set(LIBKIRO_PKG_EXEC_PREFIX "${LIBKIRO_PKG_PREFIX}/bin")
-set(LIBKIRO_PKG_LIBDIR "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}")
-set(LIBKIRO_PKG_INCLUDEDIR "${LIBKIRO_PKG_PREFIX}/include")
-
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/kiro.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/kiro.pc" @ONLY IMMEDIATE)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kiro.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kiro.pc DESTINATION ${KIRO_PKGCONFIGDIR})
include(CPack)
diff --git a/common/cmake/ConfigurePaths.cmake b/common/cmake/ConfigurePaths.cmake
new file mode 100644
index 0000000..df9c03c
--- /dev/null
+++ b/common/cmake/ConfigurePaths.cmake
@@ -0,0 +1,90 @@
+# - pre-configured paths for CMake
+#
+# Usage:
+# configure_paths(<PREFIX>)
+#
+# Checks if configure-like prefix and installation paths were passed by the user
+# and sets up corresponding variables for use in install() commands and to fill
+# out .pc files:
+#
+# PREFIX_PREFIX defaults to ... CMAKE_INSTALL_PREFIX
+# PREFIX_EPREFIX PREFIX_PREFIX
+# PREFIX_SBINDIR PREFIX_EPREFIX/sbin
+# PREFIX_SYSCONFDIR PREFIX_PREFIX/etc
+# PREFIX_LOCALSTATEDIR PREFIX_PREFIX/var
+# PREFIX_BINDIR PREFIX_EPREFIX/bin
+# PREFIX_LIBDIR PREFIX_EPREFIX/lib
+# PREFIX_INCLUDEDIR PREFIX_PREFIX/include
+# PREFIX_PKGCONFIGDIR PREFIX_LIBDIR/pkgconfig
+# PREFIX_TYPELIBDIR PREFIX_LIBDIR/girepository-1.0
+# PREFIX_DATAROOTDIR PREFIX_PREFIX/share
+# PREFIX_DATADIR PREFIX_DATAROOTDIR
+# PREFIX_INFODIR PREFIX_DATAROOTDIR/info
+# PREFIX_MANDIR PREFIX_DATAROOTDIR/man
+# PREFIX_LOCALEDIR PREFIX_DATAROOTDIR/locale
+# PREFIX_GIRDIR PREFIX_DATAROOTDIR/gir-1.0
+
+# Copyright (C) 2013 Matthias Vogelgesang <matthias.vogelgesang@gmail.com>
+#
+# Redistribution and use, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+# 1. Redistributions must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+# 2. The name of the author may not be used to endorse or promote
+# products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+if(__configure_paths)
+ return()
+endif()
+
+set(__configure_paths YES)
+
+macro(_set_var _prefix _var _user _override _description)
+ set(_name "${_prefix}_${_var}")
+
+ set("${_name}" "${_user}")
+
+ if("${_name}" STREQUAL "")
+ set("${_name}" "${_override}")
+ endif()
+
+ set(${_name} "${${_name}}" CACHE PATH "${_description}")
+ mark_as_advanced(${_name})
+endmacro()
+
+function(configure_paths _prefix)
+ _set_var("${_prefix}" "PREFIX" "${PREFIX}" "${CMAKE_INSTALL_PREFIX}" "install architecture-independent files in PREFIX")
+ _set_var("${_prefix}" "EPREFIX" "${EXEC_PREFIX}" "${${_prefix}_PREFIX}" "install architecture-dependent files in EPREFIX")
+
+ _set_var("${_prefix}" "SBINDIR" "${SBINDIR}" "${${_prefix}_EPREFIX}/sbin" "system admin executabls")
+ _set_var("${_prefix}" "SYSCONFDIR" "${SYSCONFDIR}" "${${_prefix}_PREFIX}/etc" "read-only single-machine data")
+ _set_var("${_prefix}" "LOCALSTATEDIR" "${LOCALSTATEDIR}" "${${_prefix}_PREFIX}/var" "modifiable single-machine data")
+ _set_var("${_prefix}" "BINDIR" "${BINDIR}" "${${_prefix}_EPREFIX}/bin" "user executables")
+ _set_var("${_prefix}" "LIBDIR" "${LIBDIR}" "${${_prefix}_EPREFIX}/lib" "object code libraries")
+ _set_var("${_prefix}" "INCLUDEDIR" "${INCLUDEDIR}" "${${_prefix}_PREFIX}/include" "C header files")
+ _set_var("${_prefix}" "PKGCONFIGDIR" "${PKGCONFIGDIR}" "${${_prefix}_LIBDIR}/pkgconfig" "pkg-config files")
+ _set_var("${_prefix}" "TYPELIBDIR" "${TYPELIBDIR}" "${${_prefix}_LIBDIR}/girepository-1.0" "GObject run-time introspection data")
+ _set_var("${_prefix}" "DATAROOTDIR" "${DATAROOTDIR}" "${${_prefix}_PREFIX}/share" "read-only arch.-independent data root")
+ _set_var("${_prefix}" "DATADIR" "${DATADIR}" "${${_prefix}_DATAROOTDIR}" "read-only architecture-independent data")
+ _set_var("${_prefix}" "INFODIR" "${INFODIR}" "${${_prefix}_DATAROOTDIR}/info" "info documentation")
+ _set_var("${_prefix}" "MANDIR" "${MANDIR}" "${${_prefix}_DATAROOTDIR}/man" "man documentation")
+ _set_var("${_prefix}" "LOCALEDIR" "${LOCALEDIR}" "${${_prefix}_DATAROOTDIR}/locale" "locale-dependent data")
+ _set_var("${_prefix}" "GIRDIR" "${GIRDIR}" "${${_prefix}_DATAROOTDIR}/gir-1.0" "GObject introspection data")
+endfunction()
+
+# vim: tw=0:
diff --git a/common/cmake/FindGObjectIntrospection.cmake b/common/cmake/FindGObjectIntrospection.cmake
new file mode 100644
index 0000000..2073c3c
--- /dev/null
+++ b/common/cmake/FindGObjectIntrospection.cmake
@@ -0,0 +1,61 @@
+# - try to find gobject-introspection
+#
+# Once done this will define
+#
+# INTROSPECTION_FOUND - system has gobject-introspection
+# INTROSPECTION_SCANNER - the gobject-introspection scanner, g-ir-scanner
+# INTROSPECTION_COMPILER - the gobject-introspection compiler, g-ir-compiler
+# INTROSPECTION_GENERATE - the gobject-introspection generate, g-ir-generate
+# INTROSPECTION_GIRDIR
+# INTROSPECTION_TYPELIBDIR
+# INTROSPECTION_CFLAGS
+# INTROSPECTION_LIBS
+#
+# Copyright (C) 2010, Pino Toscano, <pino@kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+macro(_GIR_GET_PKGCONFIG_VAR _outvar _varname)
+ execute_process(
+ COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=${_varname} gobject-introspection-1.0
+ OUTPUT_VARIABLE _result
+ RESULT_VARIABLE _null
+ )
+
+ if (_null)
+ else()
+ string(REGEX REPLACE "[\r\n]" " " _result "${_result}")
+ string(REGEX REPLACE " +$" "" _result "${_result}")
+ separate_arguments(_result)
+ set(${_outvar} ${_result} CACHE INTERNAL "")
+ endif()
+endmacro(_GIR_GET_PKGCONFIG_VAR)
+
+find_package(PkgConfig)
+if(PKG_CONFIG_FOUND)
+ if(PACKAGE_FIND_VERSION_COUNT GREATER 0)
+ set(_gir_version_cmp ">=${PACKAGE_FIND_VERSION}")
+ endif()
+ pkg_check_modules(_pc_gir gobject-introspection-1.0${_gir_version_cmp})
+ if(_pc_gir_FOUND)
+ set(INTROSPECTION_FOUND TRUE)
+ _gir_get_pkgconfig_var(INTROSPECTION_SCANNER "g_ir_scanner")
+ _gir_get_pkgconfig_var(INTROSPECTION_COMPILER "g_ir_compiler")
+ _gir_get_pkgconfig_var(INTROSPECTION_GENERATE "g_ir_generate")
+ _gir_get_pkgconfig_var(INTROSPECTION_GIRDIR "girdir")
+ _gir_get_pkgconfig_var(INTROSPECTION_TYPELIBDIR "typelibdir")
+ set(INTROSPECTION_CFLAGS "${_pc_gir_CFLAGS}")
+ set(INTROSPECTION_LIBS "${_pc_gir_LIBS}")
+ endif()
+endif()
+
+mark_as_advanced(
+ INTROSPECTION_SCANNER
+ INTROSPECTION_COMPILER
+ INTROSPECTION_GENERATE
+ INTROSPECTION_GIRDIR
+ INTROSPECTION_TYPELIBDIR
+ INTROSPECTION_CFLAGS
+ INTROSPECTION_LIBS
+)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3fe62a0..c8150c4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,8 +5,9 @@ set_target_properties(kiro PROPERTIES
)
target_link_libraries(kiro m rdmacm ibverbs pthread)
-install(FILES kiro-rdma.h kiro-trb.h kiro-client.h kiro-server.h DESTINATION ${HEADER_INSTALL_DIR})
+install(FILES kiro-rdma.h kiro-trb.h kiro-client.h kiro-server.h DESTINATION
+ ${KIRO_INCLUDEDIR}/kiro)
install(TARGETS kiro
- LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+ LIBRARY DESTINATION ${KIRO_LIBDIR}
)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index a3f7777..35b0531 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -7,9 +7,9 @@ pkg_check_modules(SDL sdl>=1.2.15)
if (SDL_FOUND)
add_executable(kiro-client-sdl test-client.c)
target_link_libraries(kiro-client-sdl kiro SDL m gobject-2.0 glib-2.0)
- install(TARGETS kiro-client-sdl RUNTIME DESTINATION bin)
+ install(TARGETS kiro-client-sdl RUNTIME DESTINATION ${KIRO_BINDIR})
else ()
- message("SDL not found: Won't build KIRO test-client-sdl binary.")
+ message("SDL not found: Won't build kiro-client-sdl binary.")
endif ()
add_executable(kiro-test-latency test-client-latency.c)
@@ -20,4 +20,4 @@ add_executable(kiro-server test-server.c)
target_link_libraries(kiro-server kiro gobject-2.0 glib-2.0)
install(TARGETS kiro-test-bandwidth kiro-test-latency kiro-server
- RUNTIME DESTINATION bin)
+ RUNTIME DESTINATION ${KIRO_BINDIR})