mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-01 05:03:52 +00:00
* Adding first try at coverage * Fix for CMakeLists * Fix for wrong shell * Fixes to Coverage * Fix for missing coverage * Adding badge * Using repo token * Adding test files to coverage * Fix typo * Adding codecov * Fix for code coverage * Fix single file tests under CodeCov * Seperating coverage steps * Fix testrunner to be ctest * Fix constant rebuilding of doxygen * Adding coverage, tested locally * Adding compiler version to gcov * Fixing code coverage gcov download and use * Adding Coverage build type with some fixes * Better way of using gcc * Adding coverage badge * Removing tests from calcs
68 lines
2.1 KiB
CMake
68 lines
2.1 KiB
CMake
cmake_minimum_required(VERSION 3.4 FATAL_ERROR)
|
|
|
|
project(CLI11 CXX)
|
|
|
|
SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
|
|
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
|
set(CUR_PROJ ON)
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
else()
|
|
set(CUR_PROJ OFF)
|
|
endif()
|
|
|
|
# Be moderately paranoid with flags
|
|
if(CMAKE_COMPILER_IS_GNUCC)
|
|
add_definitions("-Wall -Wextra -pedantic")
|
|
endif()
|
|
if(MSVC)
|
|
add_definitions("/W4")
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
|
endif()
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL Coverage)
|
|
include(CodeCoverage)
|
|
setup_target_for_coverage(CLI_coverage ctest coverage)
|
|
endif()
|
|
|
|
add_library(CLI INTERFACE)
|
|
target_include_directories(CLI INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
|
|
|
file(GLOB CLI_headers "${CMAKE_CURRENT_SOURCE_DIR}/include/CLI/*")
|
|
# To see in IDE, must be listed for target
|
|
|
|
# Single file test
|
|
option(CLI_SINGLE_FILE "Generate a single header file (and test)" ${CUR_PROJ})
|
|
if(CLI_SINGLE_FILE)
|
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include")
|
|
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/include/CLI11.hpp"
|
|
COMMAND python "${CMAKE_CURRENT_SOURCE_DIR}/scripts/MakeSingleHeader.py" "${CMAKE_CURRENT_BINARY_DIR}/include/CLI11.hpp"
|
|
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/CLI/CLI.hpp" ${CLI_headers}
|
|
)
|
|
add_custom_target(generate_cli_single_file ALL
|
|
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/include/CLI11.hpp")
|
|
|
|
add_library(CLI_SINGLE INTERFACE)
|
|
target_link_libraries(CLI_SINGLE INTERFACE CLI)
|
|
add_dependencies(CLI_SINGLE generate_cli_single_file)
|
|
target_compile_definitions(CLI_SINGLE INTERFACE -DCLI_SINGLE_FILE)
|
|
target_include_directories(CLI_SINGLE INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/include/")
|
|
endif()
|
|
|
|
option(CLI_SINGLE_FILE_TESTS "Duplicate all the tests for a single file build" OFF)
|
|
|
|
option(CLI_TESTING "Build the tests and add them" ${CUR_PROJ})
|
|
if(CLI_TESTING)
|
|
enable_testing()
|
|
add_subdirectory(tests)
|
|
endif()
|
|
|
|
option(CLI_EXAMPLES "Build the examples" ${CUR_PROJ})
|
|
if(CLI_EXAMPLES)
|
|
add_subdirectory(examples)
|
|
endif()
|
|
|