Skip to content

Commit bf5dab5

Browse files
committed
test: test installation of conan packages
1 parent 6f693d4 commit bf5dab5

3 files changed

Lines changed: 32 additions & 17 deletions

File tree

tests/myproj/CMakeLists.txt

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,14 @@ project_options(
9494
add_executable(main ./src/main/main.cpp)
9595
target_link_libraries(main PRIVATE myproj_project_options myproj_project_warnings)
9696

97-
target_find_dependencies(
98-
main
97+
target_find_dependencies(main
9998
PUBLIC
100-
PACKAGE
101-
fmt
102-
CONFIG
103-
PACKAGE
104-
Eigen3
105-
CONFIG
106-
PACKAGE
107-
docopt
108-
CONFIG
99+
PACKAGE fmt CONFIG
100+
PACKAGE Eigen3 CONFIG
101+
PACKAGE docopt CONFIG
109102
)
110103

111-
target_link_system_libraries(main PRIVATE fmt::fmt Eigen3::Eigen)
104+
target_link_system_libraries(main PRIVATE fmt::fmt Eigen3::Eigen docopt)
112105

113106
add_subdirectory(libs)
114107

@@ -178,7 +171,7 @@ package_project(
178171
myproj_project_options
179172
myproj_project_warnings
180173
PUBLIC_INCLUDES
181-
${lib2_INCLUDE_DIR22}
174+
${lib2_INCLUDE_DIR2}
182175
)
183176

184177
package_project(NAME myproj_main TARGETS main)

tests/myproj/conanfile.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
[requires]
44
docopt.cpp/0.6.3
55

6+
[options]
7+
docopt.cpp/*:shared=True
8+
69
[generators]
710
CMakeDeps

tests/myproj/src/main/main.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
// test external pac
2+
#include <docopt/docopt.h>
23
#include <Eigen/Dense>
34
#include <fmt/core.h>
5+
#include <fmt/ostream.h>
46
#include <fmt/ranges.h>
57

68
// test std libraries
79
#include <iostream>
10+
#include <map>
811
#include <string>
912
#include <string_view>
1013

@@ -15,15 +18,31 @@
1518
#include <cstdint>
1619
#include <cstring>
1720

18-
int main() {
19-
fmt::print("Hello from fmt{}", "!");
21+
static std::string const usage{
22+
R"(main.
23+
24+
Usage:
25+
main
26+
main (-h | --help)
27+
main --version
28+
29+
Options:
30+
-h --help Show this screen.
31+
--version Show version.
32+
)"};
33+
34+
int main(int argc, char const* argv[]) {
35+
std::map<std::string, docopt::value> args{docopt::docopt(usage, {argv + 1, argv + argc}, /*help=*/true, "main 1.0")};
36+
for (auto const& arg : args) {
37+
fmt::println("{}: {}", arg.first, fmt::streamed(arg.second));
38+
}
2039

2140
Eigen::VectorXd eigen_vec = Eigen::Vector3d(1, 2, 3);
22-
fmt::print("[{}]", fmt::join(eigen_vec, ", "));
41+
fmt::println("[{}]", fmt::join(eigen_vec, ", "));
2342

2443
#if !defined(__MINGW32__) && !defined(__MSYS__)// TODO fails
2544
Eigen::VectorXd eigen_vec2 = Eigen::VectorXd::LinSpaced(10, 0, 1);
26-
fmt::print("[{}]", fmt::join(eigen_vec2, ", "));
45+
fmt::println("[{}]", fmt::join(eigen_vec2, ", "));
2746
#endif
2847

2948
// trigger address sanitizer

0 commit comments

Comments
 (0)