Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow project options to be used in creation of a conan package. #122

Merged
merged 4 commits into from
Apr 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
82 changes: 46 additions & 36 deletions src/Conan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,46 +33,56 @@ macro(run_conan)
URL
https://bincrafters.jfrog.io/artifactory/api/conan/public-conan)

# For multi configuration generators, like VS and XCode
if(NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Single configuration build!")
set(LIST_OF_BUILD_TYPES ${CMAKE_BUILD_TYPE})
if(CONAN_EXPORTED)
aminya marked this conversation as resolved.
Show resolved Hide resolved
# standard conan installation, in which deps will be defined in conanfile. It is not necessary to call conan again, as it is already running.
if (EXISTS "${CMAKE_BINARY_DIR}/../conanbuildinfo.cmake")
include(${CMAKE_BINARY_DIR}/../conanbuildinfo.cmake)
else()
message(FATAL_ERROR "Could not set up conan because \"${CMAKE_BINARY_DIR}/../conanbuildinfo.cmake\" does not exist")
endif()
conan_basic_setup()
aminya marked this conversation as resolved.
Show resolved Hide resolved
else()
message(STATUS "Multi-configuration build: '${CMAKE_CONFIGURATION_TYPES}'!")
set(LIST_OF_BUILD_TYPES ${CMAKE_CONFIGURATION_TYPES})
endif()
# For multi configuration generators, like VS and XCode
if(NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Single configuration build!")
set(LIST_OF_BUILD_TYPES ${CMAKE_BUILD_TYPE})
else()
message(STATUS "Multi-configuration build: '${CMAKE_CONFIGURATION_TYPES}'!")
set(LIST_OF_BUILD_TYPES ${CMAKE_CONFIGURATION_TYPES})
endif()

is_verbose(_is_verbose)
if(NOT ${_is_verbose})
set(OUTPUT_QUIET "OUTPUT_QUIET")
else()
set(OUTPUT_QUIET OFF)
endif()
is_verbose(_is_verbose)
if(NOT ${_is_verbose})
set(OUTPUT_QUIET "OUTPUT_QUIET")
else()
set(OUTPUT_QUIET OFF)
endif()

foreach(TYPE ${LIST_OF_BUILD_TYPES})
message(STATUS "Running Conan for build type '${TYPE}'")
foreach(TYPE ${LIST_OF_BUILD_TYPES})
message(STATUS "Running Conan for build type '${TYPE}'")

# Detects current build settings to pass into conan
conan_cmake_autodetect(settings BUILD_TYPE ${TYPE})
# Detects current build settings to pass into conan
conan_cmake_autodetect(settings BUILD_TYPE ${TYPE})

# PATH_OR_REFERENCE ${CMAKE_SOURCE_DIR} is used to tell conan to process
# the external "conanfile.py" provided with the project
# Alternatively a conanfile.txt could be used
conan_cmake_install(
PATH_OR_REFERENCE
${CMAKE_SOURCE_DIR}
BUILD
missing
# Pass compile-time configured options into conan
OPTIONS
${ProjectOptions_CONAN_OPTIONS}
# Pass CMake compilers to Conan
ENV
"CC=${CMAKE_C_COMPILER}"
"CXX=${CMAKE_CXX_COMPILER}"
SETTINGS
${settings}
${OUTPUT_QUIET})
endforeach()
# PATH_OR_REFERENCE ${CMAKE_SOURCE_DIR} is used to tell conan to process
# the external "conanfile.py" provided with the project
# Alternatively a conanfile.txt could be used
conan_cmake_install(
PATH_OR_REFERENCE
${CMAKE_SOURCE_DIR}
BUILD
missing
# Pass compile-time configured options into conan
OPTIONS
${ProjectOptions_CONAN_OPTIONS}
# Pass CMake compilers to Conan
ENV
"CC=${CMAKE_C_COMPILER}"
"CXX=${CMAKE_CXX_COMPILER}"
SETTINGS
${settings}
${OUTPUT_QUIET})
endforeach()
endif()

endmacro()