static lib and examples compiles

release/4.3a0
Jing Dong 2017-05-19 18:51:14 -07:00
parent eb1e75fd27
commit 0f80f9bf41
3 changed files with 21 additions and 14 deletions

View File

@ -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) # Allow for not using the timer libraries on boost < 1.48 (GTSAM timing code falls back to old timer library)
set(GTSAM_BOOST_LIBRARIES set(GTSAM_BOOST_LIBRARIES
${Boost_SERIALIZATION_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${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) if (GTSAM_DISABLE_NEW_TIMERS)
message("WARNING: GTSAM timing instrumentation manually disabled") message("WARNING: GTSAM timing instrumentation manually disabled")
add_definitions(-DGTSAM_DISABLE_NEW_TIMERS) add_definitions(-DGTSAM_DISABLE_NEW_TIMERS)

View File

@ -26,21 +26,28 @@
// class __declspec(dllexport) MyClass { ... }; // class __declspec(dllexport) MyClass { ... };
// When included while compiling other code against GTSAM: // When included while compiling other code against GTSAM:
// class __declspec(dllimport) MyClass { ... }; // 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 _WIN32
# ifdef @library_name@_EXPORTS # ifdef @library_name@_BUILD_STATIC_LIBRARY
# define @library_name@_EXPORT __declspec(dllexport) # define @library_name@_EXPORT
# define @library_name@_EXTERN_EXPORT __declspec(dllexport) extern # define @library_name@_EXTERN_EXPORT extern
# else # else /* @library_name@_BUILD_STATIC_LIBRARY */
# ifndef @library_name@_IMPORT_STATIC # 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@_EXPORT __declspec(dllimport)
# define @library_name@_EXTERN_EXPORT __declspec(dllimport) # define @library_name@_EXTERN_EXPORT __declspec(dllimport)
# else /* @library_name@_IMPORT_STATIC */ # endif /* @library_name@_EXPORTS */
# define @library_name@_EXPORT # endif /* @library_name@_BUILD_STATIC_LIBRARY */
# define @library_name@_EXTERN_EXPORT extern
# endif /* @library_name@_IMPORT_STATIC */
# endif /* @library_name@_EXPORTS */
#else /* _WIN32 */ #else /* _WIN32 */
# define @library_name@_EXPORT # define @library_name@_EXPORT
# define @library_name@_EXTERN_EXPORT extern # define @library_name@_EXTERN_EXPORT extern
#endif #endif

View File

@ -110,8 +110,8 @@ if (GTSAM_BUILD_STATIC_LIBRARY)
SOVERSION ${gtsam_soversion}) SOVERSION ${gtsam_soversion})
if(WIN32) # Add 'lib' prefix to static library to avoid filename collision with shared library if(WIN32) # Add 'lib' prefix to static library to avoid filename collision with shared library
set_target_properties(gtsam PROPERTIES set_target_properties(gtsam PROPERTIES
PREFIX "lib" PREFIX "lib")
COMPILE_DEFINITIONS GTSAM_IMPORT_STATIC) #COMPILE_DEFINITIONS GTSAM_IMPORT_STATIC)
endif() endif()
install(TARGETS gtsam EXPORT GTSAM-exports ARCHIVE DESTINATION lib) install(TARGETS gtsam EXPORT GTSAM-exports ARCHIVE DESTINATION lib)
list(APPEND GTSAM_EXPORTED_TARGETS gtsam) list(APPEND GTSAM_EXPORTED_TARGETS gtsam)