Skip to content

Commit

Permalink
Merge pull request #112 from saxbophone/develop
Browse files Browse the repository at this point in the history
v0.19.3 - C99 + C11 Build
  • Loading branch information
saxbophone authored Oct 25, 2016
2 parents 00c27c7 + 8bb8cc8 commit d0e6d60
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ compiler:
- clang
# commenting out gcc until installing GCC v5.x+ actually works on Travis CI
# - gcc
# different C Standard versions - test on C99 and C11
env:
- LIBSAXBOSPIRAL_C_STANDARD=99
- LIBSAXBOSPIRAL_C_STANDARD=11
# exclude gcc on osx as this always points to clang
matrix:
exclude:
Expand Down
18 changes: 15 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,21 @@
# begin basic metadata
cmake_minimum_required(VERSION 3.0)

project(libsaxbospiral VERSION 0.19.2 LANGUAGES C)
set(CMAKE_C_STANDARD 99)
project(libsaxbospiral VERSION 0.19.3 LANGUAGES C)

# set default C standard to use (C99)
set(SAXBOSPIRAL_C_STANDARD "99")
# if env variable LIBSAXBOSPIRAL_C_STANDARD is set and valid, override version
if(DEFINED ENV{LIBSAXBOSPIRAL_C_STANDARD})
# not a very robust regex but ok for most purposes
if("$ENV{LIBSAXBOSPIRAL_C_STANDARD}" MATCHES "(99|11)")
set(SAXBOSPIRAL_C_STANDARD "$ENV{LIBSAXBOSPIRAL_C_STANDARD}")
endif()
endif()
message(STATUS "C Standard set to C${SAXBOSPIRAL_C_STANDARD}")
set(CMAKE_C_STANDARD ${SAXBOSPIRAL_C_STANDARD})
set(CMAKE_C_STANDARD_REQUIRED ON)

set(
SAXBOSPIRAL_VERSION_STRING
"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
Expand Down Expand Up @@ -62,7 +74,7 @@ endfunction()

# enable extra flags (warnings) if we're not in release mode
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "")
message("Warnings Enabled")
message(STATUS "Warnings Enabled")
# enable all warnings about 'questionable constructs'
enable_c_compiler_flag_if_supported("-Wall")
# issue 'pedantic' warnings for strict ISO compliance
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ In addition, please make sure:

- You commit files with Unix Line-endings (`\n` `<LF>` `0x0a`)
- Each text file committed has a trailing newline at the end
- Your C code is compliant to the ISO C99 and C11 standards
- C source code is indented with 4 spaces per indentation level (no tabs)
- Public functions are prototyped in the correct C Header file, all private declarations are declared `static`
- Every public function (and ideally private too) has an accompanying explanatory comment
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ Libsaxbospiral can be built without installing for test purposes and for general

You will need:

- A compiler that can compile ISO C99 code
- A compiler that can compile ISO C99 or C11 code
- [Cmake](https://cmake.org/) - v3.0 or newer
- [libpng](http://www.libpng.org/pub/png/libpng.html) - (this often comes preinstalled with many modern unix-like systems)

> ### Note:
> These commands are for unix-like systems, without an IDE or other build system besides CMake. If building for a different system, or within an IDE or other environment, consult your IDE/System documentation on how to build CMake projects.
> Additionally, it is of worth noting that this library has only been thoroughly tested and developed on **Ubuntu GNU/Linux** with **GCC v5.4.0** and **Clang 3.8.0**. Although every effort has been made to make it as cross-platform as possible (including quite strict **ISO C 99** compliance), **Your Mileage May Vary**. Bug Reports and Patches for problems running on other systems, particularly **Microsoft Windows** and **Mac OSX** are most welcome.
> Additionally, it is of worth noting that this library has only been thoroughly tested and developed on **Ubuntu GNU/Linux** with **GCC v5.4.0** and **Clang 3.8.0**. Although every effort has been made to make it as cross-platform as possible (including quite strict **ISO C99** and **ISO C11** compliance), **Your Mileage May Vary**. Bug Reports and Patches for problems running on other systems, particularly **Microsoft Windows** and **Mac OSX** are most welcome.
### Recommended Library Build

Expand All @@ -61,6 +61,14 @@ cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON .
make
```

The above builds in C99 mode by default. The standard to use is controlled by the `LIBSAXBOSPIRAL_C_STANDARD` environment variable.

You can build in C11 mode if you want with the following:

```sh
LIBSAXBOSPIRAL_C_STANDARD=11 cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON .
```

> ### Note:
> Building as a shared library is recommended as then binaries compiled from [sxbp](https://github.com/saxbophone/sxbp) or your own programs that are linked against the shared version can immediately use any installed upgraded versions of libsaxbospiral with compatible ABIs without needing re-compiling.
Expand Down

0 comments on commit d0e6d60

Please sign in to comment.