Skip to content

Commit

Permalink
🔨 Introduce QOLM_INSTALL to make installation optional
Browse files Browse the repository at this point in the history
This option is enabled if QOlm is main project,
and disabled if QOlm isn't.
It is user responsibility to enable it when fetching QOlm if he needs to install it
  • Loading branch information
OlivierLDff committed Jul 15, 2021
1 parent 1874754 commit 9323b24
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ set(QOLM_TESTS_PREFIX ${QOLM_PROJECT} CACHE STRING "Prefix for all QOlm tests")
set(QOLM_ENABLE_EXAMPLES OFF CACHE BOOL "Create or not a target for examples")
set(QOLM_EXAMPLES_PREFIX ${QOLM_PROJECT} CACHE STRING "Prefix for all QOlm tests")

set(QOLM_INSTALL ${QOLM_MAIN_PROJECT} CACHE BOOL "Generate the install target")

# ───── VERSION ─────

set(QOLM_VERSION_MAJOR 3)
Expand Down Expand Up @@ -72,6 +74,7 @@ message(STATUS "QOLM_VERSION : " ${QOLM_VERSION})
message(STATUS "QOLM_VERSION_TAG : " ${QOLM_VERSION_TAG})
message(STATUS "QOLM_FOLDER_PREFIX : " ${QOLM_FOLDER_PREFIX})
message(STATUS "QOLM_BUILD_SHARED : " ${QOLM_BUILD_SHARED})
message(STATUS "QOLM_INSTALL : " ${QOLM_INSTALL})

# Tests
message(STATUS "QOLM_ENABLE_TESTS : " ${QOLM_ENABLE_TESTS})
Expand Down Expand Up @@ -146,23 +149,25 @@ if(QOLM_MAIN_PROJECT)
include(cmake/PrintConfiguration.cmake)
endif()

include(GNUInstallDirs)
install(TARGETS ${QOLM_TARGET}
EXPORT ${QOLM_TARGET}Targets
PUBLIC_HEADER DESTINATION include/QOlm
)
if(QOLM_INSTALL)
include(GNUInstallDirs)
install(TARGETS ${QOLM_TARGET}
EXPORT ${QOLM_TARGET}Targets
PUBLIC_HEADER DESTINATION include/QOlm
)

export(EXPORT ${QOLM_TARGET}Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${QATERIAL_TARGET}/${QOLM_TARGET}Targets.cmake"
NAMESPACE ${QOLM_TARGET}::
)
export(EXPORT ${QOLM_TARGET}Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${QATERIAL_TARGET}/${QOLM_TARGET}Targets.cmake"
NAMESPACE ${QOLM_TARGET}::
)

set(ConfigPackageLocation lib/cmake/${QOLM_TARGET})
install(EXPORT ${QOLM_TARGET}Targets
FILE
${QOLM_TARGET}Targets.cmake
NAMESPACE
${QOLM_TARGET}::
DESTINATION
${ConfigPackageLocation}
)
set(ConfigPackageLocation lib/cmake/${QOLM_TARGET})
install(EXPORT ${QOLM_TARGET}Targets
FILE
${QOLM_TARGET}Targets.cmake
NAMESPACE
${QOLM_TARGET}::
DESTINATION
${ConfigPackageLocation}
)
endif()

0 comments on commit 9323b24

Please sign in to comment.