Code Monkey home page Code Monkey logo

Comments (5)

aminya avatar aminya commented on May 28, 2024

It seems you have not installed the vcpkg dependencies. Please provide a reproduction.

from cpp_vcpkg_project.

ClausKlein avatar ClausKlein commented on May 28, 2024

Everything is right installed!
see https://github.com/ClausKlein/cpp_cmake_project/pull/1/files

from cpp_vcpkg_project.

ClausKlein avatar ClausKlein commented on May 28, 2024

It seems a cmake problem:

bash-3.2$ make test
cmake -B ./build -G "Ninja Multi-Config" -D CMAKE_BUILD_TYPE:STRING=Debug -D FEATURE_TESTS:BOOL=ON
-- vcpkg is already installed at /Users/clausklein/vcpkg.
-- Running vcpkg install
Detecting compiler hash for triplet x64-osx...
All requested packages are currently installed.
Restored 0 packages from /Users/clausklein/.cache/vcpkg/archives in 1.509 us. Use --debug to see more details.

Total elapsed time: 1.722 s

The package fmt provides CMake targets:

    find_package(fmt CONFIG REQUIRED)
    target_link_libraries(main PRIVATE fmt::fmt)

    # Or use the header-only version
    find_package(fmt CONFIG REQUIRED)
    target_link_libraries(main PRIVATE fmt::fmt-header-only)

The package catch2 provides CMake targets:

    find_package(Catch2 CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Catch2::Catch2 Catch2::Catch2WithMain)

-- Running vcpkg install - done
-- /usr/local/bin/ccache found and enabled
CMake Warning at CMakeLists.txt:98 (message):
  missing my_header_lib_DEPENDENCIES_CONFIGURED!


-- Configuring done
-- Generating done
-- Build files have been written to: /Users/clausklein/Workspace/cpp/cpp_cmake_project/build
cmake --build ./build --config Debug
[18/18] Linking CXX executable my_header_lib/test/Debug/my_header_lib_tests
cmake --build ./build --config Debug --target test
[0/1] Running tests...
Test project /Users/clausklein/Workspace/cpp/cpp_cmake_project/build
    Start 1: some_fun
1/8 Test #1: some_fun .........................   Passed    0.10 sec
    Start 2: my_exe_test
2/8 Test #2: my_exe_test ......................   Passed    0.26 sec
    Start 3: some_fun
3/8 Test #3: some_fun .........................   Passed    0.10 sec
    Start 4: some_constexpr_fun
4/8 Test #4: some_constexpr_fun ...............   Passed    0.10 sec
    Start 5: some_constexpr_fun
5/8 Test #5: some_constexpr_fun ...............   Passed    0.10 sec
    Start 6: some_fun
6/8 Test #6: some_fun .........................   Passed    0.10 sec
    Start 7: some_constexpr_fun
7/8 Test #7: some_constexpr_fun ...............   Passed    0.10 sec
    Start 8: some_constexpr_fun
8/8 Test #8: some_constexpr_fun ...............   Passed    0.10 sec

100% tests passed, 0 tests failed out of 8

Total Test time (real) =   0.95 sec
gcovr -r .
------------------------------------------------------------------------------
                           GCC Code Coverage Report
Directory: .
------------------------------------------------------------------------------
File                                       Lines    Exec  Cover   Missing
------------------------------------------------------------------------------
my_exe/include/my_exe/helpers.hpp              3       3   100%   
my_exe/src/main.cpp                            6       6   100%   
my_lib/src/my_lib/lib.cpp                      3       3   100%   
------------------------------------------------------------------------------
TOTAL                                         12      12   100%
------------------------------------------------------------------------------
bash-3.2$ git diff
diff --git a/my_header_lib/CMakeLists.txt b/my_header_lib/CMakeLists.txt
index d55675b..d508f97 100644
--- a/my_header_lib/CMakeLists.txt
+++ b/my_header_lib/CMakeLists.txt
@@ -9,7 +9,7 @@ target_include_directories(my_header_lib INTERFACE "$<BUILD_INTERFACE:${CMAKE_CU
                                                    "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
 
 # Find dependencies:
-set(my_header_lib_DEPENDENCIES_CONFIGURED fmt PARENT_SCOPE)
+set(my_header_lib_DEPENDENCIES_CONFIGURED fmt)
 
 foreach(DEPENDENCY ${my_header_lib_DEPENDENCIES_CONFIGURED})
   find_package(${DEPENDENCY} CONFIG REQUIRED)
diff --git a/my_header_lib/test/CMakeLists.txt b/my_header_lib/test/CMakeLists.txt
index 6d96fa4..ef1aa20 100644
--- a/my_header_lib/test/CMakeLists.txt
+++ b/my_header_lib/test/CMakeLists.txt
@@ -8,7 +8,7 @@ endforeach()
 include(Catch)
 
 # test executable
-add_executable(my_header_lib_tests "tests.cpp")
+_add_executable(my_header_lib_tests "tests.cpp")
 
 target_link_libraries(
   my_header_lib_tests
diff --git a/my_header_lib/test/constexpr/CMakeLists.txt b/my_header_lib/test/constexpr/CMakeLists.txt
index aa6ac98..ffbf93f 100644
--- a/my_header_lib/test/constexpr/CMakeLists.txt
+++ b/my_header_lib/test/constexpr/CMakeLists.txt
@@ -1,5 +1,5 @@
 # Add a file containing a set of constexpr tests
-add_executable(my_header_lib_constexpr_tests "constexpr_tests.cpp")
+_add_executable(my_header_lib_constexpr_tests "constexpr_tests.cpp")
 
 target_link_libraries(
   my_header_lib_constexpr_tests
@@ -13,7 +13,7 @@ catch_discover_tests(my_header_lib_constexpr_tests ${COVERAGE_ARGS})
 
 # Disable the constexpr portion of the test, and build again this allows us to have an executable that we can debug when
 # things go wrong with the constexpr testing
-add_executable(my_header_lib_relaxed_constexpr_tests "constexpr_tests.cpp")
+_add_executable(my_header_lib_relaxed_constexpr_tests "constexpr_tests.cpp")
 
 target_link_libraries(
   my_header_lib_relaxed_constexpr_tests
bash-3.2$ 

from cpp_vcpkg_project.

ClausKlein avatar ClausKlein commented on May 28, 2024

With this changes, the exported cmake config package contains all target properties,
even of this warning

CMake Warning at CMakeLists.txt:98 (message):
  missing my_header_lib_DEPENDENCIES_CONFIGURED!
# Create imported target cpp_cmake_project::my_lib
add_library(cpp_cmake_project::my_lib STATIC IMPORTED)

set_target_properties(cpp_cmake_project::my_lib PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:cpp_cmake_project::project_options>;\$<LINK_ONLY:cpp_cmake_project::project_warnings>;\$<LINK_ONLY:fmt::fmt>"
)

# Create imported target cpp_cmake_project::my_header_lib
add_library(cpp_cmake_project::my_header_lib INTERFACE IMPORTED)

set_target_properties(cpp_cmake_project::my_header_lib PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "cpp_cmake_project::project_options;cpp_cmake_project::project_warnings;fmt::fmt-header-only"
)

# Create imported target cpp_cmake_project::project_options
add_library(cpp_cmake_project::project_options INTERFACE IMPORTED)

# Create imported target cpp_cmake_project::project_warnings
add_library(cpp_cmake_project::project_warnings INTERFACE IMPORTED)

set_target_properties(cpp_cmake_project::project_warnings PROPERTIES
  INTERFACE_COMPILE_OPTIONS "\$<\$<COMPILE_LANGUAGE:CXX>:-Wall;-Wextra;-Wshadow;-Wnon-virtual-dtor;-Wold-style-cast;-Wcast-align;-Wunused;-Woverloaded-virtual;-Wpedantic;-Wconversion;-Wsign-conversion;-Wnull-dereference;-Wdouble-promotion;-Wformat=2;-Wimplicit-fallthrough>;\$<\$<COMPILE_LANGUAGE:C>:-Wall;-Wextra;-Wshadow;-Wcast-align;-Wunused;-Wpedantic;-Wconversion;-Wsign-conversion;-Wnull-dereference;-Wdouble-promotion;-Wformat=2;-Wimplicit-fallthrough>;\$<\$<COMPILE_LANGUAGE:CUDA>:-Wall;-Wextra;-Wunused;-Wconversion;-Wshadow>"
)

from cpp_vcpkg_project.

ClausKlein avatar ClausKlein commented on May 28, 2024

this was a result of the use of set(include_dir ... PARENT_SCOPE)

see #6

from cpp_vcpkg_project.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.