Skip to content
Permalink
Browse files

CMakeLists.txt clean up

  • Loading branch information
wjwwood committed Dec 15, 2012
1 parent 601e37c commit 19b23e5900e9c179089e99caae52023f95d2fec8
Showing with 23 additions and 46 deletions.
  1. +23 −46 CMakeLists.txt
@@ -1,58 +1,35 @@
cmake_minimum_required( VERSION 2.8.3 )
project (srdfdom CXX C)

This comment has been minimized.

Copy link
@vrabaud

vrabaud Dec 16, 2012

why remove that info ? (CXX, C)

This comment has been minimized.

Copy link
@wjwwood

# set the default build type
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
cmake_minimum_required(VERSION 2.8.3)
project(srdfdom)

include_directories(include)

find_library(tinyxml_library tinyxml)
if (tinyxml_library)
message (STATUS "Looking for libtinyxml - found")
set(tinyxml_libraries ${tinyxml_library})
endif ()
find_path(tinyxml_include_dirs NAMES tinyxml.h PATH_SUFFIXES tinyxml)
if (NOT tinyxml_include_dirs)
message (STATUS "Looking for tinyxml/tinyxml.hpp or tinyxml/tinyxml.h - not found.")
endif ()
if (NOT tinyxml_include_dirs OR NOT tinyxml_libraries)
include (FindPkgConfig)
if (PKG_CONFIG_FOUND)
# Find tinyxml
pkg_check_modules(tinyxml tinyxml)
else()
MESSAGE("Missing: tinyxml")
endif()
endif ()
include_directories(SYSTEM ${tinyxml_include_dirs})
link_directories(${tinyxml_library_dirs})
add_definitions(${tinyxml_cflags})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(tinyxml REQUIRED)

This comment has been minimized.

Copy link
@vrabaud

vrabaud Dec 16, 2012

since when tinyxml can be find_packaged ?

This comment has been minimized.

Copy link
@wjwwood

wjwwood Dec 16, 2012

Author Contributor

The reason tinyxml can be find packages is that I created a Findtinyxml.cmake file, but forgot to add it to the commit. This is also why the farm is failing. tinyxml has only pkg-config stuff, CMake recommends that pkg-config stuff is wrapped in a Find.cmake file:

http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries#Piggybacking_on_pkg-config


include_directories(SYSTEM ${tinyxml_INCLUDE_DIRS})
link_directories(${tinyxml_LIBRARY_DIRS})

find_package(Boost REQUIRED)
include_directories(SYSTEM ${Boost_INCLUDE_DIR})

find_package(catkin REQUIRED COMPONENTS urdfdom_headers console_bridge)
include_directories(SYSTEM ${catkin_INCLUDE_DIRS})
find_package(catkin REQUIRED COMPONENTS console_bridge urdfdom_headers)

include_directories(include ${catkin_INCLUDE_DIRS})
link_directories(${catkin_LIBRARY_DIRS})

catkin_package(
LIBRARIES ${PROJECT_NAME}
INCLUDE_DIRS include
DEPENDS urdfdom_headers)

add_library(${PROJECT_NAME} SHARED src/model.cpp)
target_link_libraries(${PROJECT_NAME} ${tinyxml_libraries} ${catkin_LIBRARIES})
install(TARGETS ${PROJECT_NAME} DESTINATION lib/)
install(DIRECTORY include/srdfdom DESTINATION include/)

find_package(urdfdom QUIET)
if (urdfdom_FOUND)
include_directories(SYSTEM ${urdfdom_INCLUDE_DIRS})
add_definitions('-DTEST_RESOURCE_LOCATION="${CMAKE_CURRENT_SOURCE_DIR}/test/res/"')
add_executable(test_srdf test/test_parser.cpp)
target_link_libraries(test_srdf ${PROJECT_NAME} ${urdfdom_LIBRARIES})

This comment has been minimized.

Copy link
@vrabaud

vrabaud Dec 16, 2012

so we just get rid of the tests ?

This comment has been minimized.

Copy link
@wjwwood

wjwwood Dec 16, 2012

Author Contributor

I removed these tests because another package defined the same target... I mean to go back and rename the test, but I forgot.

Also it doesn't depend on urdfdom:

https://github.com/ros-planning/srdfdom/blob/19b23e5900e9c179089e99caae52023f95d2fec8/package.xml

This comment has been minimized.

Copy link
@isucan

isucan via email Dec 16, 2012

Contributor
else()
message(STATUS "Tests are not built without urdfdom")
endif()
DEPENDS console_bridge urdfdom_headers
)

add_library(${PROJECT_NAME} src/model.cpp)

This comment has been minimized.

Copy link
@vrabaud

vrabaud Dec 16, 2012

SHARED is actually a useful keyword and is not necessarily the default

This comment has been minimized.

Copy link
@wjwwood

wjwwood Dec 16, 2012

Author Contributor

It is with catkin because of the BUILD_SHARED_LIBS variable, you shouldn't set it unless you don't want others to override it using BUILD_SHARED_LIBS.

http://cmake.org/cmake/help/v2.8.8/cmake.html#command:add_library

target_link_libraries(${PROJECT_NAME} ${tinyxml_LIBRARIES} ${catkin_LIBRARIES})

install(TARGETS ${PROJECT_NAME}
DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
)
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
)

0 comments on commit 19b23e5

Please sign in to comment.
You can’t perform that action at this time.