如何使用cmake构建共享库?

时间:2019-05-10 05:51:50

标签: linux cmake

我有一个CMakeLists.txt,用于建立我的代码的静态库。现在,我想修改CMakeLists.txt,以便从相同的源代码构建共享库。

以前是

set(source_file ${MSS_SRC_DIR}/scep/scep.c
    ${MSS_SRC_DIR}/scep/tools/scepc.c
    ${MSS_SRC_DIR}/scep/scep_message.c

include_directories(${MSS_SRC_DIR}/scep/tools
        ${MSS_SRC_DIR}/scep)            

add_library(scep_sample STATIC ${TARGET_DIR} ${source_file}  
                ${NCRYPTO_BUILD_DIR} "scep_sample" ${MSS_BIN_DIR})

target_link_libraries(scep_sample ${libraryLists})

现在我修改为

set(source_file ${MSS_SRC_DIR}/scep/scep.c
    ${MSS_SRC_DIR}/scep/tools/scepc.c
    ${MSS_SRC_DIR}/scep/scep_message.c               

include_directories(${MSS_SRC_DIR}/scep/tools
        ${MSS_SRC_DIR}/scep)            

add_library(scep_sample SHARED ${TARGET_DIR} ${source_file}  
                ${NCRYPTO_BUILD_DIR} "scep_sample" ${MSS_BIN_DIR})

target_link_libraries(scep_sample ${libraryLists})

当我构建时,出现错误:No rule to make target 'scep_sample'。二进制文件生成失败。

0 个答案:

没有答案