Skip to content

Commit

Permalink
working, improving settings conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
memsharded committed May 4, 2016
1 parent 1ab2db2 commit 421d044
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -29,4 +29,5 @@

build/
*.pyc
.conan
.conan
.idea
6 changes: 3 additions & 3 deletions CMakeLists.txt
Expand Up @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 2.8)
project(conan_wrapper C CXX)

include(conan.cmake)
conan_requirements(REQUIRES Poco/1.7.2@lasote/stable
OPTIONS Poco:shared=False
conan_requirements(REQUIRES Hello/0.1@memsharded/testing
BUILD_DIR ${CMAKE_SOURCE_DIR}/.conan
BASIC_SETUP)
BASIC_SETUP
BUILD missing)

add_executable(main main.cpp)
target_link_libraries(main ${CONAN_LIBS})
66 changes: 51 additions & 15 deletions conan.cmake
@@ -1,25 +1,56 @@
include(CMakeParseArguments)

function(conan_install_settings result)
# message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER})
# message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER_ID})
# message(STATUS "VERSION " ${CMAKE_CXX_COMPILER_VERSION})
#message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER})
#message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER_ID})
#message(STATUS "VERSION " ${CMAKE_CXX_COMPILER_VERSION})
# message(STATUS "FLAGS " ${CMAKE_LANG_FLAGS})
# message(STATUS "LIB ARCH " ${CMAKE_CXX_LIBRARY_ARCHITECTURE})
# message(STATUS "BUILD TYPE " ${CMAKE_BUILD_TYPE})
# message(STATUS "GENERATOR " ${CMAKE_GENERATOR})
# message(STATUS "GENERATOR WIN64 " ${CMAKE_CL_64})
set(SETTINGS_STR "")
if(${CMAKE_GENERATOR} MATCHES "Visual Studio 14")
#message(STATUS "LIB ARCH " ${CMAKE_CXX_LIBRARY_ARCHITECTURE})
#message(STATUS "BUILD TYPE " ${CMAKE_BUILD_TYPE})
#message(STATUS "GENERATOR " ${CMAKE_GENERATOR})
#message(STATUS "GENERATOR WIN64 " ${CMAKE_CL_64})

if(CMAKE_BUILD_TYPE)
set(SETTINGS_STR -s build_type=${CMAKE_BUILD_TYPE})
else()
message(FATAL_ERROR "Please specify in command line CMAKE_BUILD_TYPE (-DCMAKE_BUILD_TYPE=Release)")
endif()


if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
# using GCC
set(SETTINGS_STR -s compiler=gcc -s compiler.version=4.9 -s compiler.libcxx=libstdc++)
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
set(_VISUAL "Visual Studio")
set(SETTINGS_STR -s compiler=${_VISUAL} -s compiler.version=14)
if(${CMAKE_CL_64})
set(SETTINGS_STR ${SETTINGS_STR} -s arch=x86_64)
# FIXME: Crappy, poor check
if (${CMAKE_GENERATOR} MATCHES "Visual Studio 14")
set(SETTINGS_STR -s compiler=${_VISUAL} -s compiler.version=14)
elseif (${CMAKE_GENERATOR} MATCHES "Visual Studio 12")
set(SETTINGS_STR -s compiler=${_VISUAL} -s compiler.version=12)
elseif (${CMAKE_GENERATOR} MATCHES "Visual Studio 11")
set(SETTINGS_STR -s compiler=${_VISUAL} -s compiler.version=11)
elseif (${CMAKE_GENERATOR} MATCHES "Visual Studio 10")
set(SETTINGS_STR -s compiler=${_VISUAL} -s compiler.version=10)
elseif (${CMAKE_GENERATOR} MATCHES "Visual Studio 9")
set(SETTINGS_STR -s compiler=${_VISUAL} -s compiler.version=9)
else ()
message(FATAL_ERROR "Visual Studio not recognized")
endif()

if(${CMAKE_GENERATOR} MATCHES "Win64")
set(SETTINGS_STR ${SETTINGS_STR} -s arch=x86_64)
elseif (${CMAKE_GENERATOR} MATCHES "ARM")
message(STATUS "Conan: Using default ARM architecture from MSVC")
set(SETTINGS_STR ${SETTINGS_STR} -s arch=armv6)
else()
set(SETTINGS_STR ${SETTINGS_STR} -s arch=x86)
set(SETTINGS_STR ${SETTINGS_STR} -s arch=x86)
endif()

set(SETTINGS_STR ${SETTINGS_STR} -s compiler.runtime=MD)
else()
message(FATAL_ERROR "Conan: compiler setup not recognized")
endif()
set(SETTINGS_STR ${SETTINGS_STR} -s build_type=Release -s compiler.runtime=MD)

set(${result} ${SETTINGS_STR} PARENT_SCOPE)
endfunction()

Expand All @@ -36,13 +67,18 @@ function(conan_execute_install)
else()
set(CONAN_RUN_DIR ${CMAKE_BINARY_DIR})
endif()
if(CONANFILE_BUILD)
set(CONAN_BUILD_POLICY "--build=${CONANFILE_BUILD}")
else()
set(CONAN_BUILD_POLICY "")
endif()
if(CONANFILE_CONAN_COMMAND)
set(conan_command ${CONANFILE_CONAN_COMMAND})
else()
set(conan_command "conan")
endif()

set(conan_args install ${CONAN_RUN_DIR} ${settings})
set(conan_args install ${CONAN_RUN_DIR} ${settings} ${CONAN_BUILD_POLICY})

add_custom_target(conan_install
COMMAND ${conan_command} ${conan_args}
Expand Down
10 changes: 8 additions & 2 deletions main.cpp
@@ -1,4 +1,10 @@
#include "Poco/Timer.h"
#include "hello.h"

int main(){
hello();
}

/*#include "Poco/Timer.h"
#include "Poco/Thread.h"
#include "Poco/Stopwatch.h"
#include <iostream>
Expand Down Expand Up @@ -27,4 +33,4 @@ int main(int argc, char** argv){
Thread::sleep(1000);
timer.stop();
return 0;
}
}*/

0 comments on commit 421d044

Please sign in to comment.