ExternalProject_Add 初始 svn co 未执行

ExternalProject_Add initial svn co not executed

更新最小工作示例

我在 public svn repo 中创建了一个最小的工作示例。 Checkout 来自 trunk 的 proj 文件夹,它有一个 CMakeLists.txt 和 main.cpp(代码在 posted 下面)。在主干中我还有 lib 文件夹,它是实现 class 的静态库。这个class在我的main中使用。我在代理后面,所以我在 ~/.subversion/server 添加了全局代理设置。

预期行为:在检出 proj 后执行 cmake .,同时检出 lib 并执行 make 以在构建我的 main 之前创建 libmylib.a。最后 make 我的主要项目。

实际行为:不签出 lib,因此未构建 libmylib.a。错误信息:

Re-run cmake no build system arguments
-- Found Subversion: /usr/bin/svn (found version "1.8.8") 
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
CMake Error at CMakeLists.txt:48 (add_executable):
  Cannot find source file:
 /home/user/tmp/externalProject_Test/trunk/proj/project_mylib/lib/mylib.hpp
  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx
-- Build files have been written to: /home/user/tmp/externalProject_Test/trunk/proj

文件夹由ExternalProject_add生成,但trunk/proj/project_mylib/lib

中没有svn co

MWEmain.cpp:

#include "project_mylib/lib/mylib.hpp"
int main () {
  Talker me; 
  me.say(); 
  return 0;
}

CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)

### Try to add external project 
include(ExternalProject)
ExternalProject_Add(project_mylib
    PREFIX project_mylib 
    SVN_REPOSITORY "https://subversion.assembla.com/svn/eternapprojectmwe/trunk/lib/"
#   SVN_REVISION ""         
#   SVN_USERNAME "" 
#   SVN_PASSWORD ""
    SVN_TRUST_CERT 1  
    TIMEOUT 30
    UPDATE_COMMAND ""
    SOURCE_DIR "project_mylib/lib"
    CONFIGURE_COMMAND ""
    BINARY_DIR "project_mylib/lib"
    BUILD_COMMAND  make
    BUILD_IN_SOURCE 
    INSTALL_COMMAND ""
)
ExternalProject_Get_Property(project_mylib binary_dir) 
project(main)
SET(LIB_DIR ${binary_dir})
SET(SOURCES ${PROJECT_SOURCE_DIR}/main.cpp)
SET(HEADERS ${LIB_DIR}/mylib.hpp)
add_custom_command(TARGET project_mylib
        POST_BUILD
        COMMAND echo ${LIB_DIR}
)
include_directories(
    include
    ${LIB_DIR}  
)
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS} ${LIB_DIR}) 
add_dependencies(${PROJECT_NAME} project_mylib) 
target_link_libraries(${PROJECT_NAME} ${LIB_DIR}/libmylib.a)

mylib.cpp:

#include "mylib.hpp"
 Talker::Talker()
{
    this->text = "Hello!";
}
 bool Talker::say(void)
{
    cout << this->text;
    return true;    
}

mylib.hpp

#include <iostream>
#include <string>
using namespace std;
class Talker {
   string text;
  public:
    Talker();
    bool say(void);
};

静态库的 Makefile

# Specify extensions of files to delete when cleaning
CLEANEXTS   = o a 

# Specify the target file and the install directory
OUTPUTFILE  = libmylib.a
INSTALLDIR  = .

# Default target
.PHONY: all
all: $(OUTPUTFILE)

# Build libjohnpaul.a from john.o, paul.o, and johnpaul.o
$(OUTPUTFILE): mylib.o
    ar ru $@ $^
    ranlib $@

# No rule to build john.o, paul.o, and johnpaul.o from .cpp 
# files is required; this is handled by make's database of
# implicit rules

.PHONY: install
install:
    mkdir -p $(INSTALLDIR)
    cp -p $(OUTPUTFILE) $(INSTALLDIR)

.PHONY: clean 
clean:
    for file in $(CLEANEXTS); do rm -f *.$$file; done

# Indicate dependencies of .ccp files on .hpp files
mylib.o: mylib.hpp

原版post

我有一个 ROS 包 (pomdp_planner) 链接到一个 Makefiel 项目 (project_appl)。我在 SVN 上有两个项目,但位置不同(我在代理后面)。如果我重新签出 ROS 节点并构建它,它无法下载 Makefile 项目,因此构建在链接阶段失败。如果我在所需位置手动签出 Makefile 项目,则会构建 ROS PKG

我的问题是 externalproject_add() 中的 Makefile 项目没有更新到 SVN 上的当前版本,甚至一开始都没有签出。为了构建 ROS pkg,我使用 catkin_tools.

我正在研究 Ubuntu 14.04、cmake 2.8.12.2(和 ROS Indigo)。

我的 ROS pkg CMakeList:

cmake_minimum_required(VERSION 2.8.3)

### Try to add external project 
include(ExternalProject)
ExternalProject_Add(project_appl
    PREFIX project_appl 
    SVN_REPOSITORY "mySVN.server"
    SVN_REVISION ""         
    SVN_USERNAME "user" 
    SVN_PASSWORD "pwd"
    SVN_TRUST_CERT 1  
    UPDATE_COMMAND ""
    SOURCE_DIR "project_appl/src"
    CONFIGURE_COMMAND ""
    BINARY_DIR "project_appl/src"
    BUILD_COMMAND  make
    BUILD_IN_SOURCE 
    INSTALL_COMMAND ""
)
ExternalProject_Get_Property(project_appl binary_dir)

project(pomdp_planner)    
SET(APPL_LIB_DIR ${binary_dir})
add_custom_command(TARGET project_appl
    POST_BUILD
    COMMAND cmake -E remove_directory ${binary_dir}/Utils/boost
    COMMAND cp ${binary_dir}/libappl.a ./CMakeFiles/pomdp_planner.dir/src/libappl.a
    COMMAND cp ${binary_dir}/OnlineOPSolver/OnlineOPsolver/solverOP_lib.hpp ../../devel/include/pomdp_planner/solverOP_lib.hpp
    )    
find_package(catkin REQUIRED COMPONENTS 
  roscpp
  rospy
  std_msgs
  message_generation
)    
 add_service_files(
   FILES
   PlannerAction.srv 
 )    
 generate_messages(
   DEPENDENCIES
   std_msgs
 )    
SET(SOURCES ${PROJECT_SOURCE_DIR}/src/main.cpp)
SET(HEADERS ${APPL_LIB_DIR}/OnlineOPSolver/OnlineOPsolver/solverOP_lib.hpp 
    ${APPL_LIB_DIR}/OfflineSolver/GlobalResource.h
    ${APPL_LIB_DIR}/OfflineSolver/solverUtils.h
    ${APPL_LIB_DIR}/Parser/Cassandra/Parser.h
    ${APPL_LIB_DIR}/Parser/Cassandra/POMDP.h
    ${APPL_LIB_DIR}/Parser/ParserSelector.h 
    ${APPL_LIB_DIR}/Models/MOMDP/MOMDP.h
    ${APPL_LIB_DIR}/Algorithms/SARSOP/SARSOP.h 
    ${APPL_LIB_DIR}/Algorithms/OPMDP/OPMDP.h
    ${APPL_LIB_DIR}/Bounds/BackupAlphaPlaneMOMDP.h
    ${APPL_LIB_DIR}/Bounds/BackupBeliefValuePairMOMDP.h 
    ${APPL_LIB_DIR}/OnlineOPSolver/OnlineOPsolver/dataLogger.h
    ${APPL_LIB_DIR}/Bounds/FastInfUBInitializer.h
    ${APPL_LIB_DIR}/Bounds/FullObsUBInitializer.h
    ${APPL_LIB_DIR}/Utils/CPTimer.h 
    ${APPL_LIB_DIR}/Core/BeliefCache.h
 )    
SET(APPL_DIR 
    ${APPL_LIB_DIR}/OnlineOPSolver/OnlineOPsolver/
    ${APPL_LIB_DIR}/OfflineSolver/
    ${APPL_LIB_DIR}/Parser/Cassandra/include
    ${APPL_LIB_DIR}/Parser/Cassandra/
    ${APPL_LIB_DIR}/Parser/
    ${APPL_LIB_DIR}/Parser/POMDPX/
    ${APPL_LIB_DIR}/Models/MOMDP
    ${APPL_LIB_DIR}/Algorithms/SARSOP
    ${APPL_LIB_DIR}/Algorithms/OPMDP/
    ${APPL_LIB_DIR}/Bounds/
    ${APPL_LIB_DIR}/Utils/
    #${APPL_LIB_DIR}/Utils/boost
    ${APPL_LIB_DIR}/Core/
    ${APPL_LIB_DIR}/MathLib
    ${APPL_LIB_DIR}/Algorithms
    ${APPL_LIB_DIR}/Parser/POMDPX
)    
SET(LINKER_FLAG "-std=c++11 -fpermissive")    
catkin_package(
  INCLUDE_DIRS ${APPL_LIB_DIR}  
  LIBRARIES pomdp_planner  project_appl
  CATKIN_DEPENDS roscpp rospy std_msgs message_generation
  DEPENDS system_lib 
)    
add_definitions(${LINKER_FLAG})
${APPL_DIR}/libappl.a)    
include_directories(
    include
    ${catkin_INCLUDE_DIRS}
    ${APPL_LIB_DIR}
    ${APPL_DIR} 
)     
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS} ${APPL_LIB_DIR})     
add_dependencies(${PROJECT_NAME} project_appl) 
add_dependencies(${PROJECT_NAME} ${catkin_EXPORTED_TARGETS} )
target_link_libraries(${PROJECT_NAME} ${ROS_LIBRARIES} ${catkin_LIBRARIES} ${APPL_LIB_DIR}/libappl.a)

您的配置看起来不错,您的 CMakeLists.txt 中似乎出现了一个小错误:project(main) 应该出现在外部项目包含部分之前。希望这有帮助。