cmake_minimum_required(VERSION 3.25) project(argparser) set(CMAKE_CXX_STANDARD 23) find_program(BASH bash) add_custom_target(combined-header COMMAND bash build.sh BYPRODUCTS "${CMAKE_SOURCE_DIR}/dist/include/argparser/argparser.h" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" SOURCES src/_include_order.h src/argument.h src/basic-type.h src/builtin_parser.h src/defs.h src/distinct-types.h src/errors.h src/list-type.h src/option.h src/optional-arg.h src/parse-result.h src/parser.h src/parser_func.h src/repeat-arg.h src/repeat-flag.h src/repeat-opt.h src/single-arg.h src/single-flag.h src/single-opt.h src/tuple-iteration.h src/tuple-type.h src/type.h src/union-type.h ) add_library(argparser INTERFACE) target_include_directories(argparser INTERFACE dist/include) add_dependencies(argparser combined-header) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # TODO: everything below this should only be for running cmake on this project, and not when it's included from somewhere else include(FetchContent) FETCHCONTENT_DECLARE( gtest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG bc860af08783b8113005ca7697da5f5d49a8056f ) enable_testing() FETCHCONTENT_MAKEAVAILABLE(gtest) include(GoogleTest) add_executable(ArgparserTest tests/parser.cpp tests/types.cpp ) target_link_libraries(ArgparserTest GTest::gtest_main) target_link_libraries(ArgparserTest argparser) gtest_discover_tests(ArgparserTest) target_compile_options(ArgparserTest PRIVATE -Wall -Wextra -Wpedantic -Werror)