UPDATE minimal working example
I have created a minimal working example in a public svn repo. Checkout
the proj
folder from trunk, it has a CMakeLists.txt and main.cpp (code below posted). In the trunk I also have the lib
folder, which is the static library implementing a class. This class is used in my main. I'm behind a proxy, so I have in the ~/.subversion/server
added the global proxy setup.
Expected behavior: After checkout of proj do cmake .
which also does a checkout lib and executes a make
to create libmylib.a
prior to build my main
. Finally make
my main project.
Actual behavior: Does not checkout lib so libmylib.a
is not built. Error message:
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
The folders are generated by ExternalProject_add
, but no svn co in trunk/proj/project_mylib/lib
MWE main.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 for the static library
# 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
Original post
I have a ROS
package (pomdp_planner) linked with a Makefiel
project (project_appl). I have both projects on our SVN
but different locations (I'm behind a proxy). If I have a fresh checkout of the ROS node and build it, it fails to download the Makefile
project, so building fails at linking phase. In case I manually checkout the Makefile project at the desired location then the ROS PKG is built
My issue is that the Makefile
project in the externalproject_add()
is not updated to the current version on SVN and it isn't even checked out at the beginning. To build the ROS pkg I use catkin_tools
.
I working on Ubuntu
14.04, cmake
2.8.12.2 (and ROS Indigo).
My 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)