Commit f16f3c97f04562de0a442459fb6263ee4c17f4bc

Authored by Henry Fredrick Schreiner
Committed by Henry Schreiner
1 parent b53eb516

Fixing use as a subproject for installing #156

Showing 1 changed file with 29 additions and 22 deletions
CMakeLists.txt
... ... @@ -79,8 +79,16 @@ target_include_directories(CLI11 INTERFACE
79 79 # Make add_subdirectory work like find_package
80 80 add_library(CLI11::CLI11 ALIAS CLI11)
81 81  
  82 +option(CLI11_INSTALL "Install the CLI11 folder to include during install process" ${CUR_PROJ})
  83 +
82 84 # This folder should be installed
83   -install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/CLI DESTINATION include)
  85 +if(CLI11_INSTALL)
  86 + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/CLI DESTINATION include)
  87 +
  88 + # Make an export target
  89 + install(TARGETS CLI11
  90 + EXPORT CLI11Targets)
  91 +endif()
84 92  
85 93 # Use find_package on the installed package
86 94 # Since we have no custom code, we can directly write this
... ... @@ -95,27 +103,26 @@ write_basic_package_version_file(
95 103 COMPATIBILITY AnyNewerVersion
96 104 )
97 105  
98   -# Make version available in the install
99   -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/CLI11ConfigVersion.cmake"
100   - DESTINATION lib/cmake/CLI11)
101   -
102   -# Make an export target
103   -install(TARGETS CLI11
104   - EXPORT CLI11Targets)
105   -
106   -# Install the export target as a file
107   -install(EXPORT CLI11Targets
108   - FILE CLI11Config.cmake
109   - NAMESPACE CLI11::
110   - DESTINATION lib/cmake/CLI11)
111   -
112   -# Use find_package on the installed package
113   -export(TARGETS CLI11
114   - NAMESPACE CLI11::
115   - FILE CLI11Targets.cmake)
116   -
117   -# Register in the user cmake package registry
118   -export(PACKAGE CLI11)
  106 +# These installs only make sense for a local project
  107 +if(CUR_PROJ)
  108 + # Make version available in the install
  109 + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/CLI11ConfigVersion.cmake"
  110 + DESTINATION lib/cmake/CLI11)
  111 +
  112 + # Install the export target as a file
  113 + install(EXPORT CLI11Targets
  114 + FILE CLI11Config.cmake
  115 + NAMESPACE CLI11::
  116 + DESTINATION lib/cmake/CLI11)
  117 +
  118 + # Use find_package on the installed package
  119 + export(TARGETS CLI11
  120 + NAMESPACE CLI11::
  121 + FILE CLI11Targets.cmake)
  122 +
  123 + # Register in the user cmake package registry
  124 + export(PACKAGE CLI11)
  125 +endif()
119 126  
120 127 option(CLI11_SINGLE_FILE "Generate a single header file" OFF)
121 128  
... ...