为什么CMake C / C ++不同地对待两个二进制库? (里面的细节)

时间:2018-09-25 09:48:05

标签: cmake

这是我的CMake脚本:

cmake_minimum_required(VERSION 2.8)
project(cimutils)


set(CMAKE_CXX_STANDARD 11)
set(CMAKE_VERBOSE_MAKEFILE TRUE)

# not recommended to search for all *.c (This sets all source in variable SOURCES)
#file(GLOB_RECURSE SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "*.c")

# explicitly define each .c file is preferred. (This sets all source in variable SOURCES)
set(SOURCES
"src/process_picture/saveraw.c"
"src/process_picture/savebmp.c"
"src/process_picture/savejpeg.c"
"src/lcd/framebuffer.c"
"src/main.c"
"src/cim/video.c"
"src/cim/process.c"
"src/cim/convert.c"
"src/cim/cim_fmt.c"
)

# set include path in variable INC
set (INC
"src/include"
"src/jpeg_hw_encoder"
)

# Set include path
include_directories (AFTER ${INC})

# Set all source files
add_executable(${PROJECT_NAME} ${SOURCES})

# Sets default (system) library path
set (CMAKE_SYSROOT "/usr/local/mips-linux-gnu-gcc-toolchains/mips-gcc-glibc/mips-linux-gnu/libc")

find_library (jpeg
    NAMES jpeg
    PATHS "${CMAKE_SOURCE_DIR}/lib"
    )

find_library (jpeg-hw
    NAMES jpeg-hw
    PATHS "${CMAKE_SOURCE_DIR}/lib"
    )

target_link_libraries(${PROJECT_NAME} c gcc_s ${jpeg} ${jpeg-hw})

构建正常。但是,它对jpeg-hwjpeg的处理不同,因为我看到链接命令(详细信息被截断,只显示相关部分)为:

gcc  .....  ${PROJECT_HOME}/lib/libjpeg.so -ljpeg-hw

显然,这两个二进制库位于相同的目录中,并且它们在脚本文件中使用相同的语法。但是,为什么CMake为一个选择完整路径,而为另一个选择使用-l?只是很好奇。...

0 个答案:

没有答案