Skip to content

Commit

Permalink
Fix pkgconfig file and add CMake module files
Browse files Browse the repository at this point in the history
This commit fixes the pkgconfig file so that opengl and fltk
libraries and include directories are added to stage.pc, so that
third-party packages can use stage.pc to link with stage without any
other code.

This commit also adds stage-config and stage-config-version cmake module
files, so that find_package(stage) will work.  These cmake modules also
include the opengl and fltk libraries and include directories, so that
third-party packages can link against stage without any other code.
  • Loading branch information
richmattes committed Mar 29, 2015
1 parent c06736b commit 54555de
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,31 @@ ELSE( PLAYER_FOUND )
MESSAGE(STATUS ${INDENT} "Player not detected. If Player is installed but not detected, check your PKG_CONFIG_PATH." )
ENDIF( PLAYER_FOUND )

# Format the fltk libraries for inclusion in stage.pc
SET(PC_LIBRARIES ${FLTK_LIBRARIES} ${OPENGL_LIBRARIES})
SET(PC_INCLUDE_DIRS ${FLTK_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})

SET(PC_LINK_FLAGS "")
FOREACH(LIB ${PC_LIBRARIES})
GET_FILENAME_COMPONENT(LIBNAME ${LIB} NAME_WE)
STRING(REGEX REPLACE "^lib" "" LINKLIB ${LIBNAME})
SET(PC_LINK_FLAGS "${PC_LINK_FLAGS} -l${LINKLIB}")
ENDFOREACH(LIB ${FLTK_LIBRARIES})

SET(PC_INCLUDE_FLAGS "")
FOREACH(INC ${PC_INCLUDE_DIRS})
SET(PC_INCLUDE_FLAGS "${PC_INCLUDE_FLAGS} -I${INC}")
ENDFOREACH(INC ${PC_INCLUDE_DIRS})

# Create the pkgconfig file
CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/stage.pc.in ${CMAKE_CURRENT_BINARY_DIR}/stage.pc @ONLY)
INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/stage.pc DESTINATION ${PROJECT_LIB_DIR}/pkgconfig/)

# Create the CMake module files
CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/stage-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/stage-config.cmake @ONLY)
CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/stage-config-version.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/stage-config-version.cmake @ONLY)
INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/stage-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/stage-config-version.cmake DESTINATION ${PROJECT_LIB_DIR}/cmake/${PROJECT_NAME})

MESSAGE( STATUS "Installation path CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" )

# all targets need these include directories
Expand Down
11 changes: 11 additions & 0 deletions stage-config-version.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set(PACKAGE_VERSION "@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()
14 changes: 14 additions & 0 deletions stage-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# - Config file for Stage
# It defines the following variables:
# STAGE_INCLUDE_DIRS - Stage Include directories
# STAGE_LIBRARIES - Stage link libraries

set(STAGE_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include/@PROJECT_NAME@-@APIVERSION@"
"@FLTK_INCLUDE_DIR@"
"@OPENGL_INCLUDE_DIR@")
list(REMOVE_DUPLICATES STAGE_INCLUDE_DIRS)
set(STAGE_LIBRARIES
"@CMAKE_INSTALL_PREFIX@/@PROJECT_LIB_DIR@/libstage.so"
"@FLTK_LIBRARIES@"
"@OPENGL_gl_LIBRARIES@")

4 changes: 2 additions & 2 deletions stage.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ Version: @VERSION@
# add the incantations to the flags and libs lines below
Requires:

Libs: -L${prefix}/@PROJECT_LIB_DIR@ -lstage @FLTK_LDFLAGS@
Cflags: -I${prefix}/include/Stage-@APIVERSION@ @FLTK_CFLAGS@
Libs: -L${prefix}/@PROJECT_LIB_DIR@ -lstage @PC_LINK_FLAGS@
Cflags: -I${prefix}/include/Stage-@APIVERSION@ @PC_INCLUDE_FLAGS@

0 comments on commit 54555de

Please sign in to comment.