Skip to content

Commit

Permalink
Provide a FindLibSolv.cmake file
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandres committed Oct 6, 2011
1 parent 0db9d7f commit 1fc11eb
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 11 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -37,6 +37,7 @@ SET (BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin")

# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
SET (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
INSTALL( FILES ${CMAKE_MODULE_PATH}/FindLibSolv.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules )

INCLUDE (${CMAKE_SOURCE_DIR}/VERSION.cmake)

Expand Down
95 changes: 95 additions & 0 deletions cmake/modules/FindLibSolv.cmake
@@ -0,0 +1,95 @@
# FindLibSolv - Find libsolv headers and libraries.
#
# Sample:
#
# SET( LibSolv_USE_STATIC_LIBS OFF )
# FIND_PACKAGE( LibSolv REQUIRED ext )
# IF( LibSolv_FOUND )
# INCLUDE_DIRECTORIES( ${LibSolv_INCLUDE_DIRS} )
# TARGET_LINK_LIBRARIES( ... ${LibSolv_LIBRARIES} )
# ENDIF()
#
# Variables used by this module need to be set before calling find_package
# (not that they are cmale cased like the modiulemane itself):
#
# LibSolv_USE_STATIC_LIBS Can be set to ON to force the use of the static
# libsolv libraries. Defaults to OFF.
#
# Supported components:
#
# ext Also include libsolvext
#
# Variables provided by this module:
#
# LibSolv_FOUND Include dir, libsolv and all extra libraries
# specified in the COMPONENTS list were found.
#
# LibSolv_LIBRARIES Link to these to use all the libraries you specified.
#
# LibSolv_INCLUDE_DIRS Include directories.
#
# For each component you specify in find_package(), the following (UPPER-CASE)
# variables are set to pick and choose components instead of just using LibSolv_LIBRARIES:
#
# LIBSOLV_FOUND TRUE if libsolv was found
# LIBSOLV_LIBRARY libsolv libraries
#
# LIBSOLV_${COMPONENT}_FOUND TRUE if the library component was found
# LIBSOLV_${COMPONENT}_LIBRARY The libraries for the specified component
#

# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
IF(LibSolv_USE_STATIC_LIBS)
SET( _ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
SET(CMAKE_FIND_LIBRARY_SUFFIXES .a )
ENDIF()

# Look for the header files
UNSET(LibSolv_INCLUDE_DIRS CACHE)
FIND_PATH(LibSolv_INCLUDE_DIRS NAMES solv/solvable.h)

# Look for the core library
UNSET(LIBSOLV_LIBRARY CACHE)
FIND_LIBRARY(LIBSOLV_LIBRARY NAMES solv)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibSolv DEFAULT_MSG LIBSOLV_LIBRARY LibSolv_INCLUDE_DIRS)
MARK_AS_ADVANCED(
LIBSOLV_FOUND
LIBSOLV_LIBRARY
)

# Prepare return values and collectiong more components
SET(LibSolv_FOUND ${LIBSOLV_FOUND})
SET(LibSolv_LIBRARIES ${LIBSOLV_LIBRARY})
MARK_AS_ADVANCED(
LibSolv_FOUND
LibSolv_LIBRARIES
LibSolv_INCLUDE_DIRS
)

# Look for components
FOREACH(COMPONENT ${LibSolv_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} _UPPERCOMPONENT)
UNSET(LIBSOLV_${_UPPERCOMPONENT}_LIBRARY CACHE)
FIND_LIBRARY(LIBSOLV_${_UPPERCOMPONENT}_LIBRARY NAMES solv${COMPONENT})
SET(LibSolv_${COMPONENT}_FIND_REQUIRED ${LibSolv_FIND_REQUIRED})
SET(LibSolv_${COMPONENT}_FIND_QUIETLY ${LibSolv_FIND_QUIETLY})
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibSolv_${COMPONENT} DEFAULT_MSG LIBSOLV_${_UPPERCOMPONENT}_LIBRARY)
MARK_AS_ADVANCED(
LIBSOLV_${_UPPERCOMPONENT}_FOUND
LIBSOLV_${_UPPERCOMPONENT}_LIBRARY
)
IF(LIBSOLV_${_UPPERCOMPONENT}_FOUND)
SET(LibSolv_LIBRARIES ${LibSolv_LIBRARIES} ${LIBSOLV_${_UPPERCOMPONENT}_LIBRARY})
ELSE()
SET(LibSolv_FOUND FALSE)
ENDIF()
ENDFOREACH()

# restore CMAKE_FIND_LIBRARY_SUFFIXES
IF(Solv_USE_STATIC_LIBS)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES} )
ENDIF()

IF(LibSolv_FOUND AND NOT LibSolv_FIND_QUIETLY)
MESSAGE(STATUS "Found LibSolv: ${LibSolv_INCLUDE_DIRS} ${LibSolv_LIBRARIES}")
ENDIF()
23 changes: 12 additions & 11 deletions package/libsolv.spec.in
Expand Up @@ -184,7 +184,7 @@ cmake $CMAKE_FLAGS \
%{?with_python_binding:-DENABLE_PYTHON=1} \
%{?with_ruby_binding:-DENABLE_RUBY=1} \
-DUSE_VENDORDIRS=1 \
-DCMAKE_SKIP_RPATH=1
-DCMAKE_SKIP_RPATH=1
make %{?jobs:-j %jobs}

%install
Expand All @@ -211,26 +211,27 @@ rm -rf "$RPM_BUILD_ROOT"
%files -n libsolv@LIBSOLV_SOVERSION@
%defattr(-,root,root)
%doc LICENSE*
%_libdir/libsolv.so.*
%_libdir/libsolvext.so.*
%{_libdir}/libsolv.so.*
%{_libdir}/libsolvext.so.*
%endif

%files tools
%defattr(-,root,root)
%exclude /usr/bin/helix2solv
%exclude /usr/bin/solv
/usr/bin/*
%exclude %{_bindir}/helix2solv
%exclude %{_bindir}/solv
%{_bindir}/*

%files devel
%defattr(-,root,root)
%_libdir/libsolv.so
%_libdir/libsolvext.so
/usr/include/solv
/usr/bin/helix2solv
%{_libdir}/libsolv.so
%{_libdir}/libsolvext.so
%{_includedir}/solv
%{_bindir}/helix2solv
%{_datadir}/cmake/Modules/*

%files demo
%defattr(-,root,root)
/usr/bin/solv
%{_bindir}/solv

%if %{with perl_binding}
%files -n perl-solv
Expand Down

0 comments on commit 1fc11eb

Please sign in to comment.