2018-03-27 20:52:14 +02:00
|
|
|
macro(setup_conan)
|
2020-04-23 16:02:12 +02:00
|
|
|
find_program(conan conan PATHS /usr/bin /usr/local/bin)
|
2018-03-27 20:52:14 +02:00
|
|
|
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)
|
|
|
|
set(compiler_libcxx libstdc++11)
|
|
|
|
|
|
|
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
|
|
|
set(CONAN_BUILD_TYPE Debug)
|
|
|
|
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
|
|
|
|
set(CONAN_BUILD_TYPE Release)
|
|
|
|
else()
|
|
|
|
set(CONAN_BUILD_TYPE ${CMAKE_BUILD_TYPE})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
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)
|
|
|
|
if(NOT ${return_code} EQUAL 0)
|
|
|
|
message(FATAL_ERROR "conan install command failed.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include(${conanfile_cmake})
|
2018-04-27 19:35:45 +02:00
|
|
|
conan_basic_setup()
|
2018-03-27 20:52:14 +02:00
|
|
|
endmacro()
|