Skip to content

Commit

Permalink
Merge branch 'conan-io:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Prometee authored Dec 13, 2023
2 parents d7a6576 + 2041702 commit b0ff03b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions conan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function(conan_cmake_settings result)

if(NOT _SETTINGS OR ARGUMENTS_PROFILE_AUTO STREQUAL "ALL")
set(ARGUMENTS_PROFILE_AUTO arch build_type compiler compiler.version
compiler.runtime compiler.libcxx compiler.toolset)
compiler.runtime compiler.libcxx compiler.toolset os)
endif()

# remove any manually specified settings from the autodetected settings
Expand Down Expand Up @@ -482,7 +482,7 @@ endfunction()
function(_collect_settings result)
set(ARGUMENTS_PROFILE_AUTO arch build_type compiler compiler.version
compiler.runtime compiler.libcxx compiler.toolset
compiler.cppstd)
compiler.cppstd os)
foreach(ARG ${ARGUMENTS_PROFILE_AUTO})
string(TOUPPER ${ARG} _arg_name)
string(REPLACE "." "_" _arg_name ${_arg_name})
Expand Down
30 changes: 30 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,36 @@ def tearDown(self):
os.environ.clear()
os.environ.update(self.old_env)

# https://github.com/conan-io/cmake-conan/pull/420
def test_conan_cmake_autodetect_os(self):
content = textwrap.dedent("""
cmake_minimum_required(VERSION 3.9)
project(FormatOutput CXX)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
include(conan.cmake)
conan_cmake_configure(REQUIRES fmt/6.1.2 GENERATORS cmake_find_package)
conan_cmake_autodetect(settings)
conan_cmake_install(PATH_OR_REFERENCE .
BUILD missing
REMOTE conancenter
SETTINGS ${settings})
""")
save("CMakeLists.txt", content)
empty_profile = textwrap.dedent("""
[settings]
build_type=Release
arch=x86_64
""")
save(os.path.join(os.environ.get("CONAN_USER_HOME"), ".conan", "profiles", "default"), empty_profile)
os.makedirs("build")
os.chdir("build")
run("cmake .. {} -DCMAKE_BUILD_TYPE=Release > output.txt".format(generator))
with open('output.txt', 'r') as file:
data = file.read()
the_os = {'Darwin': 'Macos'}.get(platform.system(), platform.system())
assert f"os={the_os}" in data

# https://github.com/conan-io/cmake-conan/issues/279
def test_options_override_profile(self):
content = textwrap.dedent("""
Expand Down

0 comments on commit b0ff03b

Please sign in to comment.