diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index dd1fedb0..150fc98c 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -7,4 +7,4 @@ set(CMAKE_CXX_STANDARD 14) find_package(fmt REQUIRED) add_executable(main main.cpp) -target_link_libraries(main PRIVATE fmt::fmt) \ No newline at end of file +target_link_libraries(main PRIVATE fmt::fmt) diff --git a/example/conanfile.txt b/example/conanfile.txt index e83f3c89..85f12618 100644 --- a/example/conanfile.txt +++ b/example/conanfile.txt @@ -2,4 +2,4 @@ fmt/9.1.0 [layout] -cmake_layout \ No newline at end of file +cmake_layout diff --git a/tests/resources/try_compile/CMakeLists.txt b/tests/resources/try_compile/CMakeLists.txt new file mode 100644 index 00000000..d0915873 --- /dev/null +++ b/tests/resources/try_compile/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.24) + +project(FormatOutput LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 14) + +find_package(fmt REQUIRED) + +add_executable(main main.cpp) +target_link_libraries(main PRIVATE fmt::fmt) + + +get_property(CONAN_GENERATORS_FOLDER GLOBAL PROPERTY CONAN_GENERATORS_FOLDER) +list(PREPEND CMAKE_MODULE_PATH "${CONAN_GENERATORS_FOLDER}") +message("CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}") + +CHECK_CXX_SOURCE_COMPILES("int main(){return 0;}" HELLO_WORLD_CAN_COMPILE) \ No newline at end of file diff --git a/tests/resources/try_compile/conanfile.txt b/tests/resources/try_compile/conanfile.txt new file mode 100644 index 00000000..bf31a9b3 --- /dev/null +++ b/tests/resources/try_compile/conanfile.txt @@ -0,0 +1,8 @@ +[requires] +fmt/10.1.1 + +[generators] +CMakeDeps + +[layout] +cmake_layout \ No newline at end of file diff --git a/tests/test_smoke.py b/tests/test_smoke.py index 7174cdad..52c6d0dc 100644 --- a/tests/test_smoke.py +++ b/tests/test_smoke.py @@ -687,3 +687,13 @@ def test_no_generator_py(self, capfd, basic_cmake_project, resource_path): run(f'cmake -S {source_dir} -B {binary_dir} -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES={conan_provider} -DCMAKE_BUILD_TYPE=Release', check=False) _, err = capfd.readouterr() assert 'Cmake-conan: CMakeDeps generator was not defined in the conanfile' in err + + +class TestTryCompile: + @windows + def test_try_compile(self, capfd, basic_cmake_project): + source_dir, binary_dir = basic_cmake_project + shutil.copytree(src_dir / 'tests' / 'resources' / 'try_compile', source_dir, dirs_exist_ok=True) + run(f'cmake -S {source_dir} -B {binary_dir} -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES={conan_provider}') + out, _ = capfd.readouterr() + assert 'Performing Test HELLO_WORLD_CAN_COMPILE - Success' in out