diff --git a/.cproject b/.cproject
index a456f1ab6..64b368108 100644
--- a/.cproject
+++ b/.cproject
@@ -1690,6 +1690,14 @@
false
true
+
+ make
+ -j2
+ install
+ true
+ true
+ true
+
make
-j2
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 408e0c6bd..094fcd59a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,18 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt. ")
endif()
+# guard against bad build-type strings
+if (NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Debug")
+endif()
+
+string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_tolower)
+if( NOT cmake_build_type_tolower STREQUAL "debug"
+ AND NOT cmake_build_type_tolower STREQUAL "release"
+ AND NOT cmake_build_type_tolower STREQUAL "relwithdebinfo")
+ message(FATAL_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\". Allowed values are Debug, Release, RelWithDebInfo (case-insensitive).")
+endif()
+
# Turn off function inlining when debugging
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-inline -Wall")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-inline -Wall")
diff --git a/gtsam/3rdparty/CMakeLists.txt b/gtsam/3rdparty/CMakeLists.txt
new file mode 100644
index 000000000..3b2d4d178
--- /dev/null
+++ b/gtsam/3rdparty/CMakeLists.txt
@@ -0,0 +1,15 @@
+# install CCOLAMD headers
+install(FILES CCOLAMD/Include/ccolamd.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gtsam/3rdparty/CCOLAMD)
+install(FILES UFconfig/UFconfig.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gtsam/3rdparty/UFconfig)
+
+# install Eigen - only the headers
+install(DIRECTORY Eigen/Eigen
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gtsam/3rdparty/Eigen
+ FILES_MATCHING PATTERN "*.h")
+file(GLOB eigen_dir_headers_all "Eigen/Eigen/*")
+foreach(eigen_dir ${eigen_dir_headers_all})
+ get_filename_component(filename ${eigen_dir} NAME)
+ if (NOT ((${filename} MATCHES "CMakeLists.txt") OR (${filename} MATCHES "src")))
+ install(FILES Eigen/Eigen/${filename} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gtsam/3rdparty/Eigen/Eigen)
+ endif()
+endforeach(eigen_dir)
\ No newline at end of file
diff --git a/gtsam/CMakeLists.txt b/gtsam/CMakeLists.txt
index 0a027dfda..5b795b11f 100644
--- a/gtsam/CMakeLists.txt
+++ b/gtsam/CMakeLists.txt
@@ -12,12 +12,12 @@ set (ccolamd_srcs
3rdparty/CCOLAMD/Source/ccolamd.c
3rdparty/CCOLAMD/Source/ccolamd_global.c
3rdparty/UFconfig/UFconfig.c)
-
+
+# install headers from 3rdparty libraries
+add_subdirectory(3rdparty)
+
+# Accumulate gtsam_srcs
set(gtsam_srcs ${ccolamd_srcs})
-
-# ccolamd convenience library
-#add_library(ccolamd STATIC ${ccolamd_srcs})
-#list(APPEND inner_libs ccolamd)
# Get all sources and headers from each
foreach(subdir ${gtsam_subdirs})
@@ -25,23 +25,18 @@ foreach(subdir ${gtsam_subdirs})
file(GLOB sub_gtsam_srcs "${subdir}/*.cpp")
list(APPEND gtsam_srcs ${sub_gtsam_srcs})
- # Make a convenience library
- # add_library(${subdir} STATIC ${sub_gtsam_srcs})
- # list(APPEND inner_libs ${subdir})
+ # install headers
+ file(GLOB sub_gtsam_headers "${subdir}/*.h")
+ install(FILES ${sub_gtsam_headers} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gtsam/${subdir})
# Build tests
file(GLOB tests_srcs "${subdir}/tests/test*.cpp")
foreach(test_src ${tests_srcs})
get_filename_component(test_base ${test_src} NAME_WE)
- # Trying to put the executables in the right place
- #set( test_bin ${EXECUTABLE_OUTPUT_PATH}${subdir}/${test_base} )
set( test_bin ${subdir}_${test_base} )
add_executable(${test_bin} EXCLUDE_FROM_ALL ${test_src})
add_dependencies(check ${test_bin})
add_test(${subdir}/${test_base} ${EXECUTABLE_OUTPUT_PATH}${test_bin})
-
- #Linking: would like to link against subset of convenience libraries
- #target_link_libraries(${test_bin} CppUnitLite ${inner_libs})
target_link_libraries(${test_bin} CppUnitLite gtsam)
add_custom_target(${test_bin}.run ${EXECUTABLE_OUTPUT_PATH}${test_bin} ${ARGN})
endforeach(test_src)
@@ -60,4 +55,5 @@ endforeach(subdir)
# build a single shared library
add_library(gtsam SHARED ${gtsam_srcs})
+install(TARGETS gtsam LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
diff --git a/wrap/CMakeLists.txt b/wrap/CMakeLists.txt
index c28a1e006..b6bf8b4f9 100644
--- a/wrap/CMakeLists.txt
+++ b/wrap/CMakeLists.txt
@@ -1,14 +1,15 @@
# Build/install Wrap
# Build the executable itself
-FILE(GLOB wrap_srcs "*.cpp")
-LIST(REMOVE_ITEM wrap_srcs wrap.cpp)
+file(GLOB wrap_srcs "*.cpp")
+list(REMOVE_ITEM wrap_srcs wrap.cpp)
add_library(wrapLib STATIC ${wrap_srcs})
add_executable(wrap wrap.cpp)
target_link_libraries(wrap wrapLib)
+install(TARGETS wrap DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
# Build tests
-FILE(GLOB wrap_test_srcs "tests/test*.cpp")
+file(GLOB wrap_test_srcs "tests/test*.cpp")
add_definitions(-DTOPSRCDIR="${CMAKE_SOURCE_DIR}")
foreach(test_src ${wrap_test_srcs} )
get_filename_component(test_base ${test_src} NAME_WE)
@@ -20,5 +21,5 @@ foreach(test_src ${wrap_test_srcs} )
add_custom_target(${test_bin}.run ${EXECUTABLE_OUTPUT_PATH}${test_bin} ${ARGN})
endforeach(test_src)
-
-
+# Install matlab header
+install(FILES matlab.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/wrap)