Permalink
Browse files

Create hopefully rather sane TomahawkConfig.cmake

  • Loading branch information...
1 parent 83e3ed2 commit 22c305162ce25872667f53e6a513a010b4f87224 @dschmidt dschmidt committed Jan 17, 2013
View
@@ -310,3 +310,45 @@ if( BUILD_TESTS )
enable_testing()
add_subdirectory( tests )
endif()
+
+
+# Add all targets to the build-tree export set
+set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/Tomahawk" CACHE PATH "Installation directory for CMake files")
+set(CMAKE_INSTALL_FULL_CMAKEDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_CMAKEDIR}")
+export(TARGETS tomahawklib tomahawk_portfwd
+ FILE "${PROJECT_BINARY_DIR}/TomahawkLibraryDepends.cmake")
+
+# Export the package for use from the build-tree
+# (this registers the build-tree with a global CMake-registry)
+export(PACKAGE Tomahawk)
+
+# Create a TomahawkBuildTreeSettings.cmake file for the use from the build tree
+configure_file(TomahawkBuildTreeSettings.cmake.in "${PROJECT_BINARY_DIR}/TomahawkBuildTreeSettings.cmake" @ONLY)
+
+# Create the TomahawkConfig.cmake and TomahawkConfigVersion files
+file(RELATIVE_PATH CONF_REL_INCLUDE_DIR "${CMAKE_INSTALL_FULL_CMAKEDIR}" "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
+
+configure_file(TomahawkConfig.cmake.in "${PROJECT_BINARY_DIR}/TomahawkConfig.cmake" @ONLY)
+configure_file(TomahawkConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/TomahawkConfigVersion.cmake" @ONLY)
+file(COPY TomahawkUse.cmake DESTINATION "${PROJECT_BINARY_DIR}")
+file(COPY TomahawkAddPlugin.cmake DESTINATION "${PROJECT_BINARY_DIR}")
+
+
+# Install the cmake files
+install(
+ FILES
+ "${PROJECT_BINARY_DIR}/TomahawkConfig.cmake"
+ "${PROJECT_BINARY_DIR}/TomahawkConfigVersion.cmake"
+ "${PROJECT_BINARY_DIR}/TomahawkUse.cmake"
+ "${PROJECT_BINARY_DIR}/TomahawkAddPlugin.cmake"
+ DESTINATION
+ "${CMAKE_INSTALL_CMAKEDIR}"
+)
+
+# Install the export set for use with the install-tree
+install(
+ EXPORT
+ TomahawkLibraryDepends
+ DESTINATION
+ "${CMAKE_INSTALL_CMAKEDIR}"
+)
File renamed without changes.
@@ -0,0 +1,3 @@
+set(TOMAHAWK_INCLUDE_DIRS
+ "@PROJECT_SOURCE_DIR@/src/libtomahawk"
+ "@PROJECT_BINARY_DIR@")
View
@@ -0,0 +1,21 @@
+# - Config file for the Tomahawk package
+# It defines the following variables
+# TOMAHAWK_INCLUDE_DIRS - include directories for Tomahawk
+# TOMAHAWK_LIBRARIES - libraries to link against
+# TOMAHAWK_EXECUTABLE - the bar executable
+
+# Compute paths
+get_filename_component(TOMAHAWK_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+if(EXISTS "${TOMAHAWK_CMAKE_DIR}/CMakeCache.txt")
+ # In build tree
+ include("${TOMAHAWK_CMAKE_DIR}/TomahawkBuildTreeSettings.cmake")
+else()
+ set(TOMAHAWK_INCLUDE_DIRS "${TOMAHAWK_CMAKE_DIR}/@CONF_REL_INCLUDE_DIR@/libtomahawk")
+endif()
+
+# Our library dependencies (contains definitions for IMPORTED targets)
+include("${TOMAHAWK_CMAKE_DIR}/TomahawkLibraryDepends.cmake")
+
+# These are IMPORTED targets created by TomahawkLibraryDepends.cmake
+set(TOMAHAWK_LIBRARIES tomahawklib)
+set(TOMAHAWK_USE_FILE "${TOMAHAWK_CMAKE_DIR}/TomahawkUse.cmake")
@@ -0,0 +1,12 @@
+set(PACKAGE_VERSION "@TOMAHAWK_VERSION@")
+
+# Check whether the requested PACKAGE_FIND_VERSION is compatible
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
+
@@ -27,4 +27,8 @@ macro(qt_add_translation)
endmacro()
-include( "${Tomahawk_CMAKE_DIR}/TomahawkAddPlugin.cmake" )
+if(NOT TOMAHAWK_CMAKE_DIR)
+ set(TOMAHAWK_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR})
+endif()
+
+include( "${TOMAHAWK_CMAKE_DIR}/TomahawkAddPlugin.cmake" )
@@ -1,4 +1,4 @@
-include(TomahawkAddPlugin)
+include( ${CMAKE_CURRENT_LIST_DIR}/../../TomahawkAddPlugin.cmake )
file(GLOB SUBDIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*")
foreach(SUBDIRECTORY ${SUBDIRECTORIES})
@@ -465,22 +465,12 @@ TARGET_LINK_LIBRARIES( tomahawklib
)
INSTALL( TARGETS tomahawklib
+ EXPORT TomahawkLibraryDepends
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
-# Install cmake config
-install( FILES
- TomahawkConfig.cmake
- TomahawkUse.cmake
- ${CMAKE_SOURCE_DIR}/CMakeModules/TomahawkAddPlugin.cmake
- DESTINATION
- ${CMAKE_INSTALL_LIBDIR}/cmake/Tomahawk
-)
-
-
-
# Install header files
file( GLOB rootHeaders "*.h" )
file( GLOB accountsHeaders "accounts/*.h" )
@@ -47,6 +47,7 @@ IF(WIN32)
ENDIF()
INSTALL( TARGETS tomahawk_portfwd
+ EXPORT TomahawkLibraryDepends
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}

0 comments on commit 22c3051

Please sign in to comment.