Skip to content

Commit

Permalink
Merge pull request #226 from dforsten/df-xcode-fix
Browse files Browse the repository at this point in the history
Fix for cmake-conan issue #225 - Compile error on configuration on MacOS
  • Loading branch information
czoido authored Sep 3, 2020
2 parents aff58ee + 86920da commit 7c35072
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
6 changes: 5 additions & 1 deletion conan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,13 @@ function(conan_cmake_detect_unix_libcxx result)

separate_arguments(SPLIT_CXX_FLAGS NATIVE_COMMAND ${CMAKE_CXX_FLAGS})

if(CMAKE_OSX_SYSROOT)
set(xcode_sysroot_option "--sysroot=${CMAKE_OSX_SYSROOT}")
endif()

execute_process(
COMMAND ${CMAKE_COMMAND} -E echo "#include <string>"
COMMAND ${EXPAND_CXX_COMPILER} ${SPLIT_CXX_FLAGS} -x c++ ${compile_options} -E -dM -
COMMAND ${EXPAND_CXX_COMPILER} ${SPLIT_CXX_FLAGS} -x c++ ${xcode_sysroot_option} ${compile_options} -E -dM -
OUTPUT_VARIABLE string_defines
)

Expand Down
24 changes: 24 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,30 @@ def tearDown(self):
os.environ.clear()
os.environ.update(self.old_env)

# https://github.com/conan-io/cmake-conan/issues/159
@unittest.skipIf(platform.system() != "Darwin", "Error message appears just in Macos")
def test_macos_sysroot_warning(self):
content = textwrap.dedent("""
cmake_minimum_required(VERSION 2.8)
project(FormatOutput CXX)
set(CMAKE_CXX_STANDARD 11)
include(conan.cmake)
conan_cmake_run(REQUIRES fmt/6.1.2
BASIC_SETUP
BUILD missing)
add_executable(main main.cpp)
target_link_libraries(main ${CONAN_LIBS})
""")
save("CMakeLists.txt", content)

os.makedirs("build")
os.chdir("build")
run("cmake .. %s -DCMAKE_BUILD_TYPE=Release 2> stderr_output.txt" % generator)
with open('stderr_output.txt', 'r') as file:
data = file.read()
assert "#include_next <string.h>" not in data

def test_conan_add_remote(self):
content = textwrap.dedent("""
cmake_minimum_required(VERSION 2.8)
Expand Down

0 comments on commit 7c35072

Please sign in to comment.