diff --git a/CMakeLists.txt b/CMakeLists.txt index 30c40ee..8b3d190 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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()