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 12, 2024
1 parent 6f693d4 commit bf5dab5
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 @@ -94,21 +94,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 @@ -178,7 +171,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>

Check warning on line 6 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (ubuntu-22.04, gcc, true)

included header ranges.h is not used directly [misc-include-cleaner]

Check warning on line 6 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (ubuntu-22.04, llvm, true)

included header ranges.h is not used directly [misc-include-cleaner]

Check warning on line 6 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (windows-2022, gcc, true)

included header ranges.h is not used directly [misc-include-cleaner]

Check warning on line 6 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (ubuntu-22.04, llvm, true)

included header ranges.h is not used directly [misc-include-cleaner]

Check warning on line 6 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (ubuntu-22.04, gcc, true)

included header ranges.h is not used directly [misc-include-cleaner]

Check warning on line 6 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (windows-2022, gcc, true)

included header ranges.h is not used directly [misc-include-cleaner]

// test std libraries
#include <iostream>

Check warning on line 9 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (windows-2022, gcc, true)

included header iostream is not used directly [misc-include-cleaner]

Check warning on line 9 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (windows-2022, gcc, true)

included header iostream is not used directly [misc-include-cleaner]
#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{

Check warning on line 21 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (macos-13, gcc, true)

initialization of 'usage' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]

Check warning on line 21 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (macos-13, llvm, true)

initialization of 'usage' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]

Check warning on line 21 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (macos-13, llvm, true)

initialization of 'usage' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]

Check warning on line 21 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (macos-13, gcc, true)

initialization of 'usage' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
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")};

Check warning on line 35 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (macos-13, gcc, true)

variable 'args' of type 'std::map<std::string, docopt::value>' (aka 'map<basic_string<char, char_traits<char>, allocator<char>>, docopt::value>') can be declared 'const' [misc-const-correctness]

Check warning on line 35 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (macos-13, llvm, true)

variable 'args' of type 'std::map<std::string, docopt::value>' (aka 'map<basic_string<char, char_traits<char>, allocator<char>>, docopt::value>') can be declared 'const' [misc-const-correctness]

Check warning on line 35 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (macos-13, llvm, true)

variable 'args' of type 'std::map<std::string, docopt::value>' (aka 'map<basic_string<char, char_traits<char>, allocator<char>>, docopt::value>') can be declared 'const' [misc-const-correctness]

Check warning on line 35 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (macos-13, gcc, true)

variable 'args' of type 'std::map<std::string, docopt::value>' (aka 'map<basic_string<char, char_traits<char>, allocator<char>>, docopt::value>') can be declared 'const' [misc-const-correctness]
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);

Check warning on line 44 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (macos-13, gcc, true)

10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

Check warning on line 44 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (macos-13, llvm, true)

10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

Check warning on line 44 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (macos-13, llvm, true)

10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]

Check warning on line 44 in tests/myproj/src/main/main.cpp

View workflow job for this annotation

GitHub Actions / Test (macos-13, gcc, true)

10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
fmt::print("[{}]", fmt::join(eigen_vec2, ", "));
fmt::println("[{}]", fmt::join(eigen_vec2, ", "));
#endif

// trigger address sanitizer
Expand Down

0 comments on commit bf5dab5

Please sign in to comment.