diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..deee6e8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*.exe +*.o + +/examples/basicSample +/examples/fullSample +/examples/globSample +/examples/runtests.out +/build 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..810b896 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,79 @@ +cmake_minimum_required(VERSION 3.7.2) + +set(CMAKE_USE_RELATIVE_PATHS TRUE) +project("SimpleOpt") +set("PROJECT_DESCRIPTION" "An another command-line parser class for C++ that has features not available in alternative solutions (getopt, boost, argtable, argstream, gflags) and doesn't require a steep learning curve.") +set("PROJECT_HOMEPAGE_URL" "https://github.com/brofield/simpleopt") + +set(CPACK_PACKAGE_VENDOR "Brodie Thiesfield et al.") +set(CPACK_PACKAGE_VERSION_MAJOR "0") +set(CPACK_PACKAGE_VERSION_MINOR "2") +set(CPACK_PACKAGE_VERSION_PATCH "2") +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(Include_dir "${CMAKE_CURRENT_SOURCE_DIR}/include") +set(Examples_Dir "${CMAKE_CURRENT_SOURCE_DIR}/examples") + +buildAndPackageLib(${PROJECT_NAME} + TYPE INTERFACE + COMPONENT "lib" + DESCRIPTION "${PROJECT_DESCRIPTION}" + PUBLIC_INCLUDES ${Include_dir} + DO_NOT_PASSTHROUGH +) + +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}") + endforeach() +endif() + +option(WITH_DOCS "Build docs" ON) +if(WITH_DOCS) + find_package(Doxygen REQUIRED dot) + load_doxyfile("${CMAKE_CURRENT_SOURCE_DIR}/simpleopt.doxy") + + 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_PROJECT_BRIEF" "${PROJECT_DESCRIPTION}") + + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + message(STATUS "Compiler is CLang, enabling CLang-assisted parsing in Doxygen.") + set(DOXYGEN_CLANG_ASSISTED_PARSING YES) + set(DOXYGEN_CLANG_OPTIONS "-I${Include_dir}") + endif() + + set(DOXYGEN_EXAMPLE_PATH "${Examples_Dir}") + set(DOXYGEN_STRIP_FROM_PATH "${Include_dir}") + set(DOXYGEN_STRIP_FROM_INC_PATH "${Include_dir}") + + + file(GLOB 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/LICENSE b/LICENSE new file mode 100644 index 0000000..f71f797 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2006-2015, Brodie Thiesfield + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/SimpleOpt.dsw b/SimpleOpt.dsw index 3f87357..683ed7d 100644 --- a/SimpleOpt.dsw +++ b/SimpleOpt.dsw @@ -3,7 +3,7 @@ Microsoft Developer Studio Workspace File, Format Version 6.00 ############################################################################### -Project: "basicSample"=.\basicSample.dsp - Package Owner=<4> +Project: "basicSample"=.\examples\basicSample.dsp - Package Owner=<4> Package=<5> {{{ @@ -15,7 +15,7 @@ Package=<4> ############################################################################### -Project: "fullSample"=.\fullSample.dsp - Package Owner=<4> +Project: "fullSample"=.\examples\fullSample.dsp - Package Owner=<4> Package=<5> {{{ @@ -27,7 +27,7 @@ Package=<4> ############################################################################### -Project: "globSample"=.\globSample.dsp - Package Owner=<4> +Project: "globSample"=.\examples\globSample.dsp - Package Owner=<4> Package=<5> {{{ diff --git a/SimpleOpt.sln b/SimpleOpt.sln index 52935d4..ca0c546 100644 --- a/SimpleOpt.sln +++ b/SimpleOpt.sln @@ -1,13 +1,13 @@ Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basicSample", "basicSample.vcproj", "{BC46A349-E59A-4FDC-B56A-A668ED552758}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basicSample", "examples\basicSample.vcproj", "{BC46A349-E59A-4FDC-B56A-A668ED552758}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fullSample", "fullSample.vcproj", "{4693B3B5-9070-4DC3-8C61-AAD6BF288E90}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fullSample", "examples\fullSample.vcproj", "{4693B3B5-9070-4DC3-8C61-AAD6BF288E90}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "globSample", "globSample.vcproj", "{F3EED8E1-D911-4CAC-A8A2-BF127A6AC772}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "globSample", "examples\globSample.vcproj", "{F3EED8E1-D911-4CAC-A8A2-BF127A6AC772}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject diff --git a/cmake/thirdParty/Boilerplate b/cmake/thirdParty/Boilerplate new file mode 160000 index 0000000..1d54bdc --- /dev/null +++ b/cmake/thirdParty/Boilerplate @@ -0,0 +1 @@ +Subproject commit 1d54bdc194f7ea31fe37cbc1028dea925c014f44 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/Makefile b/examples/Makefile similarity index 56% rename from Makefile rename to examples/Makefile index 33a1703..6c5acfd 100644 --- a/Makefile +++ b/examples/Makefile @@ -1,12 +1,12 @@ CC=g++ CFLAGS=-Wall -CPPFLAGS=-Wall +CPPFLAGS=-Wall -I../include/ OBJS=fullSample.o basicSample.o globSample.o help: @echo This makefile is just for the test program \(use \"make clean all test\"\) - @echo Just include the SimpleOpt.h header file to use it. + @echo Just include the ../include/SimpleOpt.h header file to use it. all: $(OBJS) $(CC) -o globSample globSample.o @@ -22,9 +22,9 @@ test: diff --unified=0 -b runtests.ux.txt runtests.out install: - @echo No install required. Just include the SimpleOpt.h header file to use it. + @echo No install required. Just include the ./include/SimpleOpt.h header file to use it. -globSample.o: SimpleOpt.h SimpleGlob.h -fullSample.o: SimpleOpt.h SimpleGlob.h -basicSample.o: SimpleOpt.h SimpleGlob.h +globSample.o: ../include/SimpleOpt.h ../include/SimpleGlob.h +fullSample.o: ../include/SimpleOpt.h ../include/SimpleGlob.h +basicSample.o: ../include/SimpleOpt.h ../include/SimpleGlob.h diff --git a/basicSample.cpp b/examples/basicSample.cpp similarity index 100% rename from basicSample.cpp rename to examples/basicSample.cpp diff --git a/basicSample.dsp b/examples/basicSample.dsp similarity index 97% rename from basicSample.dsp rename to examples/basicSample.dsp index 2e000b6..e65d392 100644 --- a/basicSample.dsp +++ b/examples/basicSample.dsp @@ -144,11 +144,11 @@ SOURCE=.\basicSample.cpp # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File -SOURCE=.\SimpleGlob.h +SOURCE=..\include\SimpleGlob.h # End Source File # Begin Source File -SOURCE=.\SimpleOpt.h +SOURCE=..\include\SimpleOpt.h # End Source File # End Group # End Target diff --git a/basicSample.vcproj b/examples/basicSample.vcproj similarity index 94% rename from basicSample.vcproj rename to examples/basicSample.vcproj index 95c867a..fa13e71 100644 --- a/basicSample.vcproj +++ b/examples/basicSample.vcproj @@ -223,10 +223,10 @@ Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc"> + RelativePath="../include/SimpleGlob.h"> + RelativePath="../include/SimpleOpt.h"> diff --git a/fullSample.cpp b/examples/fullSample.cpp similarity index 100% rename from fullSample.cpp rename to examples/fullSample.cpp diff --git a/fullSample.dsp b/examples/fullSample.dsp similarity index 97% rename from fullSample.dsp rename to examples/fullSample.dsp index 5ea66ca..de022a0 100644 --- a/fullSample.dsp +++ b/examples/fullSample.dsp @@ -144,11 +144,11 @@ SOURCE=.\fullSample.cpp # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File -SOURCE=.\SimpleGlob.h +SOURCE=..\include\SimpleGlob.h # End Source File # Begin Source File -SOURCE=.\SimpleOpt.h +SOURCE=..\include\SimpleOpt.h # End Source File # End Group # End Target diff --git a/fullSample.vcproj b/examples/fullSample.vcproj similarity index 94% rename from fullSample.vcproj rename to examples/fullSample.vcproj index 7da09e5..4a39cd8 100644 --- a/fullSample.vcproj +++ b/examples/fullSample.vcproj @@ -223,10 +223,10 @@ Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc"> + RelativePath="../include/SimpleGlob.h"> + RelativePath="../include/SimpleOpt.h"> diff --git a/globSample.cpp b/examples/globSample.cpp similarity index 100% rename from globSample.cpp rename to examples/globSample.cpp diff --git a/globSample.dsp b/examples/globSample.dsp similarity index 97% rename from globSample.dsp rename to examples/globSample.dsp index 4dc0f31..e3a41fc 100644 --- a/globSample.dsp +++ b/examples/globSample.dsp @@ -144,11 +144,11 @@ SOURCE=.\globSample.cpp # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File -SOURCE=.\SimpleGlob.h +SOURCE=..\include\SimpleGlob.h # End Source File # Begin Source File -SOURCE=.\SimpleOpt.h +SOURCE=..\include\SimpleOpt.h # End Source File # End Group # End Target diff --git a/globSample.vcproj b/examples/globSample.vcproj similarity index 94% rename from globSample.vcproj rename to examples/globSample.vcproj index 5f47440..9bff212 100644 --- a/globSample.vcproj +++ b/examples/globSample.vcproj @@ -223,10 +223,10 @@ Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc"> + RelativePath="../include/SimpleGlob.h"> + RelativePath="../include/SimpleOpt.h"> diff --git a/runtests.cmd b/examples/runtests.cmd similarity index 100% rename from runtests.cmd rename to examples/runtests.cmd diff --git a/runtests.sh b/examples/runtests.sh old mode 100644 new mode 100755 similarity index 100% rename from runtests.sh rename to examples/runtests.sh diff --git a/runtests.ux.txt b/examples/runtests.ux.txt similarity index 100% rename from runtests.ux.txt rename to examples/runtests.ux.txt diff --git a/runtests.win.txt b/examples/runtests.win.txt similarity index 100% rename from runtests.win.txt rename to examples/runtests.win.txt diff --git a/SimpleGlob.h b/include/SimpleGlob.h similarity index 100% rename from SimpleGlob.h rename to include/SimpleGlob.h diff --git a/SimpleOpt.h b/include/SimpleOpt.h similarity index 100% rename from SimpleOpt.h rename to include/SimpleOpt.h diff --git a/package.cmd b/package.cmd index 20fc465..f334470 100644 --- a/package.cmd +++ b/package.cmd @@ -2,19 +2,19 @@ set VERSION=3.6 set SEVENZIP="C:\Program Files\7-Zip\7z.exe" -FOR /F "tokens=*" %%G IN ('DIR /AD /B /S basic*') DO ( +FOR /F "tokens=*" %%G IN ('DIR /AD /B /S examples\basic*') DO ( DEL /S /Q "%%G" RD "%%G" ) -FOR /F "tokens=*" %%G IN ('DIR /AD /B /S full*') DO ( +FOR /F "tokens=*" %%G IN ('DIR /AD /B /S examples\full*') DO ( DEL /S /Q "%%G" RD "%%G" ) -FOR /F "tokens=*" %%G IN ('DIR /AD /B /S glob*') DO ( +FOR /F "tokens=*" %%G IN ('DIR /AD /B /S examples\glob*') DO ( DEL /S /Q "%%G" RD "%%G" ) -DEL /Q "runtests.full*" +DEL /Q "examples\runtests.full*" DEL /Q "simpleOpt.ncb" ATTRIB -H "simpleOpt.suo" DEL /Q "simpleOpt.suo"