diff --git a/CMakeLists.txt b/CMakeLists.txt index 6db1f6681..115c8bb49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,7 +128,7 @@ option(GTSAM_DISABLE_NEW_TIMERS "Disables using Boost.chrono for timing" OFF) # Allow for not using the timer libraries on boost < 1.48 (GTSAM timing code falls back to old timer library) set(GTSAM_BOOST_LIBRARIES ${Boost_SERIALIZATION_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} - ${Boost_THREAD_LIBRARY} ${Boost_DATE_TIME_LIBRARY}) + ${Boost_THREAD_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_REGEX_LIBRARY}) if (GTSAM_DISABLE_NEW_TIMERS) message("WARNING: GTSAM timing instrumentation manually disabled") add_definitions(-DGTSAM_DISABLE_NEW_TIMERS) diff --git a/cmake/dllexport.h.in b/cmake/dllexport.h.in index 023f06f57..6539e869e 100644 --- a/cmake/dllexport.h.in +++ b/cmake/dllexport.h.in @@ -26,21 +26,28 @@ // class __declspec(dllexport) MyClass { ... }; // When included while compiling other code against GTSAM: // class __declspec(dllimport) MyClass { ... }; + +#pragma once + +// Whether GTSAM is compiled as static or DLL in windows. +// This will be used to decide whether include __declspec(dllimport) or not in headers +// TODO: replace GTSAM by @library_name@ +#cmakedefine GTSAM_BUILD_STATIC_LIBRARY + #ifdef _WIN32 -# ifdef @library_name@_EXPORTS -# define @library_name@_EXPORT __declspec(dllexport) -# define @library_name@_EXTERN_EXPORT __declspec(dllexport) extern -# else -# ifndef @library_name@_IMPORT_STATIC +# ifdef @library_name@_BUILD_STATIC_LIBRARY +# define @library_name@_EXPORT +# define @library_name@_EXTERN_EXPORT extern +# else /* @library_name@_BUILD_STATIC_LIBRARY */ +# ifdef @library_name@_EXPORTS +# define @library_name@_EXPORT __declspec(dllexport) +# define @library_name@_EXTERN_EXPORT __declspec(dllexport) extern +# else /* @library_name@_EXPORTS */ # define @library_name@_EXPORT __declspec(dllimport) # define @library_name@_EXTERN_EXPORT __declspec(dllimport) -# else /* @library_name@_IMPORT_STATIC */ -# define @library_name@_EXPORT -# define @library_name@_EXTERN_EXPORT extern -# endif /* @library_name@_IMPORT_STATIC */ -# endif /* @library_name@_EXPORTS */ +# endif /* @library_name@_EXPORTS */ +# endif /* @library_name@_BUILD_STATIC_LIBRARY */ #else /* _WIN32 */ # define @library_name@_EXPORT # define @library_name@_EXTERN_EXPORT extern #endif - diff --git a/gtsam/CMakeLists.txt b/gtsam/CMakeLists.txt index 8c1d8bb43..7cf801e74 100644 --- a/gtsam/CMakeLists.txt +++ b/gtsam/CMakeLists.txt @@ -110,8 +110,8 @@ if (GTSAM_BUILD_STATIC_LIBRARY) SOVERSION ${gtsam_soversion}) if(WIN32) # Add 'lib' prefix to static library to avoid filename collision with shared library set_target_properties(gtsam PROPERTIES - PREFIX "lib" - COMPILE_DEFINITIONS GTSAM_IMPORT_STATIC) + PREFIX "lib") + #COMPILE_DEFINITIONS GTSAM_IMPORT_STATIC) endif() install(TARGETS gtsam EXPORT GTSAM-exports ARCHIVE DESTINATION lib) list(APPEND GTSAM_EXPORTED_TARGETS gtsam)