Skip to content

Commit

Permalink
Merge pull request #26 from kossebau/installmakeconfig
Browse files Browse the repository at this point in the history
Install CMake config files
  • Loading branch information
antony-jr authored Aug 27, 2019
2 parents 1b7d662 + cba6050 commit 256b20d
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 11 deletions.
44 changes: 35 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")

find_package(Qt5Core)
find_package(Qt5Network)
set(MIN_QT_VERSION "5.6.0")

find_package(Qt5Core ${MIN_QT_VERSION})
find_package(Qt5Network ${MIN_QT_VERSION})

if(NOT NO_GUI)
find_package(Qt5Widgets)
find_package(Qt5Widgets ${MIN_QT_VERSION})
endif()

# cmake macros used
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

# Include Directories.
include_directories(.)
include_directories(include)
Expand Down Expand Up @@ -79,7 +85,8 @@ endif()
add_library(AppImageUpdaterBridge ${source})
target_compile_definitions(AppImageUpdaterBridge PUBLIC LOGGING_DISABLED=LG)
target_link_libraries(AppImageUpdaterBridge PUBLIC Qt5::Core Qt5::Network)
target_include_directories(AppImageUpdaterBridge PUBLIC . include)
target_include_directories(AppImageUpdaterBridge INTERFACE "$<BUILD_INTERFACE:. include>")
target_include_directories(AppImageUpdaterBridge INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/AppImageUpdaterBridge>" )

if(NOT NO_GUI)
target_link_libraries(AppImageUpdaterBridge PUBLIC Qt5::Widgets)
Expand All @@ -95,13 +102,32 @@ configure_file(

install(FILES
${CMAKE_BINARY_DIR}/AppImageUpdaterBridge.pc
DESTINATION "lib/pkgconfig")
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")

install(FILES
${CMAKE_BINARY_DIR}/libAppImageUpdaterBridge.a
DESTINATION "lib/")
install(TARGETS
AppImageUpdaterBridge
EXPORT AppImageUpdaterBridgeTargets
DESTINATION "${CMAKE_INSTALL_LIBDIR}")

install(FILES
${toinstall}
DESTINATION "include/AppImageUpdaterBridge/")
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/AppImageUpdaterBridge")

# Add CMake config
set(CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/AppImageUpdaterBridge")
if(NOT NO_GUI)
set(PACKAGE_FIND_DEPENDENCY_QTWIDGETS "find_dependency(Qt5Widgets ${MIN_QT_VERSION})")
endif()
configure_package_config_file(
"${CMAKE_SOURCE_DIR}/other/cmake/AppImageUpdaterBridgeConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/AppImageUpdaterBridgeConfig.cmake"
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/AppImageUpdaterBridgeConfig.cmake"
DESTINATION "${CMAKECONFIG_INSTALL_DIR}")

install(EXPORT AppImageUpdaterBridgeTargets
FILE AppImageUpdaterBridgeTargets.cmake
DESTINATION "${CMAKECONFIG_INSTALL_DIR}")
12 changes: 12 additions & 0 deletions examples/ProxyUpdate/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.2)

project(ProxyUpdate)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

# find installed library
find_package(AppImageUpdaterBridge)

add_executable(ProxyUpdate main.cc)

target_link_libraries(ProxyUpdate PRIVATE AppImageUpdaterBridge)
12 changes: 12 additions & 0 deletions examples/SimpleUpdate/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.2)

project(SimpleUpdate)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

# find installed library
find_package(AppImageUpdaterBridge)

add_executable(SimpleUpdate main.cc TextProgressBar.cc)

target_link_libraries(SimpleUpdate PRIVATE AppImageUpdaterBridge)
12 changes: 12 additions & 0 deletions examples/SimpleUpdateGUI/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.2)

project(SimpleUpdateGUI)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

# find installed library
find_package(AppImageUpdaterBridge)

add_executable(SimpleUpdateGUI main.cc)

target_link_libraries(SimpleUpdateGUI PRIVATE AppImageUpdaterBridge)
8 changes: 8 additions & 0 deletions other/cmake/AppImageUpdaterBridgeConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)
find_dependency(Qt5Core @MIN_QT_VERSION@)
find_dependency(Qt5Network @MIN_QT_VERSION@)
@PACKAGE_FIND_DEPENDENCY_QTWIDGETS@

include("${CMAKE_CURRENT_LIST_DIR}/AppImageUpdaterBridgeTargets.cmake")
4 changes: 2 additions & 2 deletions other/pkgconfig/AppImageUpdaterBridge.pc.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@
libdir=${prefix}/lib
includedir=${prefix}/include/AppImageUpdaterBridge
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/AppImageUpdaterBridge

Name: AppImageUpdaterBridge
Description: A Qt5 library for delta updating the AppImage format
Expand Down

0 comments on commit 256b20d

Please sign in to comment.