CMake: Linking to an imported library with dependencies fails -


i have subdirectory cmakelists.txt should compile library using make , export result imported library parent directory:

set(static_lib ${cmake_current_binary_dir}/lib/mylib.a)  add_custom_command(     working_directory ${cmake_current_source_dir}     output ${static_lib}     command make     command make install prefix=${cmake_current_binary_dir} )  add_custom_target(compile_mylib depends ${static_lib})  add_library(mylib static imported) set_property(target mylib property imported_location ${static_lib}) add_dependencies(mylib compile_mylib) 

the cmakelists.txt in parent directory looks this:

add_subdirectory(deps/mylib) add_executable(mybin source.c) target_link_libraries(mybin mylib) 

on osx works fine - if compile same on ubuntu seems ignore subdirectory's cmakelists , complains:

/usr/bin/ld.bfd.real: cannot find -lmylib 

i'm using clang compilation.

the solution add global add_library call visible parent cmakelists.txt


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -