Use standard BUILD_SHARED_LIBS
Instead of custom GTSAM_BUILD_STATIC_LIBRARYrelease/4.3a0
							parent
							
								
									58ef0dceb6
								
							
						
					
					
						commit
						88bfbceb21
					
				|  | @ -55,7 +55,7 @@ endif() | |||
| if(GTSAM_UNSTABLE_AVAILABLE) | ||||
|     option(GTSAM_BUILD_UNSTABLE              "Enable/Disable libgtsam_unstable"          ON) | ||||
| endif() | ||||
| option(GTSAM_BUILD_STATIC_LIBRARY        "Build a static gtsam library, instead of shared" OFF) | ||||
| option(BUILD_SHARED_LIBS                 "Build shared gtsam library, instead of static" ON) | ||||
| option(GTSAM_USE_QUATERNIONS             "Enable/Disable using an internal Quaternion representation for rotations instead of rotation matrices. If enable, Rot3::EXPMAP is enforced by default." OFF) | ||||
| option(GTSAM_POSE3_EXPMAP 			 	 "Enable/Disable using Pose3::EXPMAP as the default mode. If disabled, Pose3::FIRST_ORDER will be used." OFF) | ||||
| option(GTSAM_ROT3_EXPMAP 			 	 "Ignore if GTSAM_USE_QUATERNIONS is OFF (Rot3::EXPMAP by default). Otherwise, enable Rot3::EXPMAP, or if disabled, use Rot3::CAYLEY." OFF) | ||||
|  | @ -84,8 +84,8 @@ if(GTSAM_INSTALL_WRAP AND NOT GTSAM_BUILD_WRAP) | |||
| 	message(FATAL_ERROR "GTSAM_INSTALL_WRAP is enabled, please also enable GTSAM_BUILD_WRAP") | ||||
| endif() | ||||
| 
 | ||||
| if(GTSAM_INSTALL_MATLAB_TOOLBOX AND GTSAM_BUILD_STATIC_LIBRARY) | ||||
| 	message(FATAL_ERROR "GTSAM_INSTALL_MATLAB_TOOLBOX and GTSAM_BUILD_STATIC_LIBRARY are both enabled.  The MATLAB wrapper cannot be compiled with a static GTSAM library because mex modules are themselves shared libraries.  If you want a self-contained mex module, enable GTSAM_MEX_BUILD_STATIC_MODULE instead of GTSAM_BUILD_STATIC_LIBRARY.") | ||||
| if(GTSAM_INSTALL_MATLAB_TOOLBOX AND NOT BUILD_SHARED_LIBS) | ||||
| 	message(FATAL_ERROR "GTSAM_INSTALL_MATLAB_TOOLBOX and BUILD_SHARED_LIBS=OFF. The MATLAB wrapper cannot be compiled with a static GTSAM library because mex modules are themselves shared libraries.  If you want a self-contained mex module, enable GTSAM_MEX_BUILD_STATIC_MODULE instead of BUILD_SHARED_LIBS=OFF.") | ||||
| endif() | ||||
| 
 | ||||
| if(GTSAM_BUILD_PYTHON AND GTSAM_ALLOW_DEPRECATED_SINCE_V4) | ||||
|  | @ -270,7 +270,7 @@ else() | |||
| endif() | ||||
| 
 | ||||
| if (MSVC) | ||||
| 	if (NOT GTSAM_BUILD_STATIC_LIBRARY) | ||||
| 	if (BUILD_SHARED_LIBS) | ||||
| 		# mute eigen static assert to avoid errors in shared lib | ||||
| 		add_definitions(-DEIGEN_NO_STATIC_ASSERT) | ||||
| 	endif() | ||||
|  | @ -479,7 +479,7 @@ print_config_flag(${GTSAM_BUILD_TIMING_ALWAYS}         "Build timing scripts wit | |||
| if (DOXYGEN_FOUND) | ||||
|     print_config_flag(${GTSAM_BUILD_DOCS}              "Build Docs                     ") | ||||
| endif() | ||||
| print_config_flag(${GTSAM_BUILD_STATIC_LIBRARY}        "Build static GTSAM library instead of shared") | ||||
| print_config_flag(${BUILD_SHARED_LIBS}                 "Build shared GTSAM libraries   ") | ||||
| print_config_flag(${GTSAM_BUILD_TYPE_POSTFIXES}        "Put build type in library name ") | ||||
| if(GTSAM_UNSTABLE_AVAILABLE) | ||||
|     print_config_flag(${GTSAM_BUILD_UNSTABLE}          "Build libgtsam_unstable        ") | ||||
|  |  | |||
|  | @ -31,10 +31,10 @@ | |||
| 
 | ||||
| // Whether GTSAM is compiled as static or DLL in windows. 
 | ||||
| // This will be used to decide whether include __declspec(dllimport) or not in headers
 | ||||
| #cmakedefine GTSAM_BUILD_STATIC_LIBRARY | ||||
| #cmakedefine BUILD_SHARED_LIBS | ||||
| 
 | ||||
| #ifdef _WIN32 | ||||
| #  ifdef @library_name@_BUILD_STATIC_LIBRARY | ||||
| #  ifndef BUILD_SHARED_LIBS | ||||
| #    define @library_name@_EXPORT | ||||
| #    define @library_name@_EXTERN_EXPORT extern | ||||
| #  else | ||||
|  | @ -50,3 +50,6 @@ | |||
| #  define @library_name@_EXPORT | ||||
| #  define @library_name@_EXTERN_EXPORT extern | ||||
| #endif | ||||
| 
 | ||||
| #undef BUILD_SHARED_LIBS | ||||
| 
 | ||||
|  |  | |||
|  | @ -97,48 +97,48 @@ message(STATUS "GTSAM Version: ${gtsam_version}") | |||
| message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}") | ||||
| 
 | ||||
| # build shared and static versions of the library | ||||
| if (GTSAM_BUILD_STATIC_LIBRARY) | ||||
|     message(STATUS "Building GTSAM - static") | ||||
|     add_library(gtsam STATIC ${gtsam_srcs}) | ||||
| 	target_link_libraries(gtsam ${GTSAM_BOOST_LIBRARIES} ${GTSAM_ADDITIONAL_LIBRARIES}) | ||||
|     set_target_properties(gtsam PROPERTIES | ||||
|         OUTPUT_NAME         gtsam | ||||
|         CLEAN_DIRECT_OUTPUT 1 | ||||
|     	VERSION             ${gtsam_version} | ||||
|      	SOVERSION           ${gtsam_soversion}) | ||||
| 	if(WIN32) # Add 'lib' prefix to static library to avoid filename collision with shared library | ||||
| message(STATUS "Building GTSAM - shared: ${BUILD_SHARED_LIBS}") | ||||
| 
 | ||||
| # BUILD_SHARED_LIBS automatically defines static/shared libs: | ||||
| add_library(gtsam ${gtsam_srcs}) | ||||
| target_link_libraries(gtsam | ||||
|     PUBLIC | ||||
|     ${GTSAM_BOOST_LIBRARIES} ${GTSAM_ADDITIONAL_LIBRARIES}) | ||||
| set_target_properties(gtsam PROPERTIES | ||||
|     OUTPUT_NAME         gtsam | ||||
|     CLEAN_DIRECT_OUTPUT 1 | ||||
|     VERSION             ${gtsam_version} | ||||
|     SOVERSION           ${gtsam_soversion}) | ||||
| 
 | ||||
| if(WIN32) # Add 'lib' prefix to static library to avoid filename collision with shared library | ||||
| 	if (NOT BUILD_SHARED_LIBS) | ||||
| 		set_target_properties(gtsam PROPERTIES | ||||
| 			PREFIX "lib" | ||||
| 			COMPILE_DEFINITIONS GTSAM_IMPORT_STATIC) | ||||
| 	endif() | ||||
|     install(TARGETS gtsam EXPORT GTSAM-exports ARCHIVE DESTINATION lib) | ||||
|     list(APPEND GTSAM_EXPORTED_TARGETS gtsam) | ||||
|     set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE) | ||||
| else() | ||||
|     message(STATUS "Building GTSAM - shared") | ||||
|     add_library(gtsam SHARED ${gtsam_srcs}) | ||||
|     target_link_libraries(gtsam ${GTSAM_BOOST_LIBRARIES} ${GTSAM_ADDITIONAL_LIBRARIES}) | ||||
|     set_target_properties(gtsam PROPERTIES | ||||
|         OUTPUT_NAME         gtsam | ||||
|         CLEAN_DIRECT_OUTPUT 1 | ||||
|     	VERSION             ${gtsam_version} | ||||
|      	SOVERSION           ${gtsam_soversion}) | ||||
| 	if(WIN32) | ||||
| 	else() | ||||
| 		set_target_properties(gtsam PROPERTIES | ||||
| 			PREFIX "" | ||||
| 			DEFINE_SYMBOL GTSAM_EXPORTS | ||||
| 			RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") | ||||
| 	endif() | ||||
| 	if (APPLE) | ||||
| 		set_target_properties(gtsam PROPERTIES | ||||
| 			INSTALL_NAME_DIR | ||||
| 			"${CMAKE_INSTALL_PREFIX}/lib") | ||||
| 	endif() | ||||
|     install(TARGETS gtsam EXPORT GTSAM-exports LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin) | ||||
|     list(APPEND GTSAM_EXPORTED_TARGETS gtsam) | ||||
|     set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE) | ||||
| endif() | ||||
| 
 | ||||
| if (APPLE AND BUILD_SHARED_LIBS) | ||||
| 	set_target_properties(gtsam PROPERTIES | ||||
| 		INSTALL_NAME_DIR | ||||
| 		"${CMAKE_INSTALL_PREFIX}/lib") | ||||
| endif() | ||||
| 
 | ||||
| install( | ||||
| 	TARGETS gtsam | ||||
| 	EXPORT GTSAM-exports | ||||
| 	LIBRARY DESTINATION lib | ||||
| 	ARCHIVE DESTINATION lib | ||||
| 	RUNTIME DESTINATION bin) | ||||
| 
 | ||||
| list(APPEND GTSAM_EXPORTED_TARGETS gtsam) | ||||
| set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE) | ||||
| 
 | ||||
| # make sure that ccolamd compiles even in face of warnings | ||||
| if(WIN32) | ||||
|     set_source_files_properties(${3rdparty_srcs} PROPERTIES COMPILE_FLAGS "-w") | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue