2017-10-26 11:41:35 +02:00
|
|
|
macro(setup_conan)
|
|
|
|
find_program(conan conan)
|
|
|
|
if(NOT EXISTS ${conan})
|
|
|
|
message(FATAL_ERROR "Conan is required. Please see README.md")
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Darwin)
|
|
|
|
set(os Macos)
|
|
|
|
else()
|
|
|
|
set(os ${CMAKE_HOST_SYSTEM_NAME})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
|
|
|
|
set(compiler gcc)
|
|
|
|
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL AppleClang)
|
|
|
|
set(compiler apple-clang)
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
string(SUBSTRING ${CMAKE_CXX_COMPILER_VERSION} 0 3 compiler_version)
|
|
|
|
|
|
|
|
set(conanfile ${CMAKE_SOURCE_DIR}/conanfile.txt)
|
|
|
|
set(conanfile_cmake ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
2017-11-16 00:37:10 +01:00
|
|
|
set(compiler_libcxx libstdc++11)
|
2017-10-26 11:41:35 +02:00
|
|
|
|
2017-12-31 11:56:09 +01:00
|
|
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
|
|
|
set(CONAN_BUILD_TYPE Debug)
|
|
|
|
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
|
|
|
|
set(CONAN_BUILD_TYPE Release)
|
2017-10-26 11:41:35 +02:00
|
|
|
else()
|
2017-12-31 11:56:09 +01:00
|
|
|
set(CONAN_BUILD_TYPE ${CMAKE_BUILD_TYPE})
|
2017-10-26 11:41:35 +02:00
|
|
|
endif()
|
2017-12-31 11:56:09 +01:00
|
|
|
|
|
|
|
execute_process(COMMAND ${conan} install --build=missing
|
|
|
|
-s build_type=${CONAN_BUILD_TYPE} -s compiler.libcxx=${compiler_libcxx}
|
|
|
|
${CMAKE_SOURCE_DIR} RESULT_VARIABLE return_code)
|
2017-10-26 11:41:35 +02:00
|
|
|
if(NOT ${return_code} EQUAL 0)
|
|
|
|
message(FATAL_ERROR "conan install command failed.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include(${conanfile_cmake})
|
2018-04-06 02:45:11 +02:00
|
|
|
#conan_basic_setup(TARGETS)
|
|
|
|
conan_basic_setup()
|
2017-12-31 11:56:09 +01:00
|
|
|
endmacro()
|