-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch from autotools to CMake build system (#23)
* Switch from autotools to CMake * CMake: require at least cmake 3.8 * cmake: updates for tests
- Loading branch information
1 parent
108c33f
commit a6bb8c0
Showing
18 changed files
with
353 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
#------------------------------- | ||
# PROJECT INFORMATION | ||
#------------------------------- | ||
|
||
cmake_minimum_required(VERSION 3.8) | ||
|
||
project(sdbus-c++ VERSION 0.3.2 LANGUAGES C CXX) | ||
|
||
include(GNUInstallDirs) # Installation directories for `install` command and pkgconfig file | ||
|
||
#------------------------------- | ||
# PERFORMING CHECKS | ||
#------------------------------- | ||
|
||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(SYSTEMD REQUIRED libsystemd>=236) | ||
|
||
#------------------------------- | ||
# SOURCE FILES CONFIGURATION | ||
#------------------------------- | ||
|
||
set(SDBUSCPP_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src) | ||
set(SDBUSCPP_INCLUDE_SUBDIR sdbus-c++) | ||
set(SDBUSCPP_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include/${SDBUSCPP_INCLUDE_SUBDIR}) | ||
|
||
set(SDBUSCPP_CPP_SRCS | ||
${SDBUSCPP_SOURCE_DIR}/Connection.cpp | ||
${SDBUSCPP_SOURCE_DIR}/ConvenienceClasses.cpp | ||
${SDBUSCPP_SOURCE_DIR}/Error.cpp | ||
${SDBUSCPP_SOURCE_DIR}/Message.cpp | ||
${SDBUSCPP_SOURCE_DIR}/MethodResult.cpp | ||
${SDBUSCPP_SOURCE_DIR}/Object.cpp | ||
${SDBUSCPP_SOURCE_DIR}/ObjectProxy.cpp | ||
${SDBUSCPP_SOURCE_DIR}/Types.cpp | ||
${SDBUSCPP_SOURCE_DIR}/VTableUtils.c) | ||
|
||
set(SDBUSCPP_HDR_SRCS | ||
${SDBUSCPP_SOURCE_DIR}/Connection.h | ||
${SDBUSCPP_SOURCE_DIR}/IConnection.h | ||
${SDBUSCPP_SOURCE_DIR}/MessageUtils.h | ||
${SDBUSCPP_SOURCE_DIR}/Object.h | ||
${SDBUSCPP_SOURCE_DIR}/ObjectProxy.h | ||
${SDBUSCPP_SOURCE_DIR}/ScopeGuard.h | ||
${SDBUSCPP_SOURCE_DIR}/VTableUtils.h) | ||
|
||
set(SDBUSCPP_PUBLIC_HDRS | ||
${SDBUSCPP_INCLUDE_DIR}/ConvenienceClasses.h | ||
${SDBUSCPP_INCLUDE_DIR}/ConvenienceClasses.inl | ||
${SDBUSCPP_INCLUDE_DIR}/Error.h | ||
${SDBUSCPP_INCLUDE_DIR}/IConnection.h | ||
${SDBUSCPP_INCLUDE_DIR}/Interfaces.h | ||
${SDBUSCPP_INCLUDE_DIR}/Introspection.h | ||
${SDBUSCPP_INCLUDE_DIR}/IObject.h | ||
${SDBUSCPP_INCLUDE_DIR}/IObjectProxy.h | ||
${SDBUSCPP_INCLUDE_DIR}/Message.h | ||
${SDBUSCPP_INCLUDE_DIR}/MethodResult.h | ||
${SDBUSCPP_INCLUDE_DIR}/sdbus-c++.h | ||
${SDBUSCPP_INCLUDE_DIR}/Types.h | ||
${SDBUSCPP_INCLUDE_DIR}/TypeTraits.h) | ||
|
||
set(SDBUSCPP_SRCS ${SDBUSCPP_CPP_SRCS} ${SDBUSCPP_HDR_SRCS} ${SDBUSCPP_PUBLIC_HDRS}) | ||
|
||
#------------------------------- | ||
# GENERAL COMPILER CONFIGURATION | ||
#------------------------------- | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
add_compile_options(-W -Wextra -Wall -Werror -pedantic) | ||
include_directories("${CMAKE_SOURCE_DIR}/include") | ||
include_directories("${CMAKE_SOURCE_DIR}/src") | ||
|
||
#---------------------------------- | ||
# LIBRARY BUILD INFORMATION | ||
#---------------------------------- | ||
|
||
set(SDBUSCPP_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") | ||
set(SDBUSCPP_VERSION "${PROJECT_VERSION}") | ||
|
||
# We are building in two steps: first objects, then link them into a library, | ||
# and that's because we need object files since unit tests link against them. | ||
add_library(sdbuscppobjects OBJECT ${SDBUSCPP_SRCS}) | ||
target_include_directories(sdbuscppobjects PUBLIC ${SYSTEMD_INCLUDE_DIRS}) | ||
target_compile_definitions(sdbuscppobjects PRIVATE BUILDLIB=1) | ||
set_target_properties(sdbuscppobjects PROPERTIES POSITION_INDEPENDENT_CODE ON) | ||
|
||
add_library(sdbus-c++ SHARED $<TARGET_OBJECTS:sdbuscppobjects>) | ||
set_target_properties(sdbus-c++ | ||
PROPERTIES | ||
PUBLIC_HEADER "${SDBUSCPP_PUBLIC_HDRS}" | ||
VERSION "${SDBUSCPP_VERSION}" | ||
SOVERSION "${SDBUSCPP_VERSION_MAJOR}" | ||
OUTPUT_NAME "sdbus-c++") | ||
target_link_libraries(sdbus-c++ ${SYSTEMD_LIBRARIES}) | ||
|
||
#---------------------------------- | ||
# INSTALLATION | ||
#---------------------------------- | ||
|
||
install(TARGETS sdbus-c++ | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT static_libraries | ||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${SDBUSCPP_INCLUDE_SUBDIR} COMPONENT dev) | ||
|
||
#---------------------------------- | ||
# TESTS | ||
#---------------------------------- | ||
|
||
option(ENABLE_TESTS "Build and install tests (default ON)" ON) | ||
|
||
if(ENABLE_TESTS) | ||
enable_testing() | ||
add_subdirectory("${CMAKE_SOURCE_DIR}/test") | ||
endif() | ||
|
||
#---------------------------------- | ||
# UTILS | ||
#---------------------------------- | ||
|
||
option(BUILD_CODE_GEN "Build and install interface stub code generator (default OFF)" OFF) | ||
|
||
if(BUILD_CODE_GEN) | ||
add_subdirectory("${CMAKE_SOURCE_DIR}/stub-generator") | ||
endif() | ||
|
||
#---------------------------------- | ||
# DOCUMENTATION | ||
#---------------------------------- | ||
|
||
# TODO Build doxygen | ||
|
||
#---------------------------------- | ||
# CMAKE CONFIG & PACKAGE CONFIG | ||
#---------------------------------- | ||
|
||
set(SDBUSCPP_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/sdbus-c++) | ||
|
||
configure_file(sdbus-c++-config.cmake.in sdbus-c++-config.cmake @ONLY) | ||
install(FILES ${CMAKE_BINARY_DIR}/sdbus-c++-config.cmake DESTINATION ${SDBUSCPP_CONFIG_INSTALL_DIR} COMPONENT dev) | ||
|
||
configure_file(sdbus-c++-config-version.cmake.in sdbus-c++-config-version.cmake @ONLY) | ||
install(FILES ${CMAKE_BINARY_DIR}/sdbus-c++-config-version.cmake DESTINATION ${SDBUSCPP_CONFIG_INSTALL_DIR} COMPONENT dev) | ||
|
||
configure_file(sdbus-c++.pc.in sdbus-c++.pc @ONLY) | ||
install(FILES ${CMAKE_BINARY_DIR}/sdbus-c++.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT dev) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
set(PACKAGE_VERSION "@SDBUSCPP_VERSION@") | ||
|
||
# Check whether the requested PACKAGE_FIND_VERSION is compatible | ||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") | ||
set(PACKAGE_VERSION_COMPATIBLE FALSE) | ||
else() | ||
set(PACKAGE_VERSION_COMPATIBLE TRUE) | ||
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") | ||
set(PACKAGE_VERSION_EXACT TRUE) | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Config file for the sdbus-c++ package. | ||
# | ||
# It defines the following variables: | ||
# SDBUSCPP_VERSION - version of sdbus-c++ | ||
# SDBUSCPP_FOUND - set to true | ||
# SDBUSCPP_INCLUDE_DIRS - include directories for sdbus-c++ | ||
# SDBUSCPP_LIBRARY_DIR - library directories for sdbus-c++ | ||
# SDBUSCPP_LIBRARIES - libraries to link against | ||
|
||
set(SDBUSCPP_VERSION "@SDBUSCPP_VERSION@") | ||
set(SDBUSCPP_FOUND "TRUE") | ||
set(SDBUSCPP_INCLUDE_DIRS "@CMAKE_INSTALL_FULL_INCLUDEDIR@") | ||
set(SDBUSCPP_LIBRARY_DIR "@CMAKE_INSTALL_FULL_LIBDIR@") | ||
set(SDBUSCPP_LIBRARIES sdbus-c++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
prefix=@prefix@ | ||
exec_prefix=@exec_prefix@ | ||
libdir=@libdir@ | ||
includedir=@includedir@ | ||
prefix=@CMAKE_INSTALL_PREFIX@ | ||
exec_prefix=@CMAKE_INSTALL_PREFIX@ | ||
libdir=@CMAKE_INSTALL_FULL_LIBDIR@ | ||
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ | ||
|
||
Name: @PACKAGE@ | ||
Description: C++ bindings library for sd-bus | ||
Name: @PROJECT_NAME@ | ||
Description: C++ library on top of sd-bus, a systemd D-Bus library | ||
Requires: libsystemd | ||
Version: @VERSION@ | ||
Libs: -L${libdir} -lsdbus-c++ | ||
Version: @SDBUSCPP_VERSION@ | ||
Libs: -L${libdir} -l@PROJECT_NAME@ | ||
Cflags: -I${includedir} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.