cmake:missing and no known rule to make it when I import a prebuilt library

后端 未结 3 1804
伪装坚强ぢ
伪装坚强ぢ 2020-12-14 16:57

I want to import a prebuilt library using this CmakeLists.txt snippet:

add_library(openssl-crypto
            SHARED
            IMPORTED )
set_target_proper         


        
3条回答
  •  渐次进展
    2020-12-14 17:39

    You can use set_property function with attribute TARGET instead of set_target_properties, and then you can set path relatively using macros ${PROJECT_SOURCE_DIR}.

    # import shared library libmylib.so    
    add_library( my-imported-lib 
                 SHARED 
                 IMPORTED) 
    
    # set the path to appropriate so files with appropriate architectures
    set_property(TARGET 
                 my-imported-lib 
                 PROPERTY IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}//${ANDROID_ABI}/libmy-imported-lib.so) 
    
    ...
    
    # link imported library to your developed library
    target_link_libraries( my-developed-lib 
                           my-imported-lib ) 
    

    Maybe you can use macros ${PROJECT_SOURCE_DIR} while set lib path with set_target_properties but I didn't check this way.

提交回复
热议问题