From 82d3716897bb580ea42c1fb2cbf05485790910b9 Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Mon, 16 Aug 2021 21:23:58 +0300 Subject: [PATCH] Added support of CMake and CPack Moved `clpp` dir into `include` dir. Fixed the paths in the Doxyfile. --- .gitmodules | 11 +++ CMakeLists.txt | 82 +++++++++++++++++++ cmake/thirdParty/Boilerplate | 1 + cmake/thirdParty/DoxygenUtils | 1 + doc/Doxyfile | 8 +- .../clpp}/detail/argument_caster.hpp | 0 .../clpp}/detail/argument_holder.hpp | 0 .../clpp}/detail/checkers/all.hpp | 0 .../clpp}/detail/checkers/common_checker.hpp | 0 .../detail/checkers/incorrect_parameters.hpp | 0 .../detail/checkers/necessary_parameters.hpp | 0 .../detail/checkers/parameters_existence.hpp | 0 .../detail/checkers/parameters_redundancy.hpp | 0 .../detail/checkers/parameters_repetition.hpp | 0 .../clpp}/detail/checkers/validators.hpp | 0 .../detail/checkers/values_correction.hpp | 0 .../clpp}/detail/checkers/values_semantic.hpp | 0 {clpp => include/clpp}/detail/misc.hpp | 0 {clpp => include/clpp}/detail/parameter.hpp | 0 .../detail/parameter_parts_extractor.hpp | 0 {clpp => include/clpp}/detail/types.hpp | 0 .../detail/unnamed_parameters_handler.hpp | 0 .../clpp}/detail/user_functions_caller.hpp | 0 {clpp => include/clpp}/parser.hpp | 0 24 files changed, 99 insertions(+), 4 deletions(-) create mode 100644 .gitmodules create mode 100644 CMakeLists.txt create mode 160000 cmake/thirdParty/Boilerplate create mode 160000 cmake/thirdParty/DoxygenUtils rename {clpp => include/clpp}/detail/argument_caster.hpp (100%) rename {clpp => include/clpp}/detail/argument_holder.hpp (100%) rename {clpp => include/clpp}/detail/checkers/all.hpp (100%) rename {clpp => include/clpp}/detail/checkers/common_checker.hpp (100%) rename {clpp => include/clpp}/detail/checkers/incorrect_parameters.hpp (100%) rename {clpp => include/clpp}/detail/checkers/necessary_parameters.hpp (100%) rename {clpp => include/clpp}/detail/checkers/parameters_existence.hpp (100%) rename {clpp => include/clpp}/detail/checkers/parameters_redundancy.hpp (100%) rename {clpp => include/clpp}/detail/checkers/parameters_repetition.hpp (100%) rename {clpp => include/clpp}/detail/checkers/validators.hpp (100%) rename {clpp => include/clpp}/detail/checkers/values_correction.hpp (100%) rename {clpp => include/clpp}/detail/checkers/values_semantic.hpp (100%) rename {clpp => include/clpp}/detail/misc.hpp (100%) rename {clpp => include/clpp}/detail/parameter.hpp (100%) rename {clpp => include/clpp}/detail/parameter_parts_extractor.hpp (100%) rename {clpp => include/clpp}/detail/types.hpp (100%) rename {clpp => include/clpp}/detail/unnamed_parameters_handler.hpp (100%) rename {clpp => include/clpp}/detail/user_functions_caller.hpp (100%) rename {clpp => include/clpp}/parser.hpp (100%) diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..37a0379 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,11 @@ +[submodule "cmake/thirdParty/Boilerplate"] + path = cmake/thirdParty/Boilerplate + url = https://github.com/KOLANICH-libs/Boilerplate.cmake + branch = master + shallow = true + +[submodule "cmake/thirdParty/DoxygenUtils"] + path = cmake/thirdParty/DoxygenUtils + url = https://github.com/KOLANICH-libs/DoxygenUtils.cmake + branch = master + shallow = true diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e93714c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,82 @@ +cmake_minimum_required(VERSION 3.7.2) + +set(CMAKE_USE_RELATIVE_PATHS TRUE) +project("clpp") +set("PROJECT_DESCRIPTION" "") +set("PROJECT_HOMEPAGE_URL" "https://github.com/makerbot/clp-parser") # also https://sourceforge.net/project/clp-parser + +set(CPACK_PACKAGE_VENDOR "Denis Shevchenko") +set(CPACK_PACKAGE_VERSION_MAJOR "0") +set(CPACK_PACKAGE_VERSION_MINOR "0") +set(CPACK_PACKAGE_VERSION_PATCH "0") +set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") + +set(OUR_CMAKE_MODULES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +set(OUR_CMAKE_3PARTY_MODULES_DIR "${OUR_CMAKE_MODULES_DIR}/thirdParty") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${OUR_CMAKE_MODULES_DIR}" "${OUR_CMAKE_3PARTY_MODULES_DIR}" "${OUR_CMAKE_3PARTY_MODULES_DIR}/Boilerplate" "${OUR_CMAKE_3PARTY_MODULES_DIR}/DoxygenUtils") + + +include(Boilerplate) +include(DoxygenUtils) + +set(BOOST_COMPS "filesystem;regex") + +find_package(Boost COMPONENTS ${BOOST_COMPS} REQUIRED) + +set(BCS_LINK "") +foreach(bc ${BOOST_COMPS}) + set(BCS_LINK "${BCS_LINK};Boost::${bc}") +endforeach() + +set(Include_dir "${CMAKE_CURRENT_SOURCE_DIR}/include") +set(Examples_Dir "${CMAKE_CURRENT_SOURCE_DIR}/example") + +buildAndPackageLib("${PROJECT_NAME}" + DO_NOT_PASSTHROUGH + TYPE INTERFACE + COMPONENT "lib" + DESCRIPTION "${PROJECT_DESCRIPTION}" + PUBLIC_INCLUDES ${Include_dir} + PUBLIC_LIBS ${BCS_LINK} +) + +option(WITH_EXAMPLES "Build examples" OFF) +if(WITH_EXAMPLES) + file(GLOB_RECURSE EXAMPLES "${Examples_Dir}/*.cpp") + foreach(example ${EXAMPLES}) + get_filename_component(exampleName "${example}" NAME_WE) + add_executable("${exampleName}" "${example}") + harden("${exampleName}") + add_sanitizers("${exampleName}") + target_include_directories("${exampleName}" PRIVATE "${Include_dir}") + target_link_libraries("${exampleName}" "${PROJECT_NAME}") + endforeach() +endif() + +option(WITH_DOCS "Build docs" ON) +if(WITH_DOCS) + find_package(Doxygen REQUIRED dot) + + load_doxyfile("${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile") + set(DOXYGEN_PROJECT_BRIEF "${CPACK_PACKAGE_DESCRIPTION}") + set(DOXYGEN_USE_MDFILE_AS_MAINPAGE "${CPACK_RESOURCE_FILE_README}") + + set("DOXYGEN_GENERATE_HTML" YES) + set("DOXYGEN_GENERATE_MAN" YES) + + set(DOXYGEN_EXAMPLE_PATH "${Examples_Dir}") + set(DOXYGEN_STRIP_FROM_PATH "${Include_dir}/clpp") + set(DOXYGEN_STRIP_FROM_INC_PATH "${Include_dir}/clpp") + + + file(GLOB_RECURSE HEADERS "${Include_dir}/*.h" "${Include_dir}/*.hxx" "${Include_dir}/*.hpp") + doxygen_add_docs(docs + "${HEADERS}" + ALL + USE_STAMP_FILE + ) +endif() + +#pass_through_cpack_vars() + +include(CPack) diff --git a/cmake/thirdParty/Boilerplate b/cmake/thirdParty/Boilerplate new file mode 160000 index 0000000..e963872 --- /dev/null +++ b/cmake/thirdParty/Boilerplate @@ -0,0 +1 @@ +Subproject commit e963872ea0861df2544ac718d0dbee88be4a05e6 diff --git a/cmake/thirdParty/DoxygenUtils b/cmake/thirdParty/DoxygenUtils new file mode 160000 index 0000000..ad6b4d2 --- /dev/null +++ b/cmake/thirdParty/DoxygenUtils @@ -0,0 +1 @@ +Subproject commit ad6b4d201738fdd27b2694e3d1c56b467b3335c0 diff --git a/doc/Doxyfile b/doc/Doxyfile index 9b3295f..9de5d42 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -6,7 +6,7 @@ DOXYFILE_ENCODING = UTF-8 PROJECT_NAME = "C++ command line parameters parser" PROJECT_NUMBER = -OUTPUT_DIRECTORY = /home/denis/Profession/groundworks/cmd_line_params_parser/clp_parser/doc/ +OUTPUT_DIRECTORY = ./doc/ CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English BRIEF_MEMBER_DESC = YES @@ -25,7 +25,7 @@ ABBREVIATE_BRIEF = "The $name class" \ ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = NO -STRIP_FROM_PATH = /home/denis/ +STRIP_FROM_PATH = ./include/ STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO @@ -93,7 +93,7 @@ WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = /home/denis/Profession/groundworks/cmd_line_params_parser/clp_parser/clpp/ +INPUT = ./include/ INPUT_ENCODING = UTF-8 FILE_PATTERNS = *.c \ *.cpp \ @@ -136,7 +136,7 @@ HTML_OUTPUT = html HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = -HTML_STYLESHEET = /home/denis/Profession/groundworks/cmd_line_params_parser/clp_parser/doc/own.css +HTML_STYLESHEET = ./doc/own.css HTML_ALIGN_MEMBERS = YES GENERATE_HTMLHELP = NO GENERATE_DOCSET = NO diff --git a/clpp/detail/argument_caster.hpp b/include/clpp/detail/argument_caster.hpp similarity index 100% rename from clpp/detail/argument_caster.hpp rename to include/clpp/detail/argument_caster.hpp diff --git a/clpp/detail/argument_holder.hpp b/include/clpp/detail/argument_holder.hpp similarity index 100% rename from clpp/detail/argument_holder.hpp rename to include/clpp/detail/argument_holder.hpp diff --git a/clpp/detail/checkers/all.hpp b/include/clpp/detail/checkers/all.hpp similarity index 100% rename from clpp/detail/checkers/all.hpp rename to include/clpp/detail/checkers/all.hpp diff --git a/clpp/detail/checkers/common_checker.hpp b/include/clpp/detail/checkers/common_checker.hpp similarity index 100% rename from clpp/detail/checkers/common_checker.hpp rename to include/clpp/detail/checkers/common_checker.hpp diff --git a/clpp/detail/checkers/incorrect_parameters.hpp b/include/clpp/detail/checkers/incorrect_parameters.hpp similarity index 100% rename from clpp/detail/checkers/incorrect_parameters.hpp rename to include/clpp/detail/checkers/incorrect_parameters.hpp diff --git a/clpp/detail/checkers/necessary_parameters.hpp b/include/clpp/detail/checkers/necessary_parameters.hpp similarity index 100% rename from clpp/detail/checkers/necessary_parameters.hpp rename to include/clpp/detail/checkers/necessary_parameters.hpp diff --git a/clpp/detail/checkers/parameters_existence.hpp b/include/clpp/detail/checkers/parameters_existence.hpp similarity index 100% rename from clpp/detail/checkers/parameters_existence.hpp rename to include/clpp/detail/checkers/parameters_existence.hpp diff --git a/clpp/detail/checkers/parameters_redundancy.hpp b/include/clpp/detail/checkers/parameters_redundancy.hpp similarity index 100% rename from clpp/detail/checkers/parameters_redundancy.hpp rename to include/clpp/detail/checkers/parameters_redundancy.hpp diff --git a/clpp/detail/checkers/parameters_repetition.hpp b/include/clpp/detail/checkers/parameters_repetition.hpp similarity index 100% rename from clpp/detail/checkers/parameters_repetition.hpp rename to include/clpp/detail/checkers/parameters_repetition.hpp diff --git a/clpp/detail/checkers/validators.hpp b/include/clpp/detail/checkers/validators.hpp similarity index 100% rename from clpp/detail/checkers/validators.hpp rename to include/clpp/detail/checkers/validators.hpp diff --git a/clpp/detail/checkers/values_correction.hpp b/include/clpp/detail/checkers/values_correction.hpp similarity index 100% rename from clpp/detail/checkers/values_correction.hpp rename to include/clpp/detail/checkers/values_correction.hpp diff --git a/clpp/detail/checkers/values_semantic.hpp b/include/clpp/detail/checkers/values_semantic.hpp similarity index 100% rename from clpp/detail/checkers/values_semantic.hpp rename to include/clpp/detail/checkers/values_semantic.hpp diff --git a/clpp/detail/misc.hpp b/include/clpp/detail/misc.hpp similarity index 100% rename from clpp/detail/misc.hpp rename to include/clpp/detail/misc.hpp diff --git a/clpp/detail/parameter.hpp b/include/clpp/detail/parameter.hpp similarity index 100% rename from clpp/detail/parameter.hpp rename to include/clpp/detail/parameter.hpp diff --git a/clpp/detail/parameter_parts_extractor.hpp b/include/clpp/detail/parameter_parts_extractor.hpp similarity index 100% rename from clpp/detail/parameter_parts_extractor.hpp rename to include/clpp/detail/parameter_parts_extractor.hpp diff --git a/clpp/detail/types.hpp b/include/clpp/detail/types.hpp similarity index 100% rename from clpp/detail/types.hpp rename to include/clpp/detail/types.hpp diff --git a/clpp/detail/unnamed_parameters_handler.hpp b/include/clpp/detail/unnamed_parameters_handler.hpp similarity index 100% rename from clpp/detail/unnamed_parameters_handler.hpp rename to include/clpp/detail/unnamed_parameters_handler.hpp diff --git a/clpp/detail/user_functions_caller.hpp b/include/clpp/detail/user_functions_caller.hpp similarity index 100% rename from clpp/detail/user_functions_caller.hpp rename to include/clpp/detail/user_functions_caller.hpp diff --git a/clpp/parser.hpp b/include/clpp/parser.hpp similarity index 100% rename from clpp/parser.hpp rename to include/clpp/parser.hpp