Skip to content

Commit

Permalink
fix(build): simplify runs from master projects, require C++11 minimal…
Browse files Browse the repository at this point in the history
…ly if possible
  • Loading branch information
henryiii committed Oct 15, 2021
1 parent 229844f commit fd812a1
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,29 @@ project(
# Print the version number of CMake if this is the main project
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
message(STATUS "CMake ${CMAKE_VERSION}")

find_package(Doxygen)

if(CMAKE_VERSION VERSION_LESS 3.10)
message(STATUS "CMake 3.10+ adds Doxygen support. Update CMake to build documentation")
elseif(NOT Doxygen_FOUND)
message(STATUS "Doxygen not found, building docs has been disabled")
endif()

include(CTest)
else()
if(NOT DEFINED BUILD_TESTING)
set(BUILD_TESTING OFF)
endif()
endif()

include(CMakeDependentOption)
include(GNUInstallDirs)
include(CTest)

if(NOT CMAKE_VERSION VERSION_LESS 3.11)
include(FetchContent)
endif()

find_package(Doxygen)

list(APPEND force-libcxx "CMAKE_CXX_COMPILER_ID STREQUAL \"Clang\"")
list(APPEND force-libcxx "CMAKE_SYSTEM_NAME STREQUAL \"Linux\"")
list(APPEND force-libcxx "CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME")
Expand Down Expand Up @@ -118,12 +129,6 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif()

if(CMAKE_VERSION VERSION_LESS 3.10)
message(STATUS "CMake 3.10+ adds Doxygen support. Update CMake to build documentation")
elseif(NOT Doxygen_FOUND)
message(STATUS "Doxygen not found, building docs has been disabled")
endif()

# Special target that adds warnings. Is not exported.
add_library(CLI11_warnings INTERFACE)

Expand Down Expand Up @@ -154,6 +159,22 @@ add_library(CLI11::CLI11 ALIAS CLI11) # for add_subdirectory calls
target_include_directories(CLI11 INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

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()

# To see in IDE, headers must be listed for target
set(header-patterns "${PROJECT_SOURCE_DIR}/include/CLI/*")
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND NOT CMAKE_VERSION VERSION_LESS 3.12)
Expand Down Expand Up @@ -254,6 +275,7 @@ if(CLI11_SINGLE_FILE)
endif()

if(CLI11_BUILD_TESTS)
include(CTest)
add_subdirectory(tests)
endif()

Expand Down

0 comments on commit fd812a1

Please sign in to comment.