Skip to content
Permalink
Browse files

Merge branch 'master' into master

  • Loading branch information...
vincent-richard committed Sep 7, 2018
2 parents 6cfe2c5 + ea0d248 commit 71968d978daea9beffdc22522e8e9a29d52c3e9e
Showing 558 changed files with 26,488 additions and 22,567 deletions.
@@ -12,7 +12,7 @@
# http://www.cmake.org
#

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.6 FATAL_ERROR)
CMAKE_MINIMUM_REQUIRED(VERSION 3.1 FATAL_ERROR)

INCLUDE(cmake/Utils.cmake)

@@ -68,6 +68,11 @@ SET(VMIME_API_VERSION ${VMIME_API_VERSION_CURRENT}.${VMIME_API_VERSION_REVISION}
# Set base name
SET(VMIME_LIBRARY_NAME vmime)

# Enable C++11
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_CXX_EXTENSIONS OFF)

# Source files
FILE(
GLOB_RECURSE
@@ -109,6 +114,10 @@ IF(VMIME_BUILD_SHARED_LIBRARY)
${VMIME_LIBRARY_INCLUDE_FILES}
)

TARGET_INCLUDE_DIRECTORIES(${VMIME_LIBRARY_NAME} PUBLIC
$<INSTALL_INTERFACE:include>
)

GENERATE_EXPORT_HEADER(
${VMIME_LIBRARY_NAME}
BASE_NAME VMIME
@@ -154,6 +163,10 @@ IF(VMIME_BUILD_STATIC_LIBRARY)
${VMIME_LIBRARY_INCLUDE_FILES}
)

TARGET_INCLUDE_DIRECTORIES(${VMIME_LIBRARY_NAME}-static PUBLIC
$<INSTALL_INTERFACE:include>
)

GENERATE_EXPORT_HEADER(
${VMIME_LIBRARY_NAME}-static
BASE_NAME VMIME
@@ -199,6 +212,7 @@ SET(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for libraries")
IF(VMIME_BUILD_SHARED_LIBRARY)
INSTALL(
TARGETS ${VMIME_LIBRARY_NAME}
EXPORT ${VMIME_LIBRARY_NAME}-config
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" COMPONENT sharedlibs
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" COMPONENT sharedlibs
)
@@ -207,6 +221,7 @@ ENDIF()
IF(VMIME_BUILD_STATIC_LIBRARY)
INSTALL(
TARGETS ${VMIME_LIBRARY_NAME}-static
EXPORT ${VMIME_LIBRARY_NAME}-config
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" COMPONENT staticlibs
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" COMPONENT staticlibs
)
@@ -222,6 +237,8 @@ INSTALL_HEADERS_WITH_DIRECTORY(VMIME_LIBRARY_GENERATED_INCLUDE_FILES headers "${
# COMPONENT headers
#)

install(EXPORT ${VMIME_LIBRARY_NAME}-config DESTINATION cmake)


##############################################################################
# Tests
@@ -783,89 +800,6 @@ ELSE()
ENDIF()


##############################################################################
# Language features

# C++11
INCLUDE(cmake/cmake-cxx11/Modules/CheckCXX11Features.cmake)

# Smart pointers
#
# If a C++11-compliant compiler is available and supports std::shared_ptr<>,
# use the standard implementation. Else, use boost::shared_ptr<>.
# In any case, let the user override the choice with VMIME_SHARED_PTR_USE_CXX
# and VMIME_SHARED_PTR_USE_BOOST variables.

CHECK_CXX_SOURCE_COMPILES(
"
#include <memory>
struct A { int foo; };
int main() {
std::shared_ptr <A> a = std::make_shared <A>();
return 0;
}
"
VMIME_HAS_CXX11_SHARED_PTR
)

IF(NOT VMIME_SHARED_PTR_USE_CXX AND NOT VMIME_SHARED_PTR_USE_BOOST)
IF(CXX11_COMPILER_FLAGS AND VMIME_HAS_CXX11_SHARED_PTR)
# If std::shared_ptr<> is available, use it by default
SET(VMIME_SHARED_PTR_USE_CXX_DEFAULT ON)
SET(VMIME_SHARED_PTR_USE_BOOST_DEFAULT OFF)
ELSE()
# Else, set default to boost::shared_ptr<>
SET(VMIME_SHARED_PTR_USE_CXX_DEFAULT OFF)
SET(VMIME_SHARED_PTR_USE_BOOST_DEFAULT ON)
ENDIF()
ENDIF()

OPTION(
VMIME_SHARED_PTR_USE_CXX
"Use standard std::shared_ptr<> (requires a C++11 compiler)"
${VMIME_SHARED_PTR_USE_CXX_DEFAULT}
)

OPTION(
VMIME_SHARED_PTR_USE_BOOST
"Use boost::shared_ptr<> (requires Boost)"
${VMIME_SHARED_PTR_USE_BOOST_DEFAULT}
)

IF(VMIME_SHARED_PTR_USE_CXX AND VMIME_SHARED_PTR_USE_BOOST)
MESSAGE(FATAL_ERROR "Options VMIME_SHARED_PTR_USE_CXX and VMIME_SHARED_PTR_USE_BOOST are mutually exclusive (select one or the other, but not both!)")
ENDIF()

IF(VMIME_SHARED_PTR_USE_CXX)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}")

IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
ENDIF()

MESSAGE(STATUS "Checking support for shared_ptr<>: built-in (C++11)")

ELSEIF(VMIME_SHARED_PTR_USE_BOOST)

# Depends on Boost library if C++11 is not supported
FIND_PACKAGE(Boost)

IF(Boost_FOUND)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
ELSE()
MESSAGE(FATAL_ERROR "Boost library is required for shared_ptr<>, unless you compile using C++11")
ENDIF()

MESSAGE(STATUS "Checking support for shared_ptr<>: boost library")

ELSE()

MESSAGE(FATAL_ERROR "No implementation for shared_ptr<> was selected/found")

ENDIF()


##############################################################################
# Platform

@@ -997,12 +931,12 @@ IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")

SET(
CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -D_REENTRANT=1 -W -Wall -pedantic -Warray-bounds-pointer-arithmetic -Wold-style-cast -Wconversion -Wcast-align -Wno-sign-conversion"
"-D_REENTRANT=1 -W -Wall -pedantic -Warray-bounds-pointer-arithmetic -Wold-style-cast -Wconversion -Wcast-align -Wno-sign-conversion ${CMAKE_CXX_FLAGS}"
)

SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
SET(CMAKE_CXX_FLAGS_RELEASE "-O2 ${CMAKE_CXX_FLAGS_RELEASE}")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 ${CMAKE_CXX_FLAGS_DEBUG}")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")

#SET(CMAKE_EXE_LINKER_FLAGS "-s")

@@ -1012,12 +946,12 @@ ELSE()

SET(
CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -D_REENTRANT=1 -W -Wall -pedantic -Wpointer-arith -Wold-style-cast -Wconversion -Wcast-align -Wno-long-long"
"-D_REENTRANT=1 -W -Wall -pedantic -Wpointer-arith -Wold-style-cast -Wconversion -Wcast-align -Wno-long-long ${CMAKE_CXX_FLAGS}"
)

SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
SET(CMAKE_CXX_FLAGS_RELEASE "-O2 ${CMAKE_CXX_FLAGS_RELEASE}")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 ${CMAKE_CXX_FLAGS_DEBUG}")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")

#SET(CMAKE_EXE_LINKER_FLAGS "-s")

94 HACKING
@@ -80,73 +80,91 @@ width to its preferred settings (eg. 4 or 8 spaces).
2.2. Brace position
-------------------

Open braces should always be at the beginning of the line after the statement
that begins the block. Contents of the brace should be indented by 1 tab.
Open braces should always be at the end of the line of the statement that
begins the block. Contents of the brace should be indented by 1 tab.

if (expr) {

if (expr)
{
do_something();
do_another_thing();
}
else
{

} else {

do_something_else();
}

In a function, the opening brace must always be followed by an empty line:

void header::appendField(const shared_ptr <headerField>& field) {

m_fields.push_back(field);
}

A function with few arguments:

bool header::hasField(const string& fieldName) const {

...
}

A function with more arguments:

void header::parseImpl(
const parsingContext& ctx,
const string& buffer,
const size_t position,
const size_t end,
size_t* newPosition
) {

...
}


2.3. "switch" statement
-----------------------

switch (expr)
{
case 0:
switch (expr) {

something;
break;
case 0:

case 1:
something;
break;

something_else;
break;
case 1:

case 2:
{
int var = 42;
another_thing;
break;
}
something_else;
break;

case 2: {

int var = 42;
another_thing;
break;
}
}


2.4. Single instruction
-----------------------

Omit braces around simple single-statement body:
Don't omit braces around simple single-statement body:

if (...)
if (...) {
something;
}

and not:

if (...)
{
something;
}

Except when body spans over multiple lines:

if (...)
{
something_too_long_for(
a_single_line);
}


2.5. Line length
----------------

Each line of text should not exceed 80 characters.
If possible, each line of text should not exceed 100 characters, except if
manual line wrapping breaks code clarity.

Exception: if a comment line contains an example command or a literal URL
longer than 100 characters, that line may be longer than 100 characters
@@ -290,8 +308,8 @@ Where ever possible, place comments above the code instead of beside it.
Comments can be placed at the end of a line when one or more spaces follow.
Tabs should NOT be used to indent at the end of a line:

class myClass
{
class myClass {

private:

int m_member1; // first member
@@ -322,8 +340,8 @@ the purpose of the functions/classes and the meaning of the parameters.

* No more than one class per file (except for inner classes).

* Put the inclusion for the class's header file as the first inclusion in
the implementation file.
* Put the #include for the class's header file first in the implementation
file.

* Put the copyright header at the top of each file.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 71968d9

Please sign in to comment.
You can’t perform that action at this time.