Skip to content

Commit

Permalink
Merge pull request #38 from Shatur95/improve-cmake-rule
Browse files Browse the repository at this point in the history
Improve CMake rules
  • Loading branch information
Skycoder42 committed Jun 7, 2020
2 parents 0352904 + 055d242 commit c373d83
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.1)

project(qhotkey VERSION 1.2.2 LANGUAGES CXX)

option(QHOTKEY_EXAMPLES "Build examples" ON)
option(QHOTKEY_EXAMPLES "Build examples" OFF)
option(QHOTKEY_INSTALL "Enable install rule" ON)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

Expand Down Expand Up @@ -53,18 +54,20 @@ if(QHOTKEY_EXAMPLES)
add_subdirectory(HotkeyTest)
endif()

include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/QHotkey)

install(
TARGETS qhotkey EXPORT QHotkeyConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES
${CMAKE_SOURCE_DIR}/QHotkey/qhotkey.h
${CMAKE_SOURCE_DIR}/QHotkey/QHotkey
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/)
install(EXPORT QHotkeyConfig DESTINATION ${INSTALL_CONFIGDIR})

export(TARGETS qhotkey FILE QHotkeyConfig.cmake)
if(QHOTKEY_INSTALL)
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/QHotkey)

install(
TARGETS qhotkey EXPORT QHotkeyConfig
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/QHotkey/qhotkey.h
${CMAKE_CURRENT_SOURCE_DIR}/QHotkey/QHotkey
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/)
install(EXPORT QHotkeyConfig DESTINATION ${INSTALL_CONFIGDIR})

export(TARGETS qhotkey FILE QHotkeyConfig.cmake)
endif()

0 comments on commit c373d83

Please sign in to comment.