Permalink
Browse files

Removed the disgusting MERGE_STATIC_LIBRARIES and all uses of it.

Now when libstp is built the boost-library will not be merged in to
it. CMake clients of libstp

* the stp executable
* Any CMake project that imports our targets

will automatically know which Boost libraries to link in.

Clients of libstp (e.g. KLEE )who do not use CMake will now have to link
in the right Boost libraries manually to their application
  • Loading branch information...
1 parent ec7a1f5 commit 66bf4298f653297f632311efb66145ae1955070f @delcypher delcypher committed Jan 25, 2014
View
@@ -171,10 +171,6 @@ get_git_head_revision(GIT_REFSPEC GIT_SHA1)
# -----------------------------------------------------------------------------
if(NOT BUILD_SHARED_LIBS)
- # If we are building libstp as static we will want to
- # make sure there are no unresolved symbols to Boost
- # library functions. Later we'll merge them into the
- # archive so we'll need static boost libraries.
message("Trying to use static Boost libraries")
set(Boost_USE_STATIC_LIBS ON)
endif()
@@ -1,81 +0,0 @@
-# This macro creates a true static library bundle with debug and release configurations
-# TARGET - the output library, or target, that you wish to contain all of the object files
-# CONFIGURATION - DEBUG, RELEASE or ALL
-# LIBRARIES - a list of all of the static libraries you want merged into the TARGET
-#
-# Example use:
-# MERGE_STATIC_LIBRARIES (mytarget ALL "${MY_STATIC_LIBRARIES}")
-#
-# NOTE: When you call this script, make sure you quote the argument to LIBRARIES if it is a list!
-
-macro (MERGE_STATIC_LIBRARIES TARGET CONFIGURATION LIBRARIES)
- if (WIN32)
- # On Windows you must add aditional formatting to the LIBRARIES variable as a single string for the windows libtool
- # with each library path wrapped in "" in case it contains spaces
- string (REPLACE ";" "\" \"" LIBS "${LIBRARIES}")
- set (LIBS \"${LIBS}\")
-
- if(${CONFIGURATION} STREQUAL "DEBUG")
- set_property (TARGET ${TARGET} APPEND PROPERTY STATIC_LIBRARY_FLAGS_DEBUG "${LIBS}")
- elseif (${CONFIGURATION} STREQUAL "RELEASE")
- set_property (TARGET ${TARGET} APPEND PROPERTY STATIC_LIBRARY_FLAGS_RELEASE "${LIBS}")
- elseif (${CONFIGURATION} STREQUAL "RELWITHDEBINFO")
- set_property (TARGET ${TARGET} APPEND PROPERTY STATIC_LIBRARY_FLAGS_RELWITHDEBINFO "${LIBS}")
- elseif (${CONFIGURATION} STREQUAL "ALL")
- set_property (TARGET ${TARGET} APPEND PROPERTY STATIC_LIBRARY_FLAGS "${LIBS}")
- else (${CONFIGURATION} STREQUAL "DEBUG")
- message (FATAL_ERROR "Be sure to set the CONFIGURATION argument to DEBUG, RELEASE or ALL")
- endif(${CONFIGURATION} STREQUAL "DEBUG")
- elseif (APPLE AND ${CMAKE_GENERATOR} STREQUAL "Xcode")
- # iOS and OSX platforms with Xcode need slighly less formatting
- string (REPLACE ";" " " LIBS "${LIBRARIES}")
-
- if(${CONFIGURATION} STREQUAL "DEBUG")
- set_property (TARGET ${TARGET} APPEND PROPERTY STATIC_LIBRARY_FLAGS_DEBUG "${LIBS}")
- elseif (${CONFIGURATION} STREQUAL "RELEASE")
- set_property (TARGET ${TARGET} APPEND PROPERTY STATIC_LIBRARY_FLAGS_RELEASE "${LIBS}")
- elseif (${CONFIGURATION} STREQUAL "RELWITHDEBINFO")
- set_property (TARGET ${TARGET} APPEND PROPERTY STATIC_LIBRARY_FLAGS_RELWITHDEBINFO "${LIBS}")
- elseif (${CONFIGURATION} STREQUAL "ALL")
- set_property (TARGET ${TARGET} APPEND PROPERTY STATIC_LIBRARY_FLAGS "${LIBS}")
- else (${CONFIGURATION} STREQUAL "DEBUG")
- message (FATAL_ERROR "Be sure to set the CONFIGURATION argument to DEBUG, RELEASE or ALL")
- endif(${CONFIGURATION} STREQUAL "DEBUG")
- elseif (UNIX)
- # Posix platforms, including Android, require manual merging of static libraries via a special script
- set (LIBRARIES ${LIBRARIES})
-
- if (NOT CMAKE_BUILD_TYPE)
- message (FATAL_ERROR "To use the MergeStaticLibraries script on Posix systems, you MUST define your CMAKE_BUILD_TYPE")
- endif (NOT CMAKE_BUILD_TYPE)
-
- set (MERGE OFF)
-
- # We need the debug postfix on posix systems for the merge script
- string (TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
- if (${BUILD_TYPE} STREQUAL ${CONFIGURATION} OR ${CONFIGURATION} STREQUAL "ALL")
- if (${BUILD_TYPE} STREQUAL "DEBUG")
- get_target_property (TARGETLOC ${TARGET} LOCATION_DEBUG)
- else ()
- get_target_property (TARGETLOC ${TARGET} LOCATION)
- endif ()
- set (MERGE ON)
- endif()
-
- # Setup the static library merge script
- if (NOT MERGE)
- message (STATUS "MergeStaticLibraries ignores mismatch betwen BUILD_TYPE=${BUILD_TYPE} and CONFIGURATION=${CONFIGURATION}")
- message(STATUS "damn")
- else (NOT MERGE)
- configure_file (
- ${PROJECT_SOURCE_DIR}/cmake/modules/PosixMergeStaticLibraries.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/PosixMergeStaticLibraries-${TARGET}.cmake @ONLY
- )
- # Use existing target
- add_custom_command (TARGET ${TARGET} POST_BUILD
- COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/PosixMergeStaticLibraries-${TARGET}.cmake
- )
- message(STATUS "OK ${TARGET} command added")
- endif (NOT MERGE)
- endif (WIN32)
-endmacro (MERGE_STATIC_LIBRARIES)
@@ -1,40 +0,0 @@
-# A configurable script that unarchives TARGET and all LIBRARIES
-# and then merges them back into a single TARGET using the proper ar tool
-
-# Setup
-set (TARGETLOC "@TARGETLOC@")
-set (LIBRARIES @LIBRARIES@) # Do NOT quote libraries since we need to loop over the list
-set (CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@")
-set (CMAKE_AR "@CMAKE_AR@")
-set (CMAKE_RANLIB "@CMAKE_RANLIB@")
-unset (AROBJS)
-get_filename_component (TARGETNAME ${TARGETLOC} NAME)
-set (ARDIR ${CMAKE_CURRENT_BINARY_DIR}/PosixMergeStaticLibraries-${TARGETNAME})
-make_directory (${ARDIR})
-
-# Extract every dependent library into a series of object files
-foreach (LIB ${LIBRARIES})
- get_filename_component (LIBNAME ${LIB} NAME)
- file (MAKE_DIRECTORY ${ARDIR}/${LIBNAME})
- execute_process (
- COMMAND ${CMAKE_AR} x ${LIB} WORKING_DIRECTORY ${ARDIR}/${LIBNAME}
- )
- message(STATUS "Executed COMMAND ${CMAKE_AR} x ${LIB} WORKING_DIRECTORY ${ARDIR}/${LIBNAME}")
- file (GLOB_RECURSE OBJS "${ARDIR}/${LIBNAME}/*")
- set (AROBJS ${AROBJS} ${OBJS})
-endforeach (LIB)
-
-# Merge all extracted object files into the existing target archive
-execute_process (
- COMMAND ${CMAKE_AR} r ${TARGETLOC} ${AROBJS} WORKING_DIRECTORY ${ARDIR}
-)
-message(STATUS "COMMAND ${CMAKE_AR} r ${TARGETLOC} ${AROBJS} WORKING_DIRECTORY ${ARDIR}")
-
-# Ranlib the new archive library
-execute_process (
- COMMAND ${CMAKE_RANLIB} ${TARGETLOC} WORKING_DIRECTORY ${ARDIR}
-)
-message(STATUS "executed COMMAND ${CMAKE_RANLIB} ${TARGETLOC} WORKING_DIRECTORY ${ARDIR}")
-
-# Delete all leftover object files
-file (REMOVE_RECURSE ${ARDIR})
View
@@ -45,15 +45,20 @@ set_target_properties(libstp PROPERTIES
)
-# Sort out Boost dependency
-if(BUILD_SHARED_LIBS)
- message(STATUS "Boost dynamic libraries will be linked to client library")
- target_link_libraries(libstp ${Boost_LIBRARIES})
-else()
- message(STATUS "Boost static libraries will be embedded in client library")
- include(MergeStaticLibraries)
- MERGE_STATIC_LIBRARIES(libstp ALL "${Boost_LIBRARIES}")
-endif()
+# -----------------------------------------------------------------------------
+# On non-windows systems a built static library cannot have another static
+# library linked to it. So this does not cause the Boost libraries to be
+# added to ``libstp.a``. Instead what this does is tell CMake that anything
+# that we built that uses the ``libstp`` target should also link in these
+# Boost libraries.
+#
+# So the stp executable and any clients of libstp that use the exported CMake
+# targets (e.g. examples/simple) will know what to link in.
+#
+# Clients of libstp that don't use CMake will have to link the Boost libraries
+# in manually.
+# -----------------------------------------------------------------------------
+target_link_libraries(libstp ${Boost_LIBRARIES})
# -----------------------------------------------------------------------------

0 comments on commit 66bf429

Please sign in to comment.