@@ -27,6 +27,8 @@ project(
2727 LANGUAGES CXX
2828 VERSION ${VERSION_STRING} )
2929
30+ list (APPEND CMAKE_MODULE_PATH "${CLI11_SOURCE_DIR} /cmake" )
31+
3032# Print the version number of CMake if this is the main project
3133if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME )
3234 message (STATUS "CMake ${CMAKE_VERSION} " )
@@ -128,89 +130,9 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
128130 set_property (GLOBAL PROPERTY USE_FOLDERS ON )
129131endif ()
130132
131- # Special target that adds warnings. Is not exported.
132- add_library (CLI11_warnings INTERFACE )
133-
134- set (unix -warnings -Wall -Wextra -pedantic -Wshadow -Wsign-conversion -Wswitch-enum)
135-
136- # Clang warnings
137- # -Wfloat-equal could be added with Catch::literals and _a usage
138- if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
139- list (
140- APPEND
141- unix -warnings
142- -Wcast-align
143- -Wimplicit-atomic-properties
144- -Wmissing-declarations
145- -Woverlength-strings
146- -Wshadow
147- -Wstrict-selector-match
148- -Wundeclared-selector)
149- # -Wunreachable-code Doesn't work on Clang 3.4
150- endif ()
151-
152- # Buggy in GCC 4.8
153- if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
154- list (APPEND unix -warnings -Weffc++)
155- endif ()
156-
157- target_compile_options (
158- CLI11_warnings
159- INTERFACE $<$<BOOL :${CLI11_FORCE_LIBCXX} >:-stdlib=libc++>
160- $<$<CXX_COMPILER_ID:MSVC >:/W4
161- $<$<BOOL :${CLI11_WARNINGS_AS_ERRORS} >:/WX>>
162- $<$<NOT :$<CXX_COMPILER_ID:MSVC >>:${unix -warnings}
163- $<$<BOOL :${CLI11_WARNINGS_AS_ERRORS} >:-Werror>>)
164-
165- if (NOT CMAKE_VERSION VERSION_LESS 3.13)
166- target_link_options (CLI11_warnings INTERFACE $<$<BOOL :${CLI11_FORCE_LIBCXX} >:-stdlib=libc++>)
167- endif ()
168-
169- # To see in IDE, headers must be listed for target
170- set (MAYBE_CONFIGURE_DEPENDS "" )
171- if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND NOT CMAKE_VERSION VERSION_LESS 3.12)
172- list (INSERT MAYBE_CONFIGURE_DEPENDS 0 CONFIGURE_DEPENDS)
173- endif ()
174-
175- file (GLOB CLI11_headers ${MAYBE_CONFIGURE_DEPENDS} "${PROJECT_SOURCE_DIR} /include/CLI/*.hpp" )
176- file (GLOB CLI11_impl_headers ${MAYBE_CONFIGURE_DEPENDS}
177- "${PROJECT_SOURCE_DIR} /include/CLI/impl/*.hpp" )
133+ include (CLI11Warnings)
178134
179- if (CLI11_PRECOMPILED)
180- # Create static lib
181- file (GLOB CLI11_precompile_sources "${PROJECT_SOURCE_DIR} /src/*.cpp" )
182- add_library (CLI11 STATIC ${CLI11_headers} ${CLI11_impl_headers} ${CLI11_precompile_sources} )
183- target_compile_definitions (CLI11 PUBLIC -DCLI11_COMPILE)
184-
185- set (PUBLIC_OR_INTERFACE PUBLIC )
186- else ()
187- add_library (CLI11 INTERFACE )
188- set (PUBLIC_OR_INTERFACE INTERFACE )
189- endif ()
190-
191- # Allow IDE's to group targets into folders
192- add_library (CLI11::CLI11 ALIAS CLI11) # for add_subdirectory calls
193-
194- # Duplicated because CMake adds the current source dir if you don't.
195- target_include_directories (
196- CLI11 ${PUBLIC_OR_INTERFACE} $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include >
197- $<INSTALL_INTERFACE:include >)
198-
199- if (CMAKE_VERSION VERSION_LESS 3.8)
200- # This might not be a complete list
201- target_compile_features (
202- CLI11
203- INTERFACE cxx_lambdas
204- cxx_nullptr
205- cxx_override
206- cxx_range_for
207- cxx_right_angle_brackets
208- cxx_strong_enums
209- cxx_constexpr
210- cxx_auto_type)
211- else ()
212- target_compile_features (CLI11 INTERFACE cxx_std_11)
213- endif ()
135+ add_subdirectory (src)
214136
215137# Allow tests to be run on CUDA
216138if (CLI11_CUDA_TESTS)
@@ -222,13 +144,6 @@ endif()
222144
223145# This folder should be installed
224146if (CLI11_INSTALL)
225- install (FILES ${CLI11_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR} /CLI" )
226- if (NOT CLI11_COMPILE)
227- install (FILES ${CLI11_impl_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR} /CLI/impl" )
228- endif ()
229-
230- # Make an export target
231- install (TARGETS CLI11 EXPORT CLI11Targets)
232147
233148 # Use find_package on the installed package
234149 # Since we have no custom code, we can directly write this
@@ -261,42 +176,6 @@ if(CLI11_INSTALL)
261176 export (PACKAGE CLI11)
262177endif ()
263178
264- if (CLI11_SINGLE_FILE)
265- # Single file test
266- if (CMAKE_VERSION VERSION_LESS 3.12)
267- find_package (PythonInterp REQUIRED)
268- add_executable (Python::Interpreter IMPORTED )
269- set_target_properties (Python::Interpreter PROPERTIES IMPORTED_LOCATION "${PYTHON_EXECUTABLE} "
270- VERSION "${PYTHON_VERSION_STRING} " )
271- else ()
272- find_package (
273- Python
274- COMPONENTS Interpreter
275- REQUIRED)
276- endif ()
277-
278- file (MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /include" )
279- add_custom_command (
280- OUTPUT "${CMAKE_CURRENT_BINARY_DIR} /include/CLI11.hpp"
281- COMMAND
282- Python::Interpreter "${CMAKE_CURRENT_SOURCE_DIR} /scripts/MakeSingleHeader.py"
283- ${CLI11_headers} ${CLI11_impl_headers} --main "${CMAKE_CURRENT_SOURCE_DIR} /CLI11.hpp.in"
284- --output "${CMAKE_CURRENT_BINARY_DIR} /include/CLI11.hpp" --version "${CLI11_VERSION} "
285- DEPENDS "${CMAKE_CURRENT_SOURCE_DIR} /include/CLI/CLI.hpp" ${CLI11_headers}
286- ${CLI11_impl_headers} )
287- add_custom_target (CLI11-generate-single-file ALL
288- DEPENDS "${CMAKE_CURRENT_BINARY_DIR} /include/CLI11.hpp" )
289- set_property (TARGET CLI11-generate-single-file PROPERTY FOLDER "Scripts" )
290- install (FILES "${CMAKE_CURRENT_BINARY_DIR} /include/CLI11.hpp" DESTINATION include )
291- add_library (CLI11_SINGLE INTERFACE )
292- target_link_libraries (CLI11_SINGLE INTERFACE CLI11)
293- add_dependencies (CLI11_SINGLE CLI11-generate-single-file)
294- target_compile_definitions (CLI11_SINGLE INTERFACE -DCLI11_SINGLE_FILE)
295- target_include_directories (
296- CLI11_SINGLE INTERFACE $<BUILD_INTERFACE:${PROJECT_BINARY_DIR} /include />
297- $<INSTALL_INTERFACE:include >)
298- endif ()
299-
300179if (CLI11_BUILD_TESTS)
301180 include (CTest)
302181 add_subdirectory (tests)
0 commit comments