- allow to build a shared and a static version of the libraries
authorMichael Schroeder <mls@suse.de>
Thu, 26 May 2011 12:53:12 +0000 (14:53 +0200)
committerMichael Schroeder <mls@suse.de>
Thu, 26 May 2011 12:53:12 +0000 (14:53 +0200)
CMakeLists.txt
VERSION.cmake
examples/CMakeLists.txt
ext/CMakeLists.txt
src/CMakeLists.txt
tools/CMakeLists.txt

index 618be03560cca7a2e075d3951340920b8fef2d3d..72677de54e9db912b36d5489bd70bce5b33a121f 100644 (file)
@@ -1,13 +1,16 @@
 PROJECT (libsolv)
 
-cmake_minimum_required (VERSION 2.4)
+CMAKE_MINIMUM_REQUIRED (VERSION 2.4)
+
+OPTION(ENABLE_STATIC "Build a static version of the libraries?" OFF)
+OPTION(DISABLE_SHARED "Do not build a shared version of the libraries?" OFF)
 
 #IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
 #ENDIF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERISION} GREATER 2.4)
 
 IF (COMMAND cmake_policy)
   # escape preprocessor, see -DVERSION below
-  cmake_policy (SET CMP0005 OLD)
+  CMAKE_POLICY (SET CMP0005 OLD)
 ENDIF (COMMAND cmake_policy)
 
 # Library
@@ -109,7 +112,7 @@ ADD_DEFINITIONS (-D_FILE_OFFSET_BITS=64)
 ADD_DEFINITIONS (-DVERSION=\\\"${VERSION}\\\")
 CONFIGURE_FILE (src/satversion.h.in src/satversion.h)
 
-SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY "SAT Solver library")
+SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Package dependency solver library")
 SET (CPACK_PACKAGE_VENDOR "SUSE")
 SET (CPACK_PACKAGE_VERSION_MAJOR ${LIBSOLV_MAJOR})
 SET (CPACK_PACKAGE_VERSION_MINOR ${LIBSOLV_MINOR})
@@ -161,14 +164,6 @@ SET (CPACK_SOURCE_IGNORE_FILES
 
 INCLUDE(CPack)
 
-####################################################################
-
-SET (DOC_INSTALL_DIR
-   "${CMAKE_INSTALL_PREFIX}/share/doc/packages/${PACKAGE}"
-   CACHE PATH "The install dir for documentation (default prefix/share/doc/packages/${PACKAGE})"
-   FORCE
-)
-
 ####################################################################
 # INCLUDES                                                         #
 ####################################################################
@@ -178,9 +173,9 @@ INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOU
 
 ####################################################################
 
-MESSAGE (STATUS "Looking modules in ${CMAKE_MODULE_PATH}")
+MESSAGE (STATUS "Looking for modules in ${CMAKE_MODULE_PATH}")
 
-set (CMAKE_C_FLAGS     "${CMAKE_C_FLAGS} -Werror -Wall")
+set (CMAKE_C_FLAGS     "${CMAKE_C_FLAGS} -Werror -Wall -Wl,--as-needed")
 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -g -O3")
 set (CMAKE_C_FLAGS_DEBUG     "${CMAKE_C_FLAGS} -g3 -O0")
 
index d11f403128ccf83804fbac57bd92e135aee7b512..2dc7a4c76c119da4bf8c034d58f02536a8f0f931 100644 (file)
@@ -44,6 +44,9 @@
 #    set COMPATMINOR to MINOR. (binary incompatible change)
 #
 
+SET(LIBSOLV_SOVERSION "0")
+SET(LIBSOLVEXT_SOVERSION "0")
+
 SET(LIBSOLV_MAJOR "0")
 SET(LIBSOLV_MINOR "0")
 SET(LIBSOLV_PATCH "0")
index c3264a9646a7eefc0f6d11a9c32efd6c758a8bb4..1d69d2128dacf9b69925fe1502804b10792d3d0a 100644 (file)
@@ -1,9 +1,11 @@
+# as we link with --as-needed we do not get bogus dependencies
+SET (SYSTEM_LIBRARIES ${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
+IF (NOT DEBIAN)
+SET (SYSTEM_LIBRARIES ${RPMDB_LIBRARY} ${SYSTEM_LIBRARIES})
+ENDIF (NOT DEBIAN)
+
 ADD_EXECUTABLE (solv solv.c)
-IF (DEBIAN)
-TARGET_LINK_LIBRARIES (solv libsolvext libsolv ${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
-ELSE (DEBIAN)
-TARGET_LINK_LIBRARIES (solv libsolvext libsolv ${RPMDB_LIBRARY} ${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
-ENDIF (DEBIAN)
+TARGET_LINK_LIBRARIES (solv libsolvext libsolv ${SYSTEM_LIBRARIES})
 
 INSTALL(TARGETS
     solv
index f444667560cadd67fb2c2a5e69fb81e2f6506f4d..687ff92c1bdd45150ce4adb9dbf0802b07b4cd19 100644 (file)
@@ -4,13 +4,10 @@ SET (libsolvext_SRCS
     repo_susetags.c repo_updateinfoxml.c repo_write.c repo_zyppdb.c
     repo_deb.c sat_xfopen.c)
 IF (NOT DEBIAN)
-SET (libsolvext_SRCS
-    ${libsolvext_SRCS} pool_fileconflicts.c repo_rpmdb.c)
+SET (libsolvext_SRCS ${libsolvext_SRCS}
+    pool_fileconflicts.c repo_rpmdb.c)
 ENDIF (NOT DEBIAN)
 
-ADD_LIBRARY (libsolvext STATIC ${libsolvext_SRCS})
-SET_TARGET_PROPERTIES(libsolvext PROPERTIES OUTPUT_NAME "solvext")
-
 SET (libsolvext_HEADERS
     pool_fileconflicts.h repo_content.h repo_deltainfoxml.h repo_helix.h repo_products.h
     repo_releasefile_products.h repo_repomdxml.h repo_rpmdb.h repo_rpmmd.h
@@ -20,5 +17,21 @@ SET (libsolvext_HEADERS
 SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
 SET (CMAKE_SHARED_LINKER_FLAGS "${LINK_FLAGS} -Wl,--version-script=${CMAKE_SOURCE_DIR}/ext/libsolvext.ver")
 
+IF (DISABLE_SHARED)
+ADD_LIBRARY (libsolvext STATIC ${libsolvext_SRCS})
+ELSE (DISABLE_SHARED)
+ADD_LIBRARY (libsolvext SHARED ${libsolvext_SRCS})
+ENDIF (DISABLE_SHARED)
+
+SET_TARGET_PROPERTIES(libsolvext PROPERTIES OUTPUT_NAME "solvext")
+SET_TARGET_PROPERTIES(libsolvext PROPERTIES SOVERSION ${LIBSOLVEXT_SOVERSION})
+
 INSTALL (FILES ${libsolvext_HEADERS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/solv")
 INSTALL (TARGETS libsolvext LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
+
+IF (ENABLE_STATIC AND NOT DISABLE_SHARED)
+ADD_LIBRARY (libsolvext_static STATIC ${libsolvext_SRCS})
+SET_TARGET_PROPERTIES(libsolvext_static PROPERTIES OUTPUT_NAME "solvext")
+SET_TARGET_PROPERTIES(libsolvext_static PROPERTIES SOVERSION ${LIBSOLVEXT_SOVERSION})
+INSTALL (TARGETS libsolvext_static LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
+ENDIF (ENABLE_STATIC AND NOT DISABLE_SHARED)
index 2966e6a3cffbeaa0d4496348dbf8e7c366815ad5..075d0a7f2e2bf257482554f7e792824d80cd690b 100644 (file)
@@ -18,9 +18,6 @@ SET (libsolv_SRCS
     transaction.c rules.c problems.c
     chksum.c md5.c sha1.c sha2.c satversion.c)
 
-ADD_LIBRARY (libsolv STATIC ${libsolv_SRCS})
-SET_TARGET_PROPERTIES(libsolv PROPERTIES OUTPUT_NAME "solv")
-
 SET (libsolv_HEADERS
     bitmap.h evr.h hash.h policy.h poolarch.h poolvendor.h pool.h
     poolid.h pooltypes.h queue.h solvable.h solver.h solverdebug.h
@@ -31,5 +28,21 @@ SET (libsolv_HEADERS
 SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
 SET (CMAKE_SHARED_LINKER_FLAGS "${LINK_FLAGS} -Wl,--version-script=${CMAKE_SOURCE_DIR}/src/libsolv.ver")
 
+IF (DISABLE_SHARED)
+ADD_LIBRARY (libsolv STATIC ${libsolv_SRCS})
+ELSE (DISABLE_SHARED)
+ADD_LIBRARY (libsolv SHARED ${libsolv_SRCS})
+ENDIF (DISABLE_SHARED)
+
+SET_TARGET_PROPERTIES(libsolv PROPERTIES OUTPUT_NAME "solv")
+SET_TARGET_PROPERTIES(libsolv PROPERTIES SOVERSION ${LIBSOLV_SOVERSION})
+
 INSTALL (FILES ${libsolv_HEADERS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/solv")
 INSTALL (TARGETS libsolv LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
+
+IF (ENABLE_STATIC AND NOT DISABLE_SHARED)
+ADD_LIBRARY (libsolv_static STATIC ${libsolv_SRCS})
+SET_TARGET_PROPERTIES(libsolv_static PROPERTIES OUTPUT_NAME "solv")
+SET_TARGET_PROPERTIES(libsolv_static PROPERTIES SOVERSION ${LIBSOLV_SOVERSION})
+INSTALL (TARGETS libsolv_static LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
+ENDIF (ENABLE_STATIC AND NOT DISABLE_SHARED)
index 18071a2a35fff972db27081206d921404273f3dc..f1aac8619d84d4887a562117034e03cef9a92911 100644 (file)
@@ -4,47 +4,52 @@
 
 ADD_LIBRARY (toolstuff STATIC common_write.c)
 
+# as we link with --as-needed we do not get bogus dependencies
+SET (SYSTEM_LIBRARIES ${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
+IF (NOT DEBIAN)
+SET (SYSTEM_LIBRARIES ${RPMDB_LIBRARY} ${SYSTEM_LIBRARIES})
+ENDIF (NOT DEBIAN)
+
 IF (NOT DEBIAN)
 ADD_EXECUTABLE (rpmdb2solv rpmdb2solv.c)
-TARGET_LINK_LIBRARIES (rpmdb2solv toolstuff libsolvext libsolv ${RPMDB_LIBRARY} ${EXPAT_LIBRARY})
+TARGET_LINK_LIBRARIES (rpmdb2solv toolstuff libsolvext libsolv ${SYSTEM_LIBRARIES})
 
 ADD_EXECUTABLE (rpms2solv rpms2solv.c)
-TARGET_LINK_LIBRARIES (rpms2solv toolstuff libsolvext libsolv ${RPMDB_LIBRARY})
+TARGET_LINK_LIBRARIES (rpms2solv toolstuff libsolvext libsolv ${SYSTEM_LIBRARIES})
 
 ADD_EXECUTABLE (findfileconflicts findfileconflicts.c)
-TARGET_LINK_LIBRARIES (findfileconflicts libsolvext libsolv ${RPMDB_LIBRARY})
-
+TARGET_LINK_LIBRARIES (findfileconflicts libsolvext libsolv ${SYSTEM_LIBRARIES})
 ENDIF (NOT DEBIAN)
 
 ADD_EXECUTABLE (rpmmd2solv rpmmd2solv.c)
-TARGET_LINK_LIBRARIES (rpmmd2solv toolstuff libsolvext libsolv ${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
+TARGET_LINK_LIBRARIES (rpmmd2solv toolstuff libsolvext libsolv ${SYSTEM_LIBRARIES})
 
 ADD_EXECUTABLE (helix2solv helix2solv.c)
-TARGET_LINK_LIBRARIES (helix2solv toolstuff libsolvext libsolv ${EXPAT_LIBRARY})
+TARGET_LINK_LIBRARIES (helix2solv toolstuff libsolvext libsolv ${SYSTEM_LIBRARIES})
 
 ADD_EXECUTABLE (susetags2solv susetags2solv.c)
-TARGET_LINK_LIBRARIES (susetags2solv toolstuff libsolvext libsolv ${ZLIB_LIBRARY})
+TARGET_LINK_LIBRARIES (susetags2solv toolstuff libsolvext libsolv ${SYSTEM_LIBRARIES})
 
 ADD_EXECUTABLE (updateinfoxml2solv updateinfoxml2solv.c)
-TARGET_LINK_LIBRARIES (updateinfoxml2solv toolstuff libsolvext libsolv ${EXPAT_LIBRARY})
+TARGET_LINK_LIBRARIES (updateinfoxml2solv toolstuff libsolvext libsolv ${SYSTEM_LIBRARIES})
 
 ADD_EXECUTABLE (deltainfoxml2solv deltainfoxml2solv.c)
-TARGET_LINK_LIBRARIES (deltainfoxml2solv toolstuff libsolvext libsolv ${EXPAT_LIBRARY})
+TARGET_LINK_LIBRARIES (deltainfoxml2solv toolstuff libsolvext libsolv ${SYSTEM_LIBRARIES})
 
 ADD_EXECUTABLE (repomdxml2solv repomdxml2solv.c)
-TARGET_LINK_LIBRARIES (repomdxml2solv toolstuff libsolvext libsolv ${EXPAT_LIBRARY})
+TARGET_LINK_LIBRARIES (repomdxml2solv toolstuff libsolvext libsolv ${SYSTEM_LIBRARIES})
 
 ADD_EXECUTABLE (installcheck installcheck.c)
-TARGET_LINK_LIBRARIES (installcheck libsolvext libsolv ${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
+TARGET_LINK_LIBRARIES (installcheck libsolvext libsolv ${SYSTEM_LIBRARIES})
 
 ADD_EXECUTABLE (patchcheck patchcheck.c)
-TARGET_LINK_LIBRARIES (patchcheck libsolvext libsolv ${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
+TARGET_LINK_LIBRARIES (patchcheck libsolvext libsolv ${SYSTEM_LIBRARIES})
 
 ADD_EXECUTABLE (dumpsolv dumpsolv.c )
 TARGET_LINK_LIBRARIES (dumpsolv libsolv)
 
 ADD_EXECUTABLE (mergesolv mergesolv.c )
-TARGET_LINK_LIBRARIES (mergesolv toolstuff libsolvext libsolv)
+TARGET_LINK_LIBRARIES (mergesolv toolstuff libsolvext libsolv ${SYSTEM_LIBRARIES})
 
 INSTALL (TARGETS
     mergesolv