CMakeLists.txt 4.38 KB
Newer Older
1
cmake_minimum_required(VERSION 2.8)
isucan's avatar
isucan committed
2
project(fcl CXX C)
sachinc's avatar
sachinc committed
3

mmoll's avatar
mmoll committed
4
5
6
7
8
# set the default build type
if (NOT CMAKE_BUILD_TYPE)
   set(CMAKE_BUILD_TYPE Release)
endif()

9
# Set build type variable
10
11
set(FCL_BUILD_TYPE_RELEASE FALSE)
set(FCL_BUILD_TYPE_DEBUG FALSE)
12
13
14

string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPERCASE)
if("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "RELEASE")
15
  set(FCL_BUILD_TYPE_RELEASE TRUE)
16
elseif("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "DEBUG")
17
  set(FCL_BUILD_TYPE_DEBUG TRUE)
18
19
20
21
else()
  message(STATUS "CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} unknown. Valid options are: Debug Release")
endif()

22
23
24
25
26
27
# This shouldn't be necessary, but there has been trouble
# with MSVC being set off, but MSVCXX ON.
if(MSVC OR MSVC90 OR MSVC10)
    set(MSVC ON)
endif (MSVC OR MSVC90 OR MSVC10)

28
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
isucan's avatar
isucan committed
29
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
30
include(CompilerSettings)
31
include(FCLVersion)
isucan's avatar
isucan committed
32

33
34
35
36
37
if(MSVC OR IS_ICPC)
  option(FCL_STATIC_LIBRARY "Whether the FCL library should be static rather than shared" ON)
else()
  option(FCL_STATIC_LIBRARY "Whether the FCL library should be static rather than shared" OFF)
endif()
38

39
# Whether to enable SSE
40
option(FCL_USE_SSE "Whether FCL should SSE instructions" OFF)
isucan's avatar
isucan committed
41
set(FCL_HAVE_SSE 0)
42
43
if(FCL_USE_SSE)
  if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
isucan's avatar
isucan committed
44
    set(FCL_HAVE_SSE 0) #always disable, for now
45
46
47
    add_definitions(-march=native)
  endif()
  # TODO: do something similar for other compilers
isucan's avatar
isucan committed
48
endif()
sachinc's avatar
sachinc committed
49

50
# Find Octomap (optional)
51
find_package(PkgConfig QUIET)
jpan's avatar
jpan committed
52
set(FCL_HAVE_OCTOMAP 0)
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
if(PKG_CONFIG_FOUND)
    pkg_check_modules(OCTOMAP QUIET octomap)
endif()
if(NOT OCTOMAP_FOUND)
    # if pkfconfig is not installed, then fall back on more fragile detection
    # of octomap
    find_path(OCTOMAP_INCLUDE_DIRS octomap.h
        PATH_SUFFIXES octomap)
    find_path(OCTOMAP_LIBRARY_DIRS
        ${CMAKE_SHARED_LIBRARY_PREFIX}octomap${CMAKE_SHARED_LIBRARY_SUFFIX})
    if(OCTOMAP_INCLUDE_DIRS AND OCTOMAP_LIBRARY_DIRS)
        set(OCTOMAP_LIBRARIES "octomap;octomath")
    endif()
endif()
if (OCTOMAP_INCLUDE_DIRS AND OCTOMAP_LIBRARY_DIRS)
68
69
  include_directories(${OCTOMAP_INCLUDE_DIRS})
  link_directories(${OCTOMAP_LIBRARY_DIRS})
jpan's avatar
jpan committed
70
  set(FCL_HAVE_OCTOMAP 1)
71
  message(STATUS "FCL uses Octomap")
jpan's avatar
jpan committed
72
else()
73
74
75
  message(STATUS "FCL does not use Octomap")
endif()

panjia1983's avatar
panjia1983 committed
76
77
78
79
80
81
82
83
84
85
86
# Find FLANN (optional)
find_package(flann QUIET)
if (FLANN_FOUND)
  set(FCL_HAVE_FLANN 1)
  include_directories(${FLANN_INCLUDE_DIRS})
  message(STATUS "FCL uses Flann")
else()
  message(STATUS "FCL does not use Flann")
endif()


87
88
89
90
91
92
93
94
95
# find_package(tinyxml QUIET)
# if (TINYXML_FOUND)
#   set(FCL_HAVE_TINYXML 1)
#   include_directories(${TINYXML_INCLUDE_DIRS})
#   link_directories(${TINYXML_LIBRARY_DIRS})
#   message(STATUS "FCL uses tinyxml")
# else()
#   message(STATUS "FCL does not use tinyxml")
# endif()
panjia1983's avatar
panjia1983 committed
96
97


98
99
100
find_package(Boost COMPONENTS thread date_time filesystem system unit_test_framework REQUIRED)
include_directories(${Boost_INCLUDE_DIR})

101
if(MSVC)
102
    add_definitions(-DBOOST_ALL_NO_LIB)
jpan's avatar
jpan committed
103
endif()
104
add_definitions(-DBOOST_TEST_DYN_LINK)
jpan's avatar
jpan committed
105

106
107
# FCL's own include dir should be at the front of the include path
include_directories(BEFORE "include")
108
include_directories("${CMAKE_CURRENT_BINARY_DIR}/include")
isucan's avatar
isucan committed
109

110
if(PKG_CONFIG_FOUND)
111
112
113
114
115
  pkg_check_modules(CCD ccd)
  # check to see if the pkg is installed under the libccd name
  if(NOT CCD_FOUND)
    pkg_check_modules(CCD libccd)
  endif()
116
endif()
117

118
119
120
121
122
123
124
125
126
127
128
129
130
if(NOT CCD_FOUND)
    # if pkfconfig is not installed, then fall back on more fragile detection
    # of ccd
    find_path(CCD_INCLUDE_DIRS ccd.h
        PATH_SUFFIXES ccd)
    find_path(CCD_LIBRARY_DIRS
        ${CMAKE_SHARED_LIBRARY_PREFIX}ccd${CMAKE_SHARED_LIBRARY_SUFFIX})
    if(CCD_INCLUDE_DIRS AND CCD_LIBRARY_DIRS)
        set(CCD_LIBRARIES "ccd")
    else()
        message(FATAL_ERROR "Libccd is required by FCL")
    endif()
endif()
isucan's avatar
isucan committed
131
132
133
include_directories(${CCD_INCLUDE_DIRS})
link_directories(${CCD_LIBRARY_DIRS})

isucan's avatar
isucan committed
134
135
add_subdirectory(include/fcl)
add_subdirectory(src)
isucan's avatar
isucan committed
136

137
138
139
set(pkg_conf_file_in "${CMAKE_CURRENT_SOURCE_DIR}/fcl.pc.in")
set(pkg_conf_file_out "${CMAKE_CURRENT_BINARY_DIR}/fcl.pc")
configure_file("${pkg_conf_file_in}" "${pkg_conf_file_out}" @ONLY)
isucan's avatar
isucan committed
140

isucan's avatar
isucan committed
141
install(DIRECTORY include/ DESTINATION include
142
  FILES_MATCHING PATTERN "*.h" PATTERN "*.hxx"
isucan's avatar
isucan committed
143
144
145
  PATTERN ".DS_Store" EXCLUDE
)

146
install(FILES "${pkg_conf_file_out}" DESTINATION lib/pkgconfig/ COMPONENT pkgconfig)
jpan's avatar
jpan committed
147
148
149


enable_testing()
150
add_subdirectory(test)