I'm working on a main project, having several third party libraries. My goal is to import all of these as imported target for clarity sake, but I can't get one to work. It's basically a set of static libraries (.lib / lib.a) and their headers.
For the sake of discussion, Main is the main target, Third is the imported third party.
I manage to generate a proper Visual Studio solution on Windows, but things are not working as intended on Linux. When building the solution, I end up with this error:
"No rule to make target 'Third-NOTFOUND', needed by '../Bin/Main'"
Here are some code snippets from my CMakeLists.txt's.
Main's CMakeLists.txt:
project(Main)
[...]
add_subdirectory(ThirdParty/Third)
set_property(TARGET Third PROPERTY FOLDER "thirdparty")
[...]
add_executable(Main ${SOURCES})
target_link_libraries(Main PRIVATE Third)
Third's CMakeLists.txt:
project(Third)
[...]
# Helper function
function(append_lib target lib_debug_dir lib_release_dir name)
set_property(TARGET ${target} APPEND PROPERTY IMPORTED_LOCATION_DEBUG "${lib_debug_dir}/${LIB_NAME}")
set_property(TARGET ${target} APPEND PROPERTY IMPORTED_LOCATION_RELEASE "${lib_release_dir}/${LIB_NAME}")
endfunction()
[...]
add_library(Third STATIC IMPORTED GLOBAL)
set_property(TARGET Third APPEND PROPERTY PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${INCLUDE_DIR}")
append_lib(Third ${LIB_DIR_DEBUG} ${LIB_DIR_RELEASE} libMyLib1.a)
NB: The code for Linux and Windows are the same, except the name of the static library it self (MyLib1.lib replaces libMyLib1.a)
What am I doing wrong? Thanks :)