Skip to content

Commit

Permalink
build app
Browse files Browse the repository at this point in the history
  • Loading branch information
danimtb committed Dec 2, 2020
1 parent 63e9c85 commit 4bdbed2
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 18 deletions.
20 changes: 15 additions & 5 deletions conans/test/functional/generators/cmake_find_package_multi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ def build(self):
cmake.build()
def package(self):
self.copy("*.h", dst="include")
self.copy("*.a", dst="lib")
self.copy("*.lib", dst="lib")
self.copy("*.h", dst="include", src="src")
self.copy("*.lib", dst="lib", keep_path=False)
self.copy("*.a", dst="lib", keep_path=False)
self.copy("target-alias.cmake", dst="share/cmake")
def package_info(self):
Expand All @@ -182,6 +182,7 @@ def package_info(self):
info = textwrap.dedent("""\
self.cpp_info.name = "namespace"
self.cpp_info.filenames["cmake_find_package_multi"] = "hello"
self.cpp_info.components["comp"].libs = ["hello"]
self.cpp_info.components["comp"].build_modules.append(module)
self.cpp_info.components["comp"].builddirs = [builddir]
""")
Expand All @@ -193,6 +194,7 @@ def package_info(self):
""")
else:
info = textwrap.dedent("""\
self.cpp_info.libs = ["hello"]
self.cpp_info.build_modules.append(module)
self.cpp_info.builddirs = [builddir]
""")
Expand All @@ -213,7 +215,7 @@ class Conan(ConanFile):
name = "consumer"
version = "1.0"
settings = "os", "compiler", "build_type", "arch"
exports_sources = ["CMakeLists.txt"]
exports_sources = ["CMakeLists.txt", "main.cpp"]
generators = "cmake_find_package_multi"
requires = "hello/1.0"
Expand All @@ -229,7 +231,15 @@ def build(self):
get_target_property(tmp otherhello INTERFACE_LINK_LIBRARIES)
message("otherhello link libraries: ${tmp}")
""")
client.save({"conanfile.py": consumer, "CMakeLists.txt": cmakelists})
main = textwrap.dedent("""
#include "hello.h"
int main() {
hello();
return 0;
}
""")
client.save({"conanfile.py": consumer, "CMakeLists.txt": cmakelists, "main.cpp": main})
client.run("create .")
if use_components:
self.assertIn("otherhello link libraries: namespace::hello", client.out)
Expand Down
20 changes: 15 additions & 5 deletions conans/test/functional/generators/cmake_find_package_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,9 @@ def build(self):
cmake.build()
def package(self):
self.copy("*.h", dst="include")
self.copy("*.a", dst="lib")
self.copy("*.lib", dst="lib")
self.copy("*.h", dst="include", src="src")
self.copy("*.lib", dst="lib", keep_path=False)
self.copy("*.a", dst="lib", keep_path=False)
self.copy("target-alias.cmake", dst="share/cmake")
def package_info(self):
Expand All @@ -466,6 +466,7 @@ def package_info(self):
info = textwrap.dedent("""\
self.cpp_info.name = "namespace"
self.cpp_info.filenames["cmake_find_package"] = "hello"
self.cpp_info.components["comp"].libs = ["hello"]
self.cpp_info.components["comp"].build_modules.append(module)
self.cpp_info.components["comp"].builddirs = [builddir]
""")
Expand All @@ -477,6 +478,7 @@ def package_info(self):
""")
else:
info = textwrap.dedent("""\
self.cpp_info.libs = ["hello"]
self.cpp_info.build_modules.append(module)
self.cpp_info.builddirs = [builddir]
""")
Expand All @@ -497,7 +499,7 @@ class Conan(ConanFile):
name = "consumer"
version = "1.0"
settings = "os", "compiler", "build_type", "arch"
exports_sources = ["CMakeLists.txt"]
exports_sources = ["CMakeLists.txt", "main.cpp"]
generators = "cmake_find_package"
requires = "hello/1.0"
Expand All @@ -513,7 +515,15 @@ def build(self):
get_target_property(tmp otherhello INTERFACE_LINK_LIBRARIES)
message("otherhello link libraries: ${tmp}")
""")
client.save({"conanfile.py": consumer, "CMakeLists.txt": cmakelists})
main = textwrap.dedent("""
#include "hello.h"
int main() {
hello();
return 0;
}
""")
client.save({"conanfile.py": consumer, "CMakeLists.txt": cmakelists, "main.cpp": main})
client.run("create .")
if use_components:
self.assertIn("otherhello link libraries: namespace::hello", client.out)
Expand Down
24 changes: 16 additions & 8 deletions conans/test/functional/generators/cmake_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,13 @@ def build(self):
cmake.build()
def package(self):
self.copy("*.h", dst="include")
self.copy("*.a", dst="lib")
self.copy("*.lib", dst="lib")
self.copy("*.h", dst="include", src="src")
self.copy("*.lib", dst="lib", keep_path=False)
self.copy("*.a", dst="lib", keep_path=False)
self.copy("target-alias.cmake", dst="share/cmake")
def package_info(self):
self.cpp_info.libs = ["hello"]
builddir = os.path.join("share", "cmake")
module = os.path.join(builddir, "target-alias.cmake")
self.cpp_info.build_modules.append(module)
Expand All @@ -553,12 +554,11 @@ class Conan(ConanFile):
name = "consumer"
version = "1.0"
settings = "os", "compiler", "build_type", "arch"
exports_sources = ["CMakeLists.txt"]
exports_sources = ["CMakeLists.txt", "main.cpp"]
generators = "cmake"
requires = "hello/1.0"
def build(self):
print(tools.load(os.path.join(self.install_folder, "conanbuildinfo.cmake")))
cmake = CMake(self)
cmake.configure()
cmake.build()
Expand All @@ -567,12 +567,20 @@ def build(self):
cmake_minimum_required(VERSION 3.0)
project(test)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
message("CONAN_BUILD_MODULES_PATHS: ${CONAN_BUILD_MODULES_PATHS}")
conan_basic_setup(TARGETS)
get_target_property(tmp otherhello INTERFACE_LINK_LIBRARIES)
message("otherhello link libraries: ${tmp}")
add_executable(app main.cpp)
target_link_libraries(app otherhello)
""")
client.save({"conanfile.py": consumer, "CMakeLists.txt": cmakelists})
main = textwrap.dedent("""
#include "hello.h"
int main() {
hello();
return 0;
}
""")
client.save({"conanfile.py": consumer, "CMakeLists.txt": cmakelists, "main.cpp": main})
client.run("create .")
print(client.out)
self.assertIn("otherhello link libraries: CONAN_PKG::hello", client.out)

0 comments on commit 4bdbed2

Please sign in to comment.