Skip to content

Commit 76c9c5e

Browse files
committed
new file: GenericMakefile/.gitignore
new file: GenericMakefile/LICENSE new file: GenericMakefile/README.md new file: GenericMakefile/c/hello.c new file: GenericMakefile/cpp/hello.cpp new file: example/.gitignore new file: example/.travis.yml new file: example/01-basic/A-hello-cmake/CMakeLists.txt new file: example/01-basic/A-hello-cmake/README.adoc new file: example/01-basic/A-hello-cmake/main.cpp new file: example/01-basic/B-hello-headers/CMakeLists.txt new file: example/01-basic/B-hello-headers/README.adoc new file: example/01-basic/B-hello-headers/include/Hello.h new file: example/01-basic/B-hello-headers/src/Hello.cpp new file: example/01-basic/B-hello-headers/src/main.cpp new file: example/01-basic/C-static-library/CMakeLists.txt new file: example/01-basic/C-static-library/README.adoc new file: example/01-basic/C-static-library/include/static/Hello.h new file: example/01-basic/C-static-library/src/Hello.cpp new file: example/01-basic/C-static-library/src/main.cpp new file: example/01-basic/D-shared-library/CMakeLists.txt new file: example/01-basic/D-shared-library/README.adoc new file: example/01-basic/D-shared-library/include/shared/Hello.h new file: example/01-basic/D-shared-library/src/Hello.cpp new file: example/01-basic/D-shared-library/src/main.cpp new file: example/01-basic/E-installing/CMakeLists.txt new file: example/01-basic/E-installing/README.adoc new file: example/01-basic/E-installing/cmake-examples.conf new file: example/01-basic/E-installing/include/installing/Hello.h new file: example/01-basic/E-installing/src/Hello.cpp new file: example/01-basic/E-installing/src/main.cpp new file: example/01-basic/F-build-type/CMakeLists.txt new file: example/01-basic/F-build-type/README.adoc new file: example/01-basic/F-build-type/cmake-gui-build-type.png new file: example/01-basic/F-build-type/main.cpp new file: example/01-basic/G-compile-flags/CMakeLists.txt new file: example/01-basic/G-compile-flags/README.adoc new file: example/01-basic/G-compile-flags/main.cpp new file: example/01-basic/H-third-party-library/CMakeLists.txt new file: example/01-basic/H-third-party-library/README.adoc new file: example/01-basic/H-third-party-library/main.cpp new file: example/01-basic/I-compiling-with-clang/CMakeLists.txt new file: example/01-basic/I-compiling-with-clang/README.adoc new file: example/01-basic/I-compiling-with-clang/main.cpp new file: example/01-basic/I-compiling-with-clang/pre_test.sh new file: example/01-basic/I-compiling-with-clang/run_test.sh new file: example/01-basic/J-building-with-ninja/CMakeLists.txt new file: example/01-basic/J-building-with-ninja/README.adoc new file: example/01-basic/J-building-with-ninja/main.cpp new file: example/01-basic/J-building-with-ninja/pre_test.sh new file: example/01-basic/J-building-with-ninja/run_test.sh new file: example/01-basic/K-imported-targets/CMakeLists.txt new file: example/01-basic/K-imported-targets/README.adoc new file: example/01-basic/K-imported-targets/main.cpp new file: example/01-basic/K-imported-targets/run_test.sh new file: example/01-basic/L-cpp-standard/README.adoc new file: example/01-basic/L-cpp-standard/i-common-method/CMakeLists.txt new file: example/01-basic/L-cpp-standard/i-common-method/README.adoc new file: example/01-basic/L-cpp-standard/i-common-method/main.cpp new file: example/01-basic/L-cpp-standard/ii-cxx-standard/CMakeLists.txt new file: example/01-basic/L-cpp-standard/ii-cxx-standard/README.adoc new file: example/01-basic/L-cpp-standard/ii-cxx-standard/main.cpp new file: example/01-basic/L-cpp-standard/iii-compile-features/CMakeLists.txt new file: example/01-basic/L-cpp-standard/iii-compile-features/README.adoc new file: example/01-basic/L-cpp-standard/iii-compile-features/main.cpp new file: example/01-basic/README.adoc new file: example/02-sub-projects/A-basic/CMakeLists.txt new file: example/02-sub-projects/A-basic/README.adoc new file: example/02-sub-projects/A-basic/subbinary/CMakeLists.txt new file: example/02-sub-projects/A-basic/subbinary/main.cpp new file: example/02-sub-projects/A-basic/sublibrary1/CMakeLists.txt new file: example/02-sub-projects/A-basic/sublibrary1/include/sublib1/sublib1.h new file: example/02-sub-projects/A-basic/sublibrary1/src/sublib1.cpp new file: example/02-sub-projects/A-basic/sublibrary2/CMakeLists.txt new file: example/02-sub-projects/A-basic/sublibrary2/include/sublib2/sublib2.h new file: example/02-sub-projects/README.adoc new file: example/03-code-generation/README.adoc new file: example/03-code-generation/configure-files/CMakeLists.txt new file: example/03-code-generation/configure-files/README.adoc new file: example/03-code-generation/configure-files/main.cpp new file: example/03-code-generation/configure-files/path.h.in new file: example/03-code-generation/configure-files/ver.h.in new file: example/03-code-generation/protobuf/AddressBook.proto new file: example/03-code-generation/protobuf/CMakeLists.txt new file: example/03-code-generation/protobuf/README.adoc new file: example/03-code-generation/protobuf/main.cpp new file: example/04-static-analysis/README.adoc new file: example/04-static-analysis/clang-analyzer/CMakeLists.txt new file: example/04-static-analysis/clang-analyzer/README.adoc new file: example/04-static-analysis/clang-analyzer/run_test.sh new file: example/04-static-analysis/clang-analyzer/subproject1/CMakeLists.txt new file: example/04-static-analysis/clang-analyzer/subproject1/main1.cpp new file: example/04-static-analysis/clang-analyzer/subproject2/CMakeLists.txt new file: example/04-static-analysis/clang-analyzer/subproject2/main2.cpp new file: example/04-static-analysis/clang-format/.clang-format new file: example/04-static-analysis/clang-format/CMakeLists.txt new file: example/04-static-analysis/clang-format/README.adoc new file: example/04-static-analysis/clang-format/cmake/modules/FindClangFormat.cmake new file: example/04-static-analysis/clang-format/cmake/modules/clang-format.cmake new file: example/04-static-analysis/clang-format/cmake/scripts/clang-format-check-changed new file: example/04-static-analysis/clang-format/cmake/scripts/clang-format-check-changed.py new file: example/04-static-analysis/clang-format/run_test.sh new file: example/04-static-analysis/clang-format/subproject1/CMakeLists.txt new file: example/04-static-analysis/clang-format/subproject1/main1.cpp new file: example/04-static-analysis/clang-format/subproject2/CMakeLists.txt new file: example/04-static-analysis/clang-format/subproject2/main2.cpp new file: example/04-static-analysis/cppcheck-compile-commands/.cppcheck_suppressions new file: example/04-static-analysis/cppcheck-compile-commands/CMakeLists.txt new file: example/04-static-analysis/cppcheck-compile-commands/README.adoc new file: example/04-static-analysis/cppcheck-compile-commands/cmake/modules/FindCppCheck.cmake new file: example/04-static-analysis/cppcheck-compile-commands/run_test.sh new file: example/04-static-analysis/cppcheck-compile-commands/subproject1/CMakeLists.txt new file: example/04-static-analysis/cppcheck-compile-commands/subproject1/main1.cpp new file: example/04-static-analysis/cppcheck-compile-commands/subproject2/CMakeLists.txt new file: example/04-static-analysis/cppcheck-compile-commands/subproject2/main2.cpp new file: example/04-static-analysis/cppcheck/CMakeLists.txt new file: example/04-static-analysis/cppcheck/README.adoc new file: example/04-static-analysis/cppcheck/cmake/analysis.cmake new file: example/04-static-analysis/cppcheck/cmake/modules/FindCppCheck.cmake new file: example/04-static-analysis/cppcheck/run_test.sh new file: example/04-static-analysis/cppcheck/subproject1/CMakeLists.txt new file: example/04-static-analysis/cppcheck/subproject1/main1.cpp new file: example/04-static-analysis/cppcheck/subproject2/CMakeLists.txt new file: example/04-static-analysis/cppcheck/subproject2/main2.cpp new file: example/05-unit-testing/README.adoc new file: example/05-unit-testing/boost/CMakeLists.txt new file: example/05-unit-testing/boost/Palindrome.cpp new file: example/05-unit-testing/boost/Palindrome.h new file: example/05-unit-testing/boost/README.adoc new file: example/05-unit-testing/boost/Reverse.cpp new file: example/05-unit-testing/boost/Reverse.h new file: example/05-unit-testing/boost/main.cpp new file: example/05-unit-testing/boost/post_test.sh new file: example/05-unit-testing/boost/unit_tests.cpp new file: example/05-unit-testing/catch2-vendored/3rd_party/catch2/CMakeLists.txt new file: example/05-unit-testing/catch2-vendored/3rd_party/catch2/catch2/catch.hpp new file: example/05-unit-testing/catch2-vendored/CMakeLists.txt new file: example/05-unit-testing/catch2-vendored/Palindrome.cpp new file: example/05-unit-testing/catch2-vendored/Palindrome.h new file: example/05-unit-testing/catch2-vendored/README.adoc new file: example/05-unit-testing/catch2-vendored/Reverse.cpp new file: example/05-unit-testing/catch2-vendored/Reverse.h new file: example/05-unit-testing/catch2-vendored/main.cpp new file: example/05-unit-testing/catch2-vendored/post_test.sh new file: example/05-unit-testing/catch2-vendored/unit_tests.cpp new file: example/05-unit-testing/google-test-download/3rd_party/google-test/CMakeLists.txt new file: example/05-unit-testing/google-test-download/3rd_party/google-test/CMakeLists.txt.in new file: example/05-unit-testing/google-test-download/CMakeLists.txt new file: example/05-unit-testing/google-test-download/Palindrome.cpp new file: example/05-unit-testing/google-test-download/Palindrome.h new file: example/05-unit-testing/google-test-download/README.adoc new file: example/05-unit-testing/google-test-download/Reverse.cpp new file: example/05-unit-testing/google-test-download/Reverse.h new file: example/05-unit-testing/google-test-download/main.cpp new file: example/05-unit-testing/google-test-download/post_test.sh new file: example/05-unit-testing/google-test-download/run_test.sh new file: example/05-unit-testing/google-test-download/unit_tests.cpp new file: example/06-installer/README.adoc new file: example/06-installer/deb/CMakeLists.txt new file: example/06-installer/deb/README.adoc new file: example/06-installer/deb/cmake-examples.conf new file: example/06-installer/deb/include/Hello.h new file: example/06-installer/deb/post_test.sh new file: example/06-installer/deb/src/Hello.cpp new file: example/06-installer/deb/src/main.cpp new file: example/07-package-management/A-using-system-provide-packages/README.adoc new file: example/07-package-management/B-vendoring-code/README.adoc new file: example/07-package-management/C-external-project-add/README.adoc new file: example/07-package-management/D-conan/README.adoc new file: example/07-package-management/D-conan/i-basic/CMakeLists.txt new file: example/07-package-management/D-conan/i-basic/README.adoc new file: example/07-package-management/D-conan/i-basic/conanfile.txt new file: example/07-package-management/D-conan/i-basic/main.cpp new file: example/07-package-management/D-conan/i-basic/run_test.sh new file: example/07-package-management/D-conan/ii-basic-targets/CMakeLists.txt new file: example/07-package-management/D-conan/ii-basic-targets/README.adoc new file: example/07-package-management/D-conan/ii-basic-targets/conanfile.txt new file: example/07-package-management/D-conan/ii-basic-targets/main.cpp new file: example/07-package-management/D-conan/ii-basic-targets/run_test.sh new file: example/07-package-management/README.adoc new file: example/LICENSE new file: example/README.adoc new file: example/cmake-examples.sublime-project new file: example/dockerfiles/README.adoc new file: example/dockerfiles/setup.sh new file: example/dockerfiles/ubuntu14.04-cmake-3.4.3 new file: example/dockerfiles/ubuntu14.04-default-2.8.12.2 new file: example/dockerfiles/ubuntu16.04-cmake-3.10.3 new file: example/dockerfiles/ubuntu16.04-default-cmake-3.5.1 new file: example/test.sh new file: examples
1 parent 85c9f00 commit 76c9c5e

File tree

191 files changed

+22536
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

191 files changed

+22536
-0
lines changed

cmake/GenericMakefile/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bin
2+
build
3+
hello

cmake/GenericMakefile/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Michael Crawford
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

cmake/GenericMakefile/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
GenericMakefile
2+
===============
3+
4+
A generic makefile for use with small/medium C and C++ projects. Allows for
5+
easy project setup without the need to create tedious build rules or
6+
dependency lists. The c directory contains a makefile configured for C, while
7+
the makefile in the cpp directory is configured for C++.
8+
9+
## Features
10+
* Automatically finds and compiles all source files within the source directory.
11+
* Compiles most recently modified files first, to hopefully find problems earlier.
12+
* Automatically generates dependecies as files are compiled, ensuring that files are correctly recompiled when dependecies have updated.
13+
* Includes configurations for normal (release) build and debug build suitable for GDB debugging.
14+
* Times the compilation of each file and the entire build.
15+
* Generates version numbers based on git tags (see below), which are passed the compiler as preprocessor macros.
16+
* By default, builds in a "quiet" mode that only lists the actions being performed. By passing V=true to make, you can compile in verbose mode to see the full compiler commands being issued.
17+
18+
### Versioning
19+
Tags should be made in the format `vMAJOR.MINOR.PATCH[-description]`, where `MAJOR`, `MINOR`, and `PATCH` are numeric. The following macros will be generated and passed to the preprocessor:
20+
* `VERSION_MAJOR (int)` - The major version number from the most recent tag.
21+
* `VERSION_MINOR (int)` - The minor version number from the most recent tag.
22+
* `VERSION_PATCH (int)` - The patch version number from the most recent tag.
23+
* `VERSION_REVISION (int)` - The number of commits since the most recent tag.
24+
* `VERSION_HASH (string)` - The SHA of the current commit. Includes the "-dirty" suffix if there are uncommited changes.
25+
26+
If the makefile is not used in a git repository, or is in a repository with no tags, the version macros are not created.
27+
28+
## Limitations
29+
* Assumes GNU make.
30+
* Timing does not work correctly with MacOS. See [issue #6](https://github.com/mbcrawfo/GenericMakefile/issues/6) for a workaround patch that allows timing in seconds on Mac.
31+
* Doesn't really support multiple types of source files in the same project.
32+
* No easy way to exclude files from the build. You can either change the
33+
extension of files to be excluded, or use preprocessor flags for
34+
conditional compilation.
35+
36+
## Thanks to
37+
* My friend Jay and people on Stack Overflow for help with regex to parse the version info.
38+
* The residents of [/r/programming](https://www.reddit.com/r/programming/) for suggesting numerous tweaks and improvements.

cmake/GenericMakefile/c/hello.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <stdio.h>
2+
3+
int main(int argc, char* argv[])
4+
{
5+
// suppress warnings
6+
(void)argc; (void)argv;
7+
8+
printf("Hello World!\n");
9+
return 0;
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <iostream>
2+
3+
int main(int argc, char* argv[])
4+
{
5+
// suppress warnings
6+
(void)argc; (void)argv;
7+
8+
std::cout << "Hello World!" << std::endl;
9+
return 0;
10+
}

cmake/example/.gitignore

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
CMakeCache.txt
2+
CMakeFiles
3+
Makefile
4+
cmake_install.cmake
5+
install_manifest.txt
6+
7+
#
8+
# Sublime Test
9+
#
10+
# cache files for sublime text
11+
*.tmlanguage.cache
12+
*.tmPreferences.cache
13+
*.stTheme.cache
14+
15+
# workspace files are user-specific
16+
*.sublime-workspace
17+
18+
# project files should be checked into the repository, unless a significant
19+
# proportion of contributors will probably not be using SublimeText
20+
# *.sublime-project
21+
22+
#
23+
# C / C++
24+
#
25+
26+
# Compiled Object files
27+
*.slo
28+
*.lo
29+
*.o
30+
*.obj
31+
*.ko
32+
*.elf
33+
34+
# Precompiled Headers
35+
*.gch
36+
*.pch
37+
38+
# Compiled Dynamic libraries
39+
*.so
40+
*.dylib
41+
*.dll
42+
*.so.*
43+
*.dylib
44+
45+
# Fortran module files
46+
*.mod
47+
48+
# Compiled Static libraries
49+
*.lai
50+
*.la
51+
*.a
52+
*.lib
53+
*.lo
54+
55+
# Executables
56+
*.exe
57+
*.out
58+
*.app
59+
60+
/**/build
61+
/**/build.*
62+
63+
.tags
64+
.vscode

cmake/example/.travis.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
language: cpp
2+
services:
3+
- docker
4+
sudo: required
5+
compiler:
6+
- gcc
7+
before_install:
8+
- docker pull matrim/cmake-examples:3.5.1
9+
- docker pull matrim/cmake-examples:3.10.3
10+
script:
11+
- docker run --rm -v $PWD:/data/code -e DEV_UID=`id -u` -e DEV_GID=`id -g` -it matrim/cmake-examples:3.5.1 /data/code/test.sh
12+
- docker run --rm -v $PWD:/data/code -e DEV_UID=`id -u` -e DEV_GID=`id -g` -it matrim/cmake-examples:3.10.3 /data/code/test.sh
13+
branches:
14+
except:
15+
- gh-pages
16+
notifications:
17+
email: true
18+
os:
19+
- linux
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Set the minimum version of CMake that can be used
2+
# To find the cmake version run
3+
# $ cmake --version
4+
cmake_minimum_required(VERSION 3.5)
5+
6+
# Set the project name
7+
project (hello_cmake)
8+
9+
# Add an executable
10+
add_executable(hello_cmake main.cpp)

0 commit comments

Comments
 (0)