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
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})
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 #
####################################################################
####################################################################
-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")
# 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")
+# 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
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
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)
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
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)
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