-cmake_minimum_required( VERSION 2.6 )
+# IMPORTANT: Do not add whitespaces between cmake commands! This will break
+# the package build!
+# Do set(CONTENTS) instead of set( CONTENTS ) or set (CONTENTS)
-# project definitions
-project( libpingcheck CXX )
-set( MAJOR_VERSION 0 )
-set( MINOR_VERSION 1 )
-set( VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION} )
+# cmake: required version
+cmake_minimum_required (VERSION 2.6)
-# build type
-set( CMAKE_BUILD_TYPE Debug )
+# cmake: set the directory where the executable will be placed
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
-# set the directory where the executable will be placed
-set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
+# cmake: set the directory where the make install places the executable
+set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR})
-# set the directory where the make install places the executable
-#set( CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR} )
+# project: definitions
+project(libpingcheck)
+set(VERSION 0.1)
+set(TARGET ${PROJECT_NAME})
-# enable or disable the full compiler output
-set( CMAKE_VERBOSE_MAKEFILE OFF )
+# compiler: disable the full compiler output
+set(CMAKE_VERBOSE_MAKEFILE OFF)
-# add definitions, compiler switches, etc.
+# compiler: build type
+set(CMAKE_BUILD_TYPE Debug)
+
+# compiler: add definitions and arguments to the compiler
add_definitions(
- -Werror -Wall -Wextra -Weffc++ -O2 -DVERSION_STRING=${VERSION_STRING}
+ -Werror -Wall -Wextra -Weffc++ -O2 -DVERSION_STRING=${VERSION}
-DPROJECT_NAME=\"${PROJECT_NAME}\"
)
-# required boost libraries
-set( Boost_USE_STATIC_LIBS ON )
-set( Boost_USE_MULTITHREADED ON )
-set( Boost_USE_STATIC_RUNTIME OFF )
-find_package( Boost COMPONENTS filesystem program_options REQUIRED )
+# package: package information
+set(CPACK_PACKAGE_VERSION ${VERSION})
+set(CPACK_PACKAGE_CONTACT "Intra2net AG")
+set(CPACK_PACKAGE_DESCRIPTION ${TARGET})
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Pingcheck")
+set(CPACK_SOURCE_GENERATOR TGZ)
+set(CPACK_SOURCE_IGNORE_FILES "\\\\.git;build;build-rpm")
+set(CPACK_SOURCE_PACKAGE_FILE_NAME "${TARGET}-${VERSION}")
# build the application in the source directory
-add_subdirectory( src )
+add_subdirectory(src)
+
+# package: ???
+include(CPack)
-# include directories where the source code is located
+# package: required boost libraries
+set(Boost_USE_STATIC_LIBS ON)
+set(Boost_USE_MULTITHREADED ON)
+set(Boost_USE_STATIC_RUNTIME OFF)
+find_package(Boost COMPONENTS filesystem program_options REQUIRED)
+
+# package: find external packages
+include(FindPkgConfig)
+pkg_check_modules(I2NCOMMON REQUIRED libi2ncommon)
+
+# compiler: include directories where the source code is located
include_directories(
- ${CMAKE_CURRENT_SOURCE_DIR}
${Boost_INCLUDE_DIRS}
+ ${I2NCOMMON_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_SOURCE_DIR}
)
-# source code files
-set( SOURCES
+# compiler: source code files
+set(SOURCES
config/configuration.cpp
config/configurationreader.cpp
config/host.cpp
main.cpp
)
-# binary name
-set( TARGET ${PROJECT_NAME} )
+# compiler: creates the binary
+add_executable(${TARGET} ${SOURCES})
-# creates the binary
-add_executable( ${TARGET} ${SOURCES} )
+# linker: libraries search path
+link_directories(
+ ${Boost_LIBRARY_DIRS}
+# ${I2NCOMMON_LIBRARY_DIRS}
+)
-# link the program against the libraries
-target_link_libraries( ${TARGET} ${Boost_LIBRARIES} )
+# linker: link the program against the libraries
+target_link_libraries(
+ ${TARGET}
+ ${Boost_LIBRARIES}
+# ${I2NCOMMON_LIBRARIES}
+)
# creates the install rule for the binary
-install( TARGETS ${TARGET} DESTINATION bin )
+install(TARGETS ${TARGET} DESTINATION bin)