Skip to content

Commit

Permalink
Add test for issue #578 (#603)
Browse files Browse the repository at this point in the history
* create test for try_compile with Windows paths

* restore files

* fix files

* modified conanfile for test
  • Loading branch information
juansblanco authored Jan 18, 2024
1 parent b27d3ee commit a4d21fa
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
target_link_libraries(main PRIVATE fmt::fmt)
2 changes: 1 addition & 1 deletion example/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
fmt/9.1.0

[layout]
cmake_layout
cmake_layout
17 changes: 17 additions & 0 deletions tests/resources/try_compile/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
8 changes: 8 additions & 0 deletions tests/resources/try_compile/conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[requires]
fmt/10.1.1

[generators]
CMakeDeps

[layout]
cmake_layout
10 changes: 10 additions & 0 deletions tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a4d21fa

Please sign in to comment.