Skip to content

Commit

Permalink
Merge branch 'modern-cmake' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
saschazelzer committed Jan 19, 2017
2 parents 70371ef + dc70906 commit 916bbc9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Extract the current version from the VERSION file
file(STRINGS VERSION _version LIMIT_COUNT 1)

set(US_CMAKE_MINIMUM_REQUIRED_VERSION 3.1)
set(US_CMAKE_MINIMUM_REQUIRED_VERSION 3.2)

cmake_minimum_required(VERSION ${US_CMAKE_MINIMUM_REQUIRED_VERSION})

Expand Down Expand Up @@ -31,6 +31,8 @@ endforeach()
#------------------------------------------------------------------------------

set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED 1)
set(CMAKE_CXX_STANDARD 11)

# We make use of the following C++11 language and library features:
#
Expand Down Expand Up @@ -267,6 +269,7 @@ endif()
#-----------------------------------------------------------------------------

set(US_HAVE_VISIBILITY_ATTRIBUTE 0)
set(US_CXX11_FLAGS )
set(US_CXX_TSAN_FLAGS )
set(US_TSAN_LINK_FLAGS )

Expand Down
35 changes: 21 additions & 14 deletions doc/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
# [prj-start]
project(CppMicroServicesExamples)

set(CMAKE_CXX_STANDARD_REQUIRED 1)
set(CMAKE_CXX_STANDARD 11)

find_package(CppMicroServices NO_MODULE REQUIRED)

cmake_minimum_required(VERSION ${US_CMAKE_MINIMUM_REQUIRED_VERSION})
cmake_policy(VERSION ${US_CMAKE_MINIMUM_REQUIRED_VERSION})

include_directories(${CppMicroServices_INCLUDE_DIRS})
# [prj-end]

#-----------------------------------------------------------------------------
# Set C/CXX flags
#-----------------------------------------------------------------------------

if(${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${US_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${US_CXX_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${US_CXX_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${US_C_FLAGS}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${US_C_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${US_C_FLAGS_DEBUG}")
endif()

#-----------------------------------------------------------------------------
# Init output directories
Expand Down Expand Up @@ -136,6 +125,7 @@ if(US_BUILD_TESTING)
COMMAND ${CMAKE_COMMAND}
-D CMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
-D CMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
"-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}"
-D US_BUILD_SHARED_LIBS:BOOL=${US_BUILD_SHARED_LIBS}
-G ${CMAKE_GENERATOR}
"-DCppMicroServices_DIR:PATH=${_install_dir}/${AUXILIARY_CMAKE_INSTALL_DIR}"
Expand All @@ -157,6 +147,7 @@ if(US_BUILD_TESTING)
COMMAND ${CMAKE_COMMAND}
-D CMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-D CMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
"-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}"
-D CMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
-D US_BUILD_SHARED_LIBS:BOOL=${US_BUILD_SHARED_LIBS}
-G ${CMAKE_GENERATOR}
Expand All @@ -177,6 +168,22 @@ if(US_BUILD_TESTING)
# The makefile is Linux specific, so only try to build the Makefile example
# if we are on a proper system
if(UNIX AND NOT APPLE AND US_BUILD_SHARED_LIBS)

# We need to supply the correct language flag to the Makefile
set(US_CXX11_FLAGS -std=c++11)
usFunctionCheckCompilerFlags(${US_CXX11_FLAGS} _have_cxx11)
if(_have_cxx11)
set(US_CXX_FLAGS "${US_CXX_FLAGS} ${US_CXX11_FLAGS}")
else()
set(US_CXX11_FLAGS -std=c++0x)
usFunctionCheckCompilerFlags(${US_CXX11_FLAGS} _have_cxx0x)
if(_have_cxx0x)
set(US_CXX_FLAGS "${US_CXX_FLAGS} ${US_CXX11_FLAGS}")
else()
set(US_CXX11_FLAGS )
endif()
endif()

find_program(MAKE_COMMAND NAMES make gmake)
find_program(CXX_COMMAND NAMES g++)
mark_as_advanced(MAKE_COMMAND CXX_COMMAND)
Expand Down
2 changes: 1 addition & 1 deletion doc/src/build_instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ project or *Make* files.
Prerequisites
-------------

- `CMake <http://www.cmake.org>`_ 3.1 (users of the latest Visual Studio
- `CMake <http://www.cmake.org>`_ 3.2 (users of the latest Visual Studio
should typically also use the latest CMake version available)

Configuration
Expand Down
11 changes: 6 additions & 5 deletions install_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ if [ ! -d "$HOME/cache" ]; then
mkdir $HOME/cache;
fi

# check to see if CMake is cached
if [ ! -f "$HOME/cache/bin/ctest" ]; then
CTEST_EXEC="$HOME/cache/bin/ctest"

wget --no-check-certificate https://cmake.org/files/v3.1/cmake-3.1.3.tar.gz -O /tmp/cmake.tar.gz;
# check to see if CMake is cached
if [[ ! -f "$CTEST_EXEC" || ! "$($CTEST_EXEC --version)" =~ "3.2.3" ]]; then
wget --no-check-certificate https://cmake.org/files/v3.2/cmake-3.2.3.tar.gz -O /tmp/cmake.tar.gz;
tar -xzvf /tmp/cmake.tar.gz -C /tmp;
cd /tmp/cmake-3.1.3;
cd /tmp/cmake-3.2.3;
./configure --prefix=$HOME/cache;
make -j;
make -j2;
make install;
else
echo "Using cached bin dir: $HOME/cache/bin";
Expand Down

0 comments on commit 916bbc9

Please sign in to comment.