Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building and packaging with CMake and other improvements #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.exe
*.o

/examples/basicSample
/examples/fullSample
/examples/globSample
/examples/runtests.out
/build
11 changes: 11 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
79 changes: 79 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 3 additions & 3 deletions SimpleOpt.dsw
Original file line number Diff line number Diff line change
Expand Up @@ -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>
{{{
Expand All @@ -15,7 +15,7 @@ Package=<4>

###############################################################################

Project: "fullSample"=.\fullSample.dsp - Package Owner=<4>
Project: "fullSample"=.\examples\fullSample.dsp - Package Owner=<4>

Package=<5>
{{{
Expand All @@ -27,7 +27,7 @@ Package=<4>

###############################################################################

Project: "globSample"=.\globSample.dsp - Package Owner=<4>
Project: "globSample"=.\examples\globSample.dsp - Package Owner=<4>

Package=<5>
{{{
Expand Down
6 changes: 3 additions & 3 deletions SimpleOpt.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions cmake/thirdParty/Boilerplate
Submodule Boilerplate added at 1d54bd
1 change: 1 addition & 0 deletions cmake/thirdParty/DoxygenUtils
Submodule DoxygenUtils added at ad6b4d
12 changes: 6 additions & 6 deletions Makefile → examples/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

File renamed without changes.
4 changes: 2 additions & 2 deletions basicSample.dsp → examples/basicSample.dsp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions basicSample.vcproj → examples/basicSample.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc">
<File
RelativePath="SimpleGlob.h">
RelativePath="../include/SimpleGlob.h">
</File>
<File
RelativePath="SimpleOpt.h">
RelativePath="../include/SimpleOpt.h">
</File>
</Filter>
</Files>
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions fullSample.dsp → examples/fullSample.dsp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions fullSample.vcproj → examples/fullSample.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc">
<File
RelativePath="SimpleGlob.h">
RelativePath="../include/SimpleGlob.h">
</File>
<File
RelativePath="SimpleOpt.h">
RelativePath="../include/SimpleOpt.h">
</File>
</Filter>
</Files>
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions globSample.dsp → examples/globSample.dsp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions globSample.vcproj → examples/globSample.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc">
<File
RelativePath="SimpleGlob.h">
RelativePath="../include/SimpleGlob.h">
</File>
<File
RelativePath="SimpleOpt.h">
RelativePath="../include/SimpleOpt.h">
</File>
</Filter>
</Files>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions package.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down