Skip to content

Commit 055d242

Browse files
committed
Improve CMake rules
* Disable building examples by default. * Use CMAKE_CURRENT_SOURCE_DIR instead of CMAKE_SOURCE_DIR. * Add an option to disable install rules.
1 parent 0352904 commit 055d242

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

CMakeLists.txt

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.1)
22

33
project(qhotkey VERSION 1.2.2 LANGUAGES CXX)
44

5-
option(QHOTKEY_EXAMPLES "Build examples" ON)
5+
option(QHOTKEY_EXAMPLES "Build examples" OFF)
6+
option(QHOTKEY_INSTALL "Enable install rule" ON)
67

78
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
89

@@ -53,18 +54,20 @@ if(QHOTKEY_EXAMPLES)
5354
add_subdirectory(HotkeyTest)
5455
endif()
5556

56-
include(GNUInstallDirs)
57-
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/QHotkey)
58-
59-
install(
60-
TARGETS qhotkey EXPORT QHotkeyConfig
61-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
62-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
63-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
64-
install(FILES
65-
${CMAKE_SOURCE_DIR}/QHotkey/qhotkey.h
66-
${CMAKE_SOURCE_DIR}/QHotkey/QHotkey
67-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/)
68-
install(EXPORT QHotkeyConfig DESTINATION ${INSTALL_CONFIGDIR})
69-
70-
export(TARGETS qhotkey FILE QHotkeyConfig.cmake)
57+
if(QHOTKEY_INSTALL)
58+
include(GNUInstallDirs)
59+
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/QHotkey)
60+
61+
install(
62+
TARGETS qhotkey EXPORT QHotkeyConfig
63+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
64+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
65+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
66+
install(FILES
67+
${CMAKE_CURRENT_SOURCE_DIR}/QHotkey/qhotkey.h
68+
${CMAKE_CURRENT_SOURCE_DIR}/QHotkey/QHotkey
69+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/)
70+
install(EXPORT QHotkeyConfig DESTINATION ${INSTALL_CONFIGDIR})
71+
72+
export(TARGETS qhotkey FILE QHotkeyConfig.cmake)
73+
endif()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy