-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4ae562d
Showing
16 changed files
with
1,340 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
cmake_minimum_required (VERSION 2.6) | ||
|
||
|
||
# ================== | ||
# Define Our Project | ||
# ================== | ||
|
||
set (My_Project_Title "Some Project") | ||
set (My_Project_Author "Somebody") | ||
set (My_Project_Revised_Date "2015-06-05") | ||
set (My_Project_Version_Major 1) | ||
set (My_Project_Version_Minor 0) | ||
set (My_Project_Version_Patch 0) | ||
|
||
set (My_Project_Copyright_Date "2015") | ||
set (My_Project_Copyright "Copyright © ${My_Project_Copyright_Date} ${My_Project_Author}.") | ||
|
||
project (${My_Project_Title}) | ||
|
||
|
||
# Search for included files here | ||
include_directories( ${PROJECT_SOURCE_DIR}/src ) | ||
include_directories( ${PROJECT_SOURCE_DIR}/test ) | ||
|
||
|
||
string(TOUPPER ${My_Project_Title} My_Project_Title_Caps ) | ||
string(REGEX REPLACE " " "_" My_Project_Title_Caps ${My_Project_Title_Caps} ) | ||
|
||
|
||
# ====================== | ||
# Process Template Files | ||
# ====================== | ||
|
||
file(READ ${PROJECT_SOURCE_DIR}/LICENSE.txt My_Project_License) | ||
|
||
string(REGEX REPLACE "\n" "\n\t" My_Project_License_Indent ${My_Project_License}) | ||
|
||
configure_file ( | ||
"${PROJECT_SOURCE_DIR}/templates/template.c.in" | ||
"${PROJECT_BINARY_DIR}/template.c" | ||
) | ||
|
||
configure_file ( | ||
"${PROJECT_SOURCE_DIR}/templates/template.h.in" | ||
"${PROJECT_BINARY_DIR}/template.h" | ||
) | ||
|
||
configure_file ( | ||
"${PROJECT_SOURCE_DIR}/templates/README.md.in" | ||
"${PROJECT_BINARY_DIR}/README.md" | ||
) | ||
|
||
|
||
# ============= | ||
# Build Targets | ||
# ============= | ||
|
||
set(src_files | ||
# src/file.c | ||
) | ||
|
||
set(header_files | ||
# src/file.h | ||
) | ||
|
||
# Create a library? | ||
# add_library(libFOO STATIC | ||
# ${src_files} | ||
# ${header_files} | ||
# ) | ||
|
||
# remove the extra "lib" from "liblibFOO" | ||
# SET_TARGET_PROPERTIES(libFOO PROPERTIES PREFIX "") | ||
|
||
# Create a command-line app? | ||
# if (NOT DEFINED TEST) | ||
# add_executable(main | ||
# src/main.c | ||
# src/GLibFacade.c | ||
# src/GLibFacade.h | ||
# ${header_files} | ||
# ) | ||
# | ||
# Link the library to the app? | ||
# target_link_libraries(main libFOO) | ||
# endif() | ||
|
||
|
||
# =========================================== | ||
# Build Test Suite with CuTest (unit testing) | ||
# =========================================== | ||
|
||
set(test_files | ||
test/CuTest.c | ||
test/CuTest.h | ||
${PROJECT_BINARY_DIR}/AllTests.c | ||
) | ||
|
||
if (DEFINED TEST) | ||
add_definitions(-DTEST) | ||
|
||
add_executable(run_tests | ||
${test_files} | ||
${src_files} | ||
${header_files} | ||
) | ||
|
||
# Process source files to look for tests to run | ||
add_custom_command ( | ||
OUTPUT ${PROJECT_BINARY_DIR}/AllTests.c | ||
COMMAND sh ${PROJECT_SOURCE_DIR}/test/make-tests.sh ${PROJECT_SOURCE_DIR}/src/*.c > ${PROJECT_BINARY_DIR}/AllTests.c | ||
) | ||
|
||
enable_testing() | ||
|
||
add_test( test ${PROJECT_BINARY_DIR}/run_tests) | ||
|
||
endif() | ||
|
||
|
||
# ========================== | ||
# Build Installer with CPack | ||
# ========================== | ||
|
||
# You're on your own here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
This project is designed for use with cmake. | ||
|
||
The Makefile controls the overall build: | ||
|
||
make | ||
make release | ||
|
||
Build a version optimized for performance. | ||
|
||
make debug | ||
|
||
Faster compile, but not as high performance. | ||
|
||
make xcode | ||
|
||
Create an Xcode project for use on OS X. | ||
|
||
make windows | ||
|
||
Used for cross-compiling for Windows using MinGW. | ||
|
||
make clean | ||
|
||
Clean up the `build` directory. | ||
|
||
These commands control the `build` directory. Everything in this directory is | ||
auto-generated. You should not manually change these files or put anything | ||
else in there. | ||
|
||
|
||
The setup is designed to support unit testing with CuTest. Functions along | ||
the lines of `void Test*` will be located automatically and used to create the | ||
test suite, which is run by: | ||
|
||
./run_tests | ||
|
||
Or | ||
|
||
make test | ||
|
||
(The `run_tests` approach will probably give more useful feedback if a test fails.) | ||
|
||
|
||
Integration testing must be handled separately. | ||
|
||
You can configure the `CMakeLists.txt` to support creating installers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
The `new-project` project is released under the MIT License. | ||
|
||
GLibFacade.c and GLibFacade.h are from the MultiMarkdown v4 project: | ||
|
||
https://github.com/fletcher/MultiMarkdown-4/ | ||
|
||
MMD 4 is released under both the MIT License and GPL. | ||
|
||
|
||
CuTest is released under the zlib/libpng license. See CuTest.c for the text | ||
of the license. | ||
|
||
|
||
## The MIT License ## | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BUILD_DIR = build | ||
|
||
$(BUILD_DIR_): | ||
-mkdir $(BUILD_DIR_) 2>/dev/null | ||
-cd $(BUILD_DIR); rm -rf * | ||
|
||
# The release target will perform additional optimization | ||
release: $(BUILD_DIR) | ||
cd $(BUILD_DIR); \ | ||
cmake -DCMAKE_BUILD_TYPE=Release .. | ||
|
||
# Enables CuTest unit testing | ||
debug: $(BUILD_DIR) | ||
cd $(BUILD_DIR); \ | ||
cmake -DTEST=1 .. | ||
|
||
# For Mac only | ||
xcode: $(BUILD_DIR) | ||
cd $(BUILD_DIR); \ | ||
cmake -G Xcode .. | ||
|
||
# Cross-compile for Windows | ||
windows: $(BUILD_DIR) | ||
cd $(BUILD_DIR); \ | ||
cmake -DCMAKE_TOOLCHAIN_FILE=../tools/Toolchain-mingw32.cmake -DCMAKE_BUILD_TYPE=Release .. | ||
|
||
# Clean out the build directory | ||
clean: | ||
rm -rf $(BUILD_DIR)/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
Title: Some Project | ||
Author: Fletcher T. Penney | ||
Date: 2015-06-05 | ||
Copyright: Copyright © 2015 Fletcher T. Penney. | ||
Version: 1.0.0 | ||
|
||
# Introduction # | ||
|
||
This template was created out of a desire to simplify some of the setup and | ||
configuration that I was doing over and over each time I started a new project. | ||
Additionally, I wanted to try to start encouraging some "better practices" | ||
(though not necessarily "best practices"): | ||
|
||
1. [Test-driven development][tdd] -- My development of MultiMarkdown | ||
focused on integration testing, but really had no unit testing to | ||
speak of. Some newer projects I began working on were a bit math- | ||
heavy, and ensuring that each piece works properly became even more | ||
important. It was also nice to be able to actually develop code that | ||
could do *something* (via the test suite), even though the project as | ||
a whole was nowhere near complete.) To accomplish this, I include the | ||
[CuTest] project to support writing tests for your code. | ||
|
||
2. Use of the [cmake] build system. `cmake` is not perfect by any | ||
means, but it does offer some very useful features and a means for | ||
better integrating the compilation and packaging/installation aspects | ||
of development. Rather than reinventing the wheel each time, this | ||
setup incorporates basic `cmake` functionality to make it easy to | ||
control how your project is compiled, and includes automated generation | ||
of the test command. | ||
|
||
3. Templates -- `cmake` has a reasonable templating system, so that you | ||
can define basic variables (e.g. author, project name, etc.) and allow | ||
`cmake` to combine those elements to ensure consistency across source | ||
code and README files. | ||
|
||
|
||
|
||
[tdd]: https://en.wikipedia.org/wiki/Test-driven_development | ||
[cmake]: http://www.cmake.org/ | ||
[CuTest]: http://cutest.sourceforge.net | ||
|
||
|
||
# How do I use it? # | ||
|
||
You can download the source from [github] and get to work. The file "IMPORTANT" | ||
contains instructions on the various build commands you can use. | ||
|
||
|
||
I recommend using the following script to automatically create a new git repo, | ||
pull in the default project template, and configure git-flow. You simply have | ||
to rename your project from `new-project` to whatever you desire: | ||
|
||
|
||
#!/bin/sh | ||
|
||
git init new-project | ||
|
||
cd new-project | ||
|
||
git remote add "template" https://github.com/fletcher/c-template.git | ||
|
||
git pull template master | ||
|
||
git flow init -d | ||
|
||
git checkout develop | ||
|
||
|
||
Using this approach, you can define your own "origin" remote if you like, but | ||
the "template" remote can be used to update the core project files should any | ||
improvements come about: | ||
|
||
git checkout develop | ||
git merge template master | ||
|
||
**NOTE**: `cmake` is a complex suite of utilities, and if you have trouble you | ||
will need to get support elsewhere. If you find errors in this template, by | ||
all means I want to hear about them and fix them, but this is just a basic | ||
framework to get you started. In all likelihood, all but the most basic | ||
projects will need some customization. | ||
|
||
|
||
# License # | ||
|
||
## The MIT License ## | ||
|
||
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Ignore everything in this directory | ||
* | ||
# Except this file | ||
!.gitignore |
Oops, something went wrong.