我目前正在使用Cmake将静态库添加到我的项目中。以下是我目前的部分工作设置。部分我的意思是,为了正确下载文件,我必须构建项目,然后清理它,然后连续两次构建它以使项目有效。我在下面做的事情是否存在任何本质错误导致该项目仅部分下载?
ExternalProject_Add(
REI_LIB
SVN_REPOSITORY "repo I'm using"
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/rei_lib
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
)
ExternalProject_Get_Property(REI_LIB install_dir)
include_directories(${install_dir}/include)
这是repo的Cmake文件并从以下位置检索项目:
#Set a minimum Version
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
#Name the project
project("REI_LIB_STANDALONE")
#Create List of Headers and Source files
set(SOURCES)
set(HEADERS)
#Add in the source from this dir
set(SOURCES ${SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
#Add in the source and headers from all the required sub directories
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/IO)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/MATH)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/MESH)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/SYSTEM)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/UTILS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/XML)
#Add in the include dir
include_directories(${INCLUDE_DIRS})
#Add each file SOURCE to the correct source dir
foreach(sourceFile ${SOURCES} ${HEADERS})
#Exact the dir
set(dir)
get_filename_component(dir ${sourceFile} DIRECTORY)
#Get the relative path between the main and this file
file(RELATIVE_PATH dir ${CMAKE_CURRENT_SOURCE_DIR} ${dir})
#Convert the dir to a cmake dir only if dir is not empty from / to \\
if(NOT ${dir} STREQUAL "")
STRING(REGEX REPLACE "/" "\\\\" dir ${dir} )
#file(TO_NATIVE_PATH ${dir} dir)
endif()
#Set file in source group
SOURCE_GROUP(${dir} FILES ${sourceFile})
endforeach(sourceFile)
set(CMAKE_CXX_FLAGS_DEBUG "-DBOUNDSCHECK ${CMAKE_CXX_FLAGS_DEBUG}")
add_executable(REI_LIB_STANDALONE ${SOURCES} ${HEADERS})
add_library(REI STATIC ${SOURCES} ${HEADERS})
install(TARGETS REI DESTINATION lib)
install(FILES ${HEADERS} DESTINATION include)