Is there a technique I can use to not have to redefine the dependencies of a library created within my project that I am including in a different part of my project? I have tried several variations of find_package(), find_library(), and different options in include_link_libraries() all to no avail. My CMake is definitely picking the library up and making me define all of its dependencies. It is actually making me add a much more granular level of dependencies in the second CMake than in the CMake where the library is created in the first place. I would like to somehow have CMake use the CMake file that builds the library in the first place instead of me having to list all of the dependencies all over again.
Any help or advice is much appreciated.
Here is my directory structure: root_folder source liba (has the .cc and .h files for LibA and it compiles and links just fine) liba_test (has a .cc and a .h that call functions in LibA for testing)
LibA CMake structure:
cmake_minimum_version(VERSION 3.17)
set_source_files_properties(${SOURCES} PROPERTIES LANGUAGE CXX COMPILE_FLAGS ${CompileFlags})
add_library(libA STATIC ${SOURCES})
set_target_properties(libA PROPERTIES LINK_FLAGS ${LinkFlags} PREFIX "")
target_include_directories(libA <5 directories)
lib_test CMake structure
cmake_minimum_version(VERSION 3.17)
enable_testing();
set_source_files_properties(libATest.cc PROPERTIES LANGUAGE CXX COMPILE_FLAGS ${CompileFlags})
add_executable(libATest libATest.cc)
target_link_libraries(libATest
cppunit
jsoncpp
**** This is where it is making me define a much more granular
level of dependencies for LibA than I even had to in the
CMake file that builds it* )
set_target_properties(libATest PROPERTIES LINK_FLAGS ${LinkFlags} PREFIX "")
target_include_directories(libATest
PUBLIC source/liba
<5 more public directories>)