Skip to content

Commit

Permalink
Merge pull request #536 from ssrobins/fix-find-package
Browse files Browse the repository at this point in the history
Ensure that Find<PackageName>.cmake modules work
  • Loading branch information
memsharded authored Jul 18, 2023
2 parents fe161a7 + 7a76da3 commit 2a5625b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion conan_provider.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ macro(conan_provide_dependency package_name)
if(${index} EQUAL -1)
list(PREPEND CMAKE_PREFIX_PATH "${CONAN_GENERATORS_FOLDER}")
endif()
find_package(${ARGN} BYPASS_PROVIDER CMAKE_FIND_ROOT_PATH_BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
find_package(${ARGN} BYPASS_PROVIDER)
endmacro()


Expand Down
5 changes: 5 additions & 0 deletions tests/resources/cmake_module/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.24)
project(MyApp CXX)

set(CMAKE_CXX_STANDARD 17)
find_package(Threads REQUIRED)
17 changes: 16 additions & 1 deletion tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@ def test_reconfigure_on_conanfile_changes(self, capfd, chdir_build):
assert all(expected in out for expected in expected_conan_install_outputs)


class TestCmakeModule:
@pytest.fixture(scope="class", autouse=True)
def cmake_module_setup(self):
src_dir = Path(__file__).parent.parent
shutil.copytree(src_dir / 'tests' / 'resources' / 'cmake_module', ".", dirs_exist_ok=True)
yield

def test_cmake_module(self, capfd, chdir_build):
"Ensure that the Find<PackageName>.cmake modules from the CMake install work"
run("cmake .. -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=conan_provider.cmake -DCMAKE_BUILD_TYPE=Release")
out, _ = capfd.readouterr()
assert "Found Threads: TRUE" in out


class TestSubdir:
@pytest.fixture(scope="class", autouse=True)
def subdir_setup(self):
Expand Down Expand Up @@ -177,7 +191,8 @@ def test_no_os_version(self, capfd, chdir_build):
class TestAndroid:
@pytest.fixture(scope="class", autouse=True)
def android_setup(self):
shutil.rmtree("build")
if os.path.exists("build"):
shutil.rmtree("build")
yield

def test_android_armv8(self, capfd, chdir_build):
Expand Down

0 comments on commit 2a5625b

Please sign in to comment.