1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-05-03 05:53:52 +00:00
CLI11/src/CMakeLists.txt
Henry Schreiner bd6462f62f
chore: move single file to own folder (#1030)
See https://github.com/CLIUtils/CLI11/pull/1025.

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-05-01 12:02:16 -04:00

65 lines
2.1 KiB
CMake

if(CLI11_PRECOMPILED)
# Create static lib
file(GLOB CLI11_precompile_sources "${PROJECT_SOURCE_DIR}/src/*.cpp")
add_library(CLI11 STATIC ${CLI11_headers} ${CLI11_library_headers} ${CLI11_impl_headers}
${CLI11_precompile_sources})
target_compile_definitions(CLI11 PUBLIC -DCLI11_COMPILE)
set(PUBLIC_OR_INTERFACE PUBLIC)
else()
add_library(CLI11 INTERFACE)
if(CMAKE_VERSION VERSION_GREATER 3.19)
# This is only useful for visual studio and other IDE builds
target_sources(CLI11 PRIVATE ${CLI11_headers} ${CLI11_library_headers} ${CLI11_impl_headers})
endif()
set(PUBLIC_OR_INTERFACE INTERFACE)
endif()
# Allow IDE's to group targets into folders
add_library(CLI11::CLI11 ALIAS CLI11) # for add_subdirectory calls
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(SYSTEM_INCL "")
else()
# If this project is included from somewhere else, we mark our headers as system headers to avoid
# the compiler emitting any warnings about them
set(SYSTEM_INCL "SYSTEM")
endif()
# Duplicated because CMake adds the current source dir if you don't.
target_include_directories(
CLI11 ${SYSTEM_INCL} ${PUBLIC_OR_INTERFACE} $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
if(CMAKE_CXX_STANDARD LESS 14)
if(CMAKE_VERSION VERSION_LESS 3.8)
# This might not be a complete list
target_compile_features(
CLI11
INTERFACE cxx_lambdas
cxx_nullptr
cxx_override
cxx_range_for
cxx_right_angle_brackets
cxx_strong_enums
cxx_constexpr
cxx_auto_type)
else()
target_compile_features(CLI11 INTERFACE cxx_std_11)
endif()
endif()
if(CLI11_INSTALL)
# Make an export target
install(TARGETS CLI11 EXPORT CLI11Targets)
if(NOT CLI11_SINGLE_FILE)
install(FILES ${CLI11_headers} ${CLI11_library_headers}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/CLI")
if(NOT CLI11_PRECOMPILED)
install(FILES ${CLI11_impl_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/CLI/impl")
endif()
endif()
endif()