Skip to content

Commit

Permalink
Fixing use as a subproject for installing #156
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Sep 3, 2018
1 parent 9680fec commit bd4eca9
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,16 @@ target_include_directories(CLI11 INTERFACE
# Make add_subdirectory work like find_package
add_library(CLI11::CLI11 ALIAS CLI11)

option(CLI11_INSTALL "Install the CLI11 folder to include during install process" ${CUR_PROJ})

# This folder should be installed
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/CLI DESTINATION include)
if(CLI11_INSTALL)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/CLI DESTINATION include)

# Make an export target
install(TARGETS CLI11
EXPORT CLI11Targets)
endif()

# Use find_package on the installed package
# Since we have no custom code, we can directly write this
Expand All @@ -95,27 +103,26 @@ write_basic_package_version_file(
COMPATIBILITY AnyNewerVersion
)

# Make version available in the install
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/CLI11ConfigVersion.cmake"
DESTINATION lib/cmake/CLI11)

# Make an export target
install(TARGETS CLI11
EXPORT CLI11Targets)

# Install the export target as a file
install(EXPORT CLI11Targets
FILE CLI11Config.cmake
NAMESPACE CLI11::
DESTINATION lib/cmake/CLI11)

# Use find_package on the installed package
export(TARGETS CLI11
NAMESPACE CLI11::
FILE CLI11Targets.cmake)

# Register in the user cmake package registry
export(PACKAGE CLI11)
# These installs only make sense for a local project
if(CUR_PROJ)
# Make version available in the install
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/CLI11ConfigVersion.cmake"
DESTINATION lib/cmake/CLI11)

# Install the export target as a file
install(EXPORT CLI11Targets
FILE CLI11Config.cmake
NAMESPACE CLI11::
DESTINATION lib/cmake/CLI11)

# Use find_package on the installed package
export(TARGETS CLI11
NAMESPACE CLI11::
FILE CLI11Targets.cmake)

# Register in the user cmake package registry
export(PACKAGE CLI11)
endif()

option(CLI11_SINGLE_FILE "Generate a single header file" OFF)

Expand Down

0 comments on commit bd4eca9

Please sign in to comment.