Skip to content

Commit

Permalink
merged master
Browse files Browse the repository at this point in the history
  • Loading branch information
memsharded committed Dec 4, 2017
2 parents b134d5e + 78b3594 commit c442813
Show file tree
Hide file tree
Showing 6 changed files with 261 additions and 117 deletions.
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
language: python
python:
- 2.7
- 3.6
os: linux
sudo: required
dist: trusty

env:
matrix:
- CONAN_COMPILER=gcc CONAN_COMPILER_VERSION=4.8

matrix:
include:
- os: osx
osx_image: xcode8.3 # apple-clang 8.1
language: generic


install:
- chmod +x .travis/install.sh
- ./.travis/install.sh

script:
- chmod +x .travis/run.sh
- ./.travis/run.sh
24 changes: 24 additions & 0 deletions .travis/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -e
set -x

if [[ "$(uname -s)" == 'Darwin' ]]; then
brew update || brew update
brew outdated pyenv || brew upgrade pyenv
brew install pyenv-virtualenv
brew install cmake || true

if which pyenv > /dev/null; then
eval "$(pyenv init -)"
fi

pyenv install 2.7.10
pyenv virtualenv 2.7.10 conan
pyenv rehash
pyenv activate conan
fi

pip install conan
conan user
pip install nose
11 changes: 11 additions & 0 deletions .travis/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set -e
set -x

if [[ "$(uname -s)" == 'Darwin' ]]; then
if which pyenv > /dev/null; then
eval "$(pyenv init -)"
fi
pyenv activate conan
fi

nosetests .
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

[![Build status](https://ci.appveyor.com/api/projects/status/0y2994lfwcpw9232/branch/master?svg=true)](https://ci.appveyor.com/project/ConanCIintegration/cmake-conan/branch/master)

CMake wrapper for conan C and C++ package manager
[![Build Status](https://travis-ci.org/conan-io/cmake-conan.svg?branch=master)](https://travis-ci.org/conan-io/cmake-conan)

** Testing required **: This tools is still experimental, please try and contribute, specially with the extraction of settings from cmake.
CMake wrapper for the Conan C and C++ package manager.

**Testing required**: This tools is still experimental, please try and contribute, specially with the extraction of settings from cmake.

This cmake code allows to launch ``conan install`` from cmake.

It can be used this way:
This cmake module allows to launch ``conan install`` from cmake.

It can be used in this way:


```cmake
Expand Down Expand Up @@ -70,5 +72,3 @@ There are some tests, you can run in python, with nosetests, for example:
```bash
$ nosetests . --nocapture
```

If there are enough interest, I will set up CI with travis & appveyor
56 changes: 44 additions & 12 deletions conan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,21 @@ function(conan_cmake_settings result)
list(GET VERSION_LIST 1 MINOR)
set(_SETTINGS ${_SETTINGS} -s compiler=apple-clang -s compiler.version=${MAJOR}.${MINOR} -s compiler.libcxx=libc++)
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
# using Clang
string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
list(GET VERSION_LIST 0 MAJOR)
list(GET VERSION_LIST 1 MINOR)
set(_SETTINGS ${_SETTINGS} -s compiler=clang -s compiler.version=${MAJOR}.${MINOR} -s compiler.libcxx=libstdc++)
if(APPLE)
cmake_policy(GET CMP0025 APPLE_CLANG_POLICY_ENABLED)
if(NOT APPLE_CLANG_POLICY_ENABLED)
message(STATUS "Conan: APPLE and Clang detected. Assuming apple-clang compiler. Set CMP0025 to avoid it")
set(_SETTINGS ${_SETTINGS} -s compiler=apple-clang -s compiler.version=${MAJOR}.${MINOR} -s compiler.libcxx=libc++)
else()
set(_SETTINGS ${_SETTINGS} -s compiler=clang -s compiler.version=${MAJOR}.${MINOR} -s compiler.libcxx=libstdc++)
endif()
else()
conan_cmake_detect_gnu_libcxx(_LIBCXX)
set(_SETTINGS ${_SETTINGS} -s compiler=clang -s compiler.version=${MAJOR}.${MINOR} -s compiler.libcxx=${_LIBCXX})
endif()
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
set(_VISUAL "Visual Studio")
_get_msvc_ide_version(_VISUAL_VERSION)
Expand Down Expand Up @@ -165,33 +175,55 @@ endfunction()


macro(parse_arguments)
set(options BASIC_SETUP CMAKE_TARGETS)
set(oneValueArgs BUILD CONANFILE)
set(multiValueArgs REQUIRES OPTIONS IMPORTS CONAN_COMMAND)
set(options BASIC_SETUP CMAKE_TARGETS UPDATE)
set(oneValueArgs CONANFILE DEBUG_PROFILE RELEASE_PROFILE PROFILE)
set(multiValueArgs REQUIRES OPTIONS IMPORTS BUILD CONAN_COMMAND)
cmake_parse_arguments(ARGUMENTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
endmacro()

function(conan_cmake_install)
# Calls "conan install"
# Argument BUILD is equivalant to --build={missing, PkgName,...}
# Argument BUILD is equivalant to --build={missing, PkgName,...} or
# --build when argument is 'BUILD all' (which builds all packages from source)
# Argument CONAN_COMMAND, to specify the conan path, e.g. in case of running from source
# cmake does not identify conan as command, even if it is +x and it is in the path
parse_arguments(${ARGV})

if(ARGUMENTS_BUILD)
set(CONAN_BUILD_POLICY --build=${ARGUMENTS_BUILD})
else()
set(CONAN_BUILD_POLICY "")
endif()
set(CONAN_BUILD_POLICY "")
foreach(ARG ${ARGUMENTS_BUILD})
if(${ARG} STREQUAL "all")
set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build)
break()
else()
set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build=${ARG})
endif()
endforeach()
if(ARGUMENTS_CONAN_COMMAND)
set(conan_command ${ARGUMENTS_CONAN_COMMAND})
else()
set(conan_command conan)
endif()
set(CONAN_OPTIONS "")
if(ARGUMENTS_CONANFILE)
set(CONANFILE -f=${CMAKE_CURRENT_SOURCE_DIR}/${ARGUMENTS_CONANFILE})
# A conan file has been specified - apply specified options as well if provided
foreach(ARG ${ARGUMENTS_OPTIONS})
set(CONAN_OPTIONS ${CONAN_OPTIONS} -o ${ARG})
endforeach()
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND ARGUMENTS_DEBUG_PROFILE)
set(settings -pr ${ARGUMENTS_DEBUG_PROFILE})
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release" AND ARGUMENTS_RELEASE_PROFILE)
set(settings -pr ${ARGUMENTS_RELEASE_PROFILE})
endif()
if(ARGUMENTS_PROFILE)
set(settings -pr ${ARGUMENTS_PROFILE})
endif()
if(ARGUMENTS_UPDATE)
set(CONAN_INSTALL_UPDATE --update)
endif()
set(conan_args install ${CONANFILE} ${settings} ${CONAN_BUILD_POLICY})
set(conan_args install ${CONANFILE} ${settings} ${CONAN_BUILD_POLICY} ${CONAN_INSTALL_UPDATE} ${CONAN_OPTIONS})

string (REPLACE ";" " " _conan_args "${conan_args}")
message(STATUS "Conan executing: ${conan_command} ${_conan_args}")
Expand Down
Loading

0 comments on commit c442813

Please sign in to comment.