project(libi2ncommon)
# Version settings
-set(VERSION 2.3)
+set(VERSION 2.9)
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}")
add_definitions(-DDEBUG)
endif(${CMAKE_BUILD_TYPE} STREQUAL Debug)
+# Enable all warnings
+add_definitions("-Wall")
+
# Set components
set(CPACK_COMPONENTS_ALL sharedlibs staticlibs headers)
set(CPACK_COMPONENT_SHAREDLIBS_DISPLAY_NAME "Shared libraries")
set(CPACK_COMPONENT_SHAREDLIBS_GROUP "Development")
set(CPACK_COMPONENT_HEADERS_GROUP "Development")
+# Create suffix to eventually install in lib64
+IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ SET(LIB_SUFFIX "")
+ SET(PACK_ARCH "")
+ ELSE(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ SET(LIB_SUFFIX 64)
+ SET(PACK_ARCH .x86_64)
+endif(CMAKE_SIZEOF_VOID_P EQUAL 4)
+
# Package information
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_PACKAGE_CONTACT "Intra2net AG <libi2ncommon@developer.intra2net.com>")
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}${PACK_ARCH})
-set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/COPYING.GPL)
+set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/Linking-Exception.txt)
+set(CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/COPYING.GPL)
set(CPACK_SOURCE_GENERATOR TGZ)
set(CPACK_SOURCE_IGNORE_FILES
)
set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
+# "make dist" target
+set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${VERSION})
+add_custom_target(dist
+ COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
+ | bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
# documentation
option(DOCUMENTATION "Generate API documentation with Doxygen" ON)
find_package(Doxygen)
add_custom_target(docs ALL DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html)
message(STATUS "Generating API documentation with Doxygen")
-else(DOXYGEN_FOUND)
+else(DOCUMENTATION AND DOXYGEN_FOUND)
message(STATUS "Not generating API documentation")
-endif(DOXYGEN_FOUND)
+endif(DOCUMENTATION AND DOXYGEN_FOUND)
# Conditional build itmes
option(BUILD_XMLLIB "Build xml part of libi2ncommon - needs patched libxml++" OFF)
# pkgconfig output
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
-set(includedir ${CMAKE_INSTALL_PREFIX}/include)
-set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
+set(includedir ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME})
+set(libdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
# construct ${BOOST_LDADD} from ${Boost_LIBRARIES}
-string(REGEX REPLACE ";" " " BOOST_LDADD "${Boost_IOSTREAMS_LIBRARIES}")
-set(BOOST_LDADD "${BOOST_LDADD}")
+# forming "-L/some/path -lboost_a -L/other/path -lboost_b" from
+# "/some/path/libboost_a.so.3.5;/other/path/libboost_b.so"
+set(BOOST_LDADD "")
+FOREACH(boost_lib_full ${Boost_IOSTREAMS_LIBRARIES})
+ get_filename_component(boost_lib_path ${boost_lib_full} PATH)
+ get_filename_component(boost_lib_file ${boost_lib_full} NAME_WE)
+ string(REGEX REPLACE "^lib(boost.+)$" "\\1" boost_lib_name ${boost_lib_file})
+ set(BOOST_LDADD "${BOOST_LDADD} -L${boost_lib_path} -l${boost_lib_name}")
+ENDFOREACH()
# construct ${BOOST_CFLAGS} from ${Boost_INCLUDE_DIRS}
string(REGEX REPLACE ";" " -I" BOOST_CFLAGS "${Boost_INCLUDE_DIRS}")
install(FILES ${CMAKE_BINARY_DIR}/libi2ncommon.pc
${CMAKE_BINARY_DIR}/libi2ncommon_config.pc
${CMAKE_BINARY_DIR}/libi2ncommon_utils.pc
- DESTINATION lib/pkgconfig)
+ DESTINATION lib${LIB_SUFFIX}/pkgconfig)
if (BUILD_XMLLIB)
configure_file(${CMAKE_SOURCE_DIR}/libi2ncommon_xml.pc.in ${CMAKE_BINARY_DIR}/libi2ncommon_xml.pc @ONLY)
- install(FILES ${CMAKE_BINARY_DIR}/libi2ncommon_xml.pc DESTINATION lib/pkgconfig)
+ install(FILES ${CMAKE_BINARY_DIR}/libi2ncommon_xml.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig)
endif(BUILD_XMLLIB)