使用ExternalProject_Add正确添加和构建CMake项目

I'm trying to add an external project to my CMakeLists file on Fedora 31, GCC 9 and CMake 3.10.3. In my CMakeLists I import the GitHub csv-parser project that also uses CMake using ExternalProject_Add():

set(CSV_PARSER "csv_parser")
ExternalProject_Add(
        ${CSV_PARSER}
        GIT_REPOSITORY    https://github.com/vincentlaucsb/csv-parser.git
        GIT_REMOTE_NAME   releases
        GIT_TAG           1.3.0
        SOURCE_DIR        "${CMAKE_BINARY_DIR}/${CSV_PARSER}"
        BINARY_DIR        "${CMAKE_BINARY_DIR}/${CSV_PARSER}"
        TEST_COMMAND      ""
        GIT_SHALLOW       1
        GIT_PROGRESS      1
        LOG_DOWNLOAD      1
        LOG_BUILD         1
        LOG_INSTALL       1
        INSTALL_COMMAND ""
        #CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/${CSV_PARSER}
        #CONFIGURE_COMMAND cd ${CMAKE_BINARY_DIR}/${CSV_PARSER} && ./configure --prefix=${CMAKE_BINARY_DIR}/csv_parser
        )
# Set include csv-parser package
set(CSV_PARSER_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/${CSV_PARSER}/include)
set(CSV_PARSER_LIBS ${CMAKE_BINARY_DIR}/${CSV_PARSER}/include/internal/libcsv.a) # Points to the created "libcsv.a" lib.

我使用它来将库链接到可执行文件:

add_dependencies(hmmenc-client ${CSV_PARSER})

# Include the packages
target_include_directories(hmmenc-client PRIVATE
        ${CSV_PARSER_INCLUDE_DIRS}
        )

# Link the libraries
target_link_libraries(hmmenc-client
        ${CSV_PARSER_LIBS}
        )

但是在构建项目时出现此错误:

gmake[3]: *** No rule to make target 'csv_parser-src/include/internal/libcsv.a', needed by '../dev/hmmenc_client/bin/hmmenc-client'.  Stop.
gmake[3]: *** Waiting for unfinished jobs....
gmake[2]: *** [CMakeFiles/Makefile2:87: CMakeFiles/hmmenc-client.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:94: CMakeFiles/hmmenc-client.dir/rule] Error 2
gmake: *** [Makefile:118: hmmenc-client] Error 2

找不到libcs​​v.a,但位于提供的路径中。我想念什么吗?

评论