Skip to content

Commit

Permalink
test: test installation of conan packages
Browse files Browse the repository at this point in the history
  • Loading branch information
FeignClaims committed Sep 18, 2024
1 parent 9ccd37f commit d700613
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
19 changes: 6 additions & 13 deletions tests/myproj/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,14 @@ project_options(
add_executable(main ./src/main/main.cpp)
target_link_libraries(main PRIVATE myproj_project_options myproj_project_warnings)

target_find_dependencies(
main
target_find_dependencies(main
PUBLIC
PACKAGE
fmt
CONFIG
PACKAGE
Eigen3
CONFIG
PACKAGE
docopt
CONFIG
PACKAGE fmt CONFIG
PACKAGE Eigen3 CONFIG
PACKAGE docopt CONFIG
)

target_link_system_libraries(main PRIVATE fmt::fmt Eigen3::Eigen)
target_link_system_libraries(main PRIVATE fmt::fmt Eigen3::Eigen docopt)

add_subdirectory(libs)

Expand Down Expand Up @@ -180,7 +173,7 @@ package_project(
myproj_project_options
myproj_project_warnings
PUBLIC_INCLUDES
${lib2_INCLUDE_DIR22}
${lib2_INCLUDE_DIR2}
)

package_project(NAME myproj_main TARGETS main)
3 changes: 3 additions & 0 deletions tests/myproj/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
[requires]
docopt.cpp/0.6.3

[options]
docopt.cpp/*:shared=True

[generators]
CMakeDeps
27 changes: 23 additions & 4 deletions tests/myproj/src/main/main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// test external pac
#include <docopt/docopt.h>
#include <Eigen/Dense>
#include <fmt/core.h>
#include <fmt/ostream.h>
#include <fmt/ranges.h>

// test std libraries
#include <iostream>
#include <map>
#include <string>
#include <string_view>

Expand All @@ -15,15 +18,31 @@
#include <cstdint>
#include <cstring>

int main() {
fmt::print("Hello from fmt{}", "!");
static std::string const usage{
R"(main.
Usage:
main
main (-h | --help)
main --version
Options:
-h --help Show this screen.
--version Show version.
)"};

int main(int argc, char const* argv[]) {
std::map<std::string, docopt::value> args{docopt::docopt(usage, {argv + 1, argv + argc}, /*help=*/true, "main 1.0")};
for (auto const& arg : args) {
fmt::println("{}: {}", arg.first, fmt::streamed(arg.second));
}

Eigen::VectorXd eigen_vec = Eigen::Vector3d(1, 2, 3);
fmt::print("[{}]", fmt::join(eigen_vec, ", "));
fmt::println("[{}]", fmt::join(eigen_vec, ", "));

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

// trigger address sanitizer
Expand Down

0 comments on commit d700613

Please sign in to comment.