diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bdbc486a..7198c5dfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,10 +52,18 @@ if(GTSAM_UNSTABLE_AVAILABLE) option(GTSAM_BUILD_UNSTABLE "Enable/Disable libgtsam_unstable" OFF) endif() option(GTSAM_BUILD_WRAP "Enable/Disable building of matlab wrap utility (necessary for matlab interface)" ON) -option(GTSAM_BUILD_SHARED_LIBRARY "Enable/Disable building of a shared version of gtsam" ON) +if(MSVC) + option(GTSAM_BUILD_SHARED_LIBRARY "Enable/Disable building of a shared version of gtsam" OFF) +else() + option(GTSAM_BUILD_SHARED_LIBRARY "Enable/Disable building of a shared version of gtsam" ON) +endif() option(GTSAM_BUILD_STATIC_LIBRARY "Enable/Disable building of a static version of gtsam" ON) option(GTSAM_USE_QUATERNIONS "Enable/Disable using an internal Quaternion representation for rotations instead of rotation matrices" OFF) -option(GTSAM_BUILD_CONVENIENCE_LIBRARIES "Enable/Disable use of convenience libraries for faster development rebuilds, but slower install" ON) +if(MSVC) + option(GTSAM_BUILD_CONVENIENCE_LIBRARIES "Enable/Disable use of convenience libraries for faster development rebuilds, but slower install" OFF) +else() + option(GTSAM_BUILD_CONVENIENCE_LIBRARIES "Enable/Disable use of convenience libraries for faster development rebuilds, but slower install" ON) +endif() option(GTSAM_INSTALL_MATLAB_TOOLBOX "Enable/Disable installation of matlab toolbox" ON) option(GTSAM_INSTALL_MATLAB_EXAMPLES "Enable/Disable installation of matlab examples" ON) option(GTSAM_INSTALL_MATLAB_TESTS "Enable/Disable installation of matlab tests" ON) @@ -97,7 +105,7 @@ endif() if(MSVC) set(Boost_USE_STATIC_LIBS 1) endif() -find_package(Boost 1.40 COMPONENTS serialization REQUIRED) +find_package(Boost 1.40 COMPONENTS serialization system chrono REQUIRED) # General build settings include_directories( diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 116379489..00a93904a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -15,7 +15,9 @@ foreach(example_src ${example_srcs} ) endif() target_link_libraries(${example_bin} gtsam-static) - add_custom_target(${example_bin}.run ${EXECUTABLE_OUTPUT_PATH}${example_bin} ${ARGN}) + if(NOT MSVC) + add_custom_target(${example_bin}.run ${EXECUTABLE_OUTPUT_PATH}${example_bin} ${ARGN}) + endif() endforeach(example_src) add_subdirectory(vSLAMexample) diff --git a/gtsam/CMakeLists.txt b/gtsam/CMakeLists.txt index 2adc83365..e0cc0eae1 100644 --- a/gtsam/CMakeLists.txt +++ b/gtsam/CMakeLists.txt @@ -46,6 +46,8 @@ endif() foreach(subdir ${gtsam_subdirs}) # Build convenience libraries file(GLOB subdir_srcs "${subdir}/*.cpp") + file(GLOB subdir_headers "${subdir}/*.h") + set(subdir_srcs ${subdir_srcs} ${subdir_headers}) # Include header files so they show up in Visual Studio list(REMOVE_ITEM subdir_srcs ${excluded_sources}) set(${subdir}_srcs ${subdir_srcs}) if (GTSAM_BUILD_CONVENIENCE_LIBRARIES) @@ -71,7 +73,11 @@ set(gtsam_srcs ${slam_srcs} ) -#gtsam_assign_source_folders("${gtsam_srcs}") +# Create MSVC structure +file(GLOB_RECURSE all_c_srcs "*.c") +file(GLOB_RECURSE all_cpp_srcs "*.cpp") +file(GLOB_RECURSE all_headers "*.h") +gtsam_assign_source_folders("${all_c_srcs};${all_cpp_srcs};${all_headers}") # Versions set(gtsam_version ${GTSAM_VERSION_MAJOR}.${GTSAM_VERSION_MINOR}.${GTSAM_VERSION_PATCH}) @@ -83,6 +89,7 @@ message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}") if (GTSAM_BUILD_STATIC_LIBRARY) message(STATUS "Building GTSAM - static") add_library(gtsam-static STATIC ${gtsam_srcs}) + target_link_libraries(gtsam-static ${Boost_LIBRARIES}) set_target_properties(gtsam-static PROPERTIES OUTPUT_NAME gtsam CLEAN_DIRECT_OUTPUT 1 @@ -94,6 +101,7 @@ endif (GTSAM_BUILD_STATIC_LIBRARY) if (GTSAM_BUILD_SHARED_LIBRARY) message(STATUS "Building GTSAM - shared") add_library(gtsam-shared SHARED ${gtsam_srcs}) + target_link_libraries(gtsam-shared ${Boost_LIBRARIES}) set_target_properties(gtsam-shared PROPERTIES OUTPUT_NAME gtsam CLEAN_DIRECT_OUTPUT 1 diff --git a/gtsam/slam/CMakeLists.txt b/gtsam/slam/CMakeLists.txt index c25e32bd4..768ab2307 100644 --- a/gtsam/slam/CMakeLists.txt +++ b/gtsam/slam/CMakeLists.txt @@ -24,6 +24,10 @@ if (GTSAM_BUILD_TESTS) gtsam_add_subdir_tests(slam "${slam_local_libs}" "gtsam-static" "${slam_excluded_files}") endif(GTSAM_BUILD_TESTS) +if(MSVC) + add_definitions("/bigobj") +endif() + # Build timing scripts if (GTSAM_BUILD_TIMING) gtsam_add_subdir_timing(slam "${slam_local_libs}" "gtsam-static" "${slam_excluded_files}")